-
-
Save laevandus/4b4f4898f7fc59a5aa91e4c8691afbd6 to your computer and use it in GitHub Desktop.
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
struct ContentView: View { | |
@StateObject var viewModel = ViewModel() | |
enum FormEntry: Hashable { | |
case lastName, firstName, email | |
} | |
@FocusState var focused: FormEntry? | |
var body: some View { | |
VStack { | |
Text("Application") | |
TextField("Last Name", text: $viewModel.lastName, prompt: nil) | |
.focused($focused, equals: .lastName) | |
TextField("First Name", text: $viewModel.firstName, prompt: nil) | |
.focused($focused, equals: .firstName) | |
TextField("Email", text: $viewModel.email, prompt: nil) | |
.focused($focused, equals: .email) | |
Button("Reset") { | |
viewModel.reset() | |
focused = .lastName | |
} | |
} | |
.frame(idealWidth: 600) | |
.padding() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment