File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
Demo Project/ResponsiveTextFieldDemo
Sources/ResponsiveTextField Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -90,9 +90,9 @@ struct ContentView: View {
9090 isSecure: hidePassword,
9191 firstResponderDemand: $passwordResponderDemand. animation ( ) ,
9292 configuration: . combine( . password, . lastOfChain) ,
93- onFirstResponderStateChanged: FirstResponderStateChangeHandler { isFirstResponder in
94- isPasswordFirstResponder = isFirstResponder
95- } . animation ( ) ,
93+ onFirstResponderStateChanged: FirstResponderStateChangeHandler
94+ . updates ( $ isPasswordFirstResponder)
95+ . animation ( ) ,
9696 handleReturn: { passwordResponderDemand = . shouldResignFirstResponder } ,
9797 handleDelete: {
9898 if $0. isEmpty {
Original file line number Diff line number Diff line change @@ -204,6 +204,20 @@ public struct FirstResponderStateChangeHandler {
204204 }
205205}
206206
207+ extension FirstResponderStateChangeHandler {
208+ /// Returns a change handler that updates a `Bool` binding with the `isFirstResponder`
209+ /// value whenever it changes.
210+ ///
211+ /// - Parameters:
212+ /// - binding: A binding to some Boolean state property that should be updated.
213+ ///
214+ public static func updates( _ binding: Binding < Bool > ) -> Self {
215+ . init { isFirstResponder in
216+ binding. wrappedValue = isFirstResponder
217+ }
218+ }
219+ }
220+
207221/// Represents a request to change the text field's first responder state.
208222///
209223public enum FirstResponderDemand : Equatable {
You can’t perform that action at this time.
0 commit comments