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
enum CurrentField{ | |
case field1 | |
case field2 | |
} | |
struct TextFieldFocus: View { | |
@State var field1 = "" | |
@State var field2 = "" | |
@FocusState var activeState: CurrentField? | |
var body: some View { | |
VStack{ | |
TextField("Email", text: $field1) | |
.focused($activeState, equals: .field1) | |
.submitLabel(.continue) | |
SecureField("Password", text: $field2) | |
.focused($activeState, equals: .field2) | |
.submitLabel(.send) | |
Button("Goto Email") { | |
activeState = .field1 | |
} | |
Button("Goto Password") { | |
activeState = .field2 | |
} | |
} | |
.padding() | |
.textFieldStyle(.roundedBorder) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment