Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into antoine/swift6_prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnmrndn committed Nov 13, 2024
2 parents f26ec58 + dc9f29f commit 05cb00c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ let package = Package(
]
),
],
swiftLanguageVersions: [.v5]
swiftLanguageModes: [.v6, .v5]
)
19 changes: 1 addition & 18 deletions Sources/StorybookKit/Internals/TargetViewControllerKey.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
import SwiftUI

public enum _ViewControllerKey: EnvironmentKey {
public static var defaultValue: UIViewController?
}

enum TestKey: EnvironmentKey {
static var defaultValue: String { "default" }
}


extension EnvironmentValues {
var _targetViewController: UIViewController? {
get { self[_ViewControllerKey.self] }
set { self[_ViewControllerKey.self] = newValue }
}

var test: String {
get { self[TestKey.self] }
set { self[TestKey.self] = newValue }
}
@Entry var _targetViewController: UIViewController?
}
8 changes: 4 additions & 4 deletions Sources/StorybookKit/Primitives/BookPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Foundation
import SwiftUI
import ResultBuilderKit

public struct DeclarationIdentifier: Hashable, Codable {
public struct DeclarationIdentifier: Hashable, Codable, Sendable {

public let index: Int

Expand All @@ -37,7 +37,7 @@ public struct DeclarationIdentifier: Hashable, Codable {
}

private let _lock = NSLock()
private var _counter: Int = 0
private nonisolated(unsafe) var _counter: Int = 0
private func issueUniqueNumber() -> Int {
_lock.lock()
defer {
Expand All @@ -52,13 +52,13 @@ public struct BookPage: BookView, Identifiable {

@Environment(\.bookContext) var context

public var id: DeclarationIdentifier {
public nonisolated var id: DeclarationIdentifier {
declarationIdentifier
}

public let title: String
public let destination: AnyView
public let declarationIdentifier: DeclarationIdentifier
public nonisolated let declarationIdentifier: DeclarationIdentifier
private let file: StaticString
private let line: UInt

Expand Down
3 changes: 0 additions & 3 deletions Sources/StorybookKit/Primitives/BookPresent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import SwiftUI
public struct BookPresent: BookView {

@Environment(\._targetViewController) private var targetViewController
@Environment(\.test) var test

public let declarationIdentifier: DeclarationIdentifier
public let presentedViewControllerBlock: @MainActor () -> UIViewController
Expand All @@ -44,8 +43,6 @@ public struct BookPresent: BookView {
public var body: some View {
Button(title) {
let viewController = presentedViewControllerBlock()
print(test)
print(targetViewController)
targetViewController?.present(viewController, animated: true)
}
}
Expand Down
15 changes: 2 additions & 13 deletions Sources/StorybookKit/Primitives/BookProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,8 @@ public protocol BookProvider {
static var bookBody: BookPage { get }
}

private enum BookContextKey: EnvironmentKey {
static var defaultValue: BookStore?
}

extension EnvironmentValues {

public var bookContext: BookStore? {
get {
self[BookContextKey.self]
}
set {
self[BookContextKey.self] = newValue
}
}

@Entry public var bookContext: BookStore?

}

0 comments on commit 05cb00c

Please sign in to comment.