Created
December 2, 2020 06:08
-
-
Save SlappyAUS/de8623a2bfe7ef6f47357a674a8b8ce7 to your computer and use it in GitHub Desktop.
ConfirmationTextField #swift #swiftui #io
This file contains hidden or 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 ConfirmationTextField: View { | |
| @State private var showtextFieldToolbar = false | |
| let keyboardType: UIKeyboardType | |
| @Binding var text: String | |
| var body: some View { | |
| TextField("", text: $text) | |
| { isChanged in | |
| if isChanged { | |
| showtextFieldToolbar = true | |
| } | |
| } onCommit: { | |
| showtextFieldToolbar = false | |
| } | |
| .overlay( | |
| VStack { | |
| if showtextFieldToolbar { | |
| HStack { | |
| Spacer() | |
| Button { | |
| showtextFieldToolbar = false | |
| UIApplication.shared | |
| .sendAction(#selector(UIResponder.resignFirstResponder), | |
| to: nil, from: nil, for: nil) | |
| } label: { | |
| HStack { | |
| Image(systemName: "checkmark.circle.fill") | |
| Text("done".localized()) | |
| } | |
| .foregroundColor(ColorManager.interactive_0) | |
| } | |
| } | |
| .frame(idealWidth: .infinity, maxWidth: .infinity, alignment: .center) | |
| } | |
| } | |
| ) | |
| .keyboardType(keyboardType) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment