Implement `static func Binding<Value>.constant` (#178)
Unrelated formatting changes were added by the SwiftFormat pre-commit hook.
This commit is contained in:
parent
2b3010a631
commit
9cf606ef0c
|
@ -37,7 +37,9 @@ typealias Updater<T> = (inout T) -> ()
|
|||
self.set = set
|
||||
}
|
||||
|
||||
public subscript<Subject>(dynamicMember keyPath: WritableKeyPath<Value, Subject>) -> Binding<Subject> {
|
||||
public subscript<Subject>(
|
||||
dynamicMember keyPath: WritableKeyPath<Value, Subject>
|
||||
) -> Binding<Subject> {
|
||||
.init(
|
||||
get: {
|
||||
self.wrappedValue[keyPath: keyPath]
|
||||
|
@ -46,4 +48,8 @@ typealias Updater<T> = (inout T) -> ()
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
static func constant(_ value: Value) -> Self {
|
||||
.init(get: { value }, set: { _ in })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ extension SecureField: ViewDeferredToRenderer where Label == Text {
|
|||
], listeners: [
|
||||
"keypress": { event in if event.key == "Enter" { proxy.onCommit() } },
|
||||
"input": { event in
|
||||
if let newValue = event.target.object?.value.string {
|
||||
proxy.textBinding.wrappedValue = newValue
|
||||
}
|
||||
},
|
||||
if let newValue = event.target.object?.value.string {
|
||||
proxy.textBinding.wrappedValue = newValue
|
||||
}
|
||||
},
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,10 +44,10 @@ extension TextField: ViewDeferredToRenderer where Label == Text {
|
|||
"blur": { _ in proxy.onEditingChanged(false) },
|
||||
"keypress": { event in if event.key == "Enter" { proxy.onCommit() } },
|
||||
"input": { event in
|
||||
if let newValue = event.target.object?.value.string {
|
||||
proxy.textBinding.wrappedValue = newValue
|
||||
}
|
||||
},
|
||||
if let newValue = event.target.object?.value.string {
|
||||
proxy.textBinding.wrappedValue = newValue
|
||||
}
|
||||
},
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue