diff --git a/AppContainer.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AppContainer.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2b68538..6ddc981 100644 --- a/AppContainer.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AppContainer.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -9,6 +9,15 @@ "version" : "0.0.2" } }, + { + "identity" : "keypathvalue", + "kind" : "remoteSourceControl", + "location" : "https://github.com/p-x9/KeyPathValue.git", + "state" : { + "revision" : "6aeb41d6c5564ae1f18e8b7a4bc5733d739558e3", + "version" : "0.0.1" + } + }, { "identity" : "swift-collections", "kind" : "remoteSourceControl", diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..994f755 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,32 @@ +{ + "pins" : [ + { + "identity" : "editvalueview", + "kind" : "remoteSourceControl", + "location" : "https://github.com/p-x9/EditValueView.git", + "state" : { + "revision" : "16e74e228f320c0a2c55571313f06989e97c1ab4", + "version" : "0.0.2" + } + }, + { + "identity" : "keypathvalue", + "kind" : "remoteSourceControl", + "location" : "https://github.com/p-x9/KeyPathValue.git", + "state" : { + "revision" : "6aeb41d6c5564ae1f18e8b7a4bc5733d739558e3", + "version" : "0.0.1" + } + }, + { + "identity" : "swiftuicolor", + "kind" : "remoteSourceControl", + "location" : "https://github.com/p-x9/SwiftUIColor.git", + "state" : { + "revision" : "3696e78e84bc140dca6f865c297e1a3b405a882b", + "version" : "0.0.4" + } + } + ], + "version" : 2 +} diff --git a/Package.swift b/Package.swift index a5a1d58..8ded1bb 100644 --- a/Package.swift +++ b/Package.swift @@ -18,12 +18,15 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/p-x9/EditValueView.git", exact: "0.0.2") + .package(url: "https://github.com/p-x9/EditValueView.git", exact: "0.0.2"), + .package(url: "https://github.com/p-x9/KeyPathValue.git", exact: "0.0.1") ], targets: [ .target( name: "AppContainer", - dependencies: [] + dependencies: [ + .product(name: "KeyPathValue", package: "KeyPathValue") + ] ), .target( name: "AppContainerUI", diff --git a/Sources/AppContainer/AppContainer.swift b/Sources/AppContainer/AppContainer.swift index 982f74c..edeac16 100644 --- a/Sources/AppContainer/AppContainer.swift +++ b/Sources/AppContainer/AppContainer.swift @@ -1,4 +1,5 @@ import Foundation +import KeyPathValue public class AppContainer { public static let standard = AppContainer() diff --git a/Sources/AppContainer/Model/WritableKeyPathWithValue.swift b/Sources/AppContainer/Model/WritableKeyPathWithValue.swift deleted file mode 100644 index bc0079a..0000000 --- a/Sources/AppContainer/Model/WritableKeyPathWithValue.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// WritableKeyPathWithValue.swift -// -// -// Created by p-x9 on 2022/10/02. -// -// - -import Foundation - -public struct WritableKeyPathWithValue { - public let keyPath: PartialKeyPath - public let value: Any - public let apply: (inout Root) -> Void - - public init(_ keyPath: WritableKeyPath, _ value: Value) { - self.keyPath = keyPath - self.value = value - self.apply = { $0[keyPath: keyPath] = value } - } -} - -public struct WritableKeyPathValueApplier { - public let keyPath: PartialKeyPath - public let apply: (Any, inout Root) -> Void - - public init(_ keyPath: WritableKeyPath) { - self.keyPath = keyPath - self.apply = { - guard let value = $0 as? Value else { return } - $1[keyPath: keyPath] = value - } - } -} - - -extension WritableKeyPathWithValue { - public init(_ keyValueApplier: WritableKeyPathValueApplier, value: Any) { - self.keyPath = keyValueApplier.keyPath - self.value = value - self.apply = { - keyValueApplier.apply(value, &$0) - } - } -} -