-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
184e1ae
commit 7a13d15
Showing
7 changed files
with
76 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
import Foundation | ||
|
||
@dynamicMemberLookup | ||
public struct StepSelection<Parent: StepsCollection, Value>: Identifiable { | ||
|
||
public var parent: Parent | ||
public var value: Value { | ||
get { parent[keyPath: keyPath].wrappedValue } | ||
set { parent[keyPath: keyPath].wrappedValue = newValue } | ||
} | ||
public var id: Parent.AllSteps { parent[keyPath: keyPath].id } | ||
|
||
let keyPath: WritableKeyPath<Parent, StepWrapper<Parent, Value>> | ||
var wrapper: StepWrapper<Parent, Value> { | ||
get { parent[keyPath: keyPath] } | ||
set { parent[keyPath: keyPath] = newValue } | ||
} | ||
|
||
@_disfavoredOverload | ||
public var isSelected: Bool { | ||
parent.selected == parent[keyPath: keyPath].id | ||
} | ||
|
||
public mutating func select() { | ||
parent[keyPath: keyPath].select() | ||
} | ||
|
||
public mutating func select(with value: Value) { | ||
parent[keyPath: keyPath].select(with: value) | ||
} | ||
} | ||
|
||
extension StepSelection where Parent.AllSteps: ExpressibleByNilLiteral { | ||
|
||
public var isSelected: Bool { | ||
get { parent.selected == parent[keyPath: keyPath].id } | ||
set { parent.selected = newValue ? parent[keyPath: keyPath].id : nil } | ||
} | ||
|
||
public mutating func deselect() { | ||
parent.selected = nil | ||
} | ||
} | ||
|
||
extension StepSelection where Value: StepsCollection { | ||
|
||
public subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, StepWrapper<Value, T>>) -> StepSelection<Value, T> { | ||
get { StepSelection<Value, T>(parent: value, keyPath: keyPath) } | ||
set { value = newValue.parent } | ||
} | ||
} | ||
|
||
extension StepsCollection { | ||
|
||
public subscript<Value>(_ keyPath: WritableKeyPath<Self, StepWrapper<Self, Value>>) -> StepSelection<Self, Value> { | ||
get { StepSelection(parent: self, keyPath: keyPath) } | ||
set { self = newValue.parent } | ||
} | ||
} | ||
//import Foundation | ||
// | ||
//@dynamicMemberLookup | ||
//public struct StepSelection<Parent: StepsCollection, Value>: Identifiable { | ||
// | ||
// public var parent: Parent | ||
// public var value: Value { | ||
// get { parent[keyPath: keyPath].wrappedValue } | ||
// set { parent[keyPath: keyPath].wrappedValue = newValue } | ||
// } | ||
// public var id: Parent.AllSteps { parent[keyPath: keyPath].id } | ||
// | ||
// let keyPath: WritableKeyPath<Parent, StepWrapper<Parent, Value>> | ||
// var wrapper: StepWrapper<Parent, Value> { | ||
// get { parent[keyPath: keyPath] } | ||
// set { parent[keyPath: keyPath] = newValue } | ||
// } | ||
// | ||
// @_disfavoredOverload | ||
// public var isSelected: Bool { | ||
// parent.selected == parent[keyPath: keyPath].id | ||
// } | ||
// | ||
// public mutating func select() { | ||
// parent[keyPath: keyPath].select() | ||
// } | ||
// | ||
// public mutating func select(with value: Value) { | ||
// parent[keyPath: keyPath].select(with: value) | ||
// } | ||
//} | ||
// | ||
//extension StepSelection where Parent.AllSteps: ExpressibleByNilLiteral { | ||
// | ||
// public var isSelected: Bool { | ||
// get { parent.selected == parent[keyPath: keyPath].id } | ||
// set { parent.selected = newValue ? parent[keyPath: keyPath].id : nil } | ||
// } | ||
// | ||
// public mutating func deselect() { | ||
// parent.selected = nil | ||
// } | ||
//} | ||
// | ||
//extension StepSelection where Value: StepsCollection { | ||
// | ||
// public subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, StepWrapper<Value, T>>) -> StepSelection<Value, T> { | ||
// get { StepSelection<Value, T>(parent: value, keyPath: keyPath) } | ||
// set { value = newValue.parent } | ||
// } | ||
//} | ||
// | ||
//extension StepsCollection { | ||
// | ||
// public subscript<Value>(_ keyPath: WritableKeyPath<Self, StepWrapper<Self, Value>>) -> StepSelection<Self, Value> { | ||
// get { StepSelection(parent: self, keyPath: keyPath) } | ||
// set { self = newValue.parent } | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters