Created
May 4, 2020 16:44
-
-
Save michzio/7462b8d201902c6079616d858c21223f to your computer and use it in GitHub Desktop.
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 StaticView: View { | |
@State var value1: String = "" | |
@State var value2: String = "" | |
@ObservedObject var avoider = KeyboardAvoider() | |
var body: some View { | |
KeyboardAvoiding(with: avoider) { | |
VStack { | |
Spacer() | |
Text("Static View") | |
Spacer() | |
TextField("Field 1", text: self.$value1, onEditingChanged: { _ in | |
self.avoider.editingField = 1 | |
}) | |
.avoidKeyboard(tag: 1) | |
TextField("Field 2", text: self.$value2, onEditingChanged: { _ in | |
self.avoider.editingField = 2 | |
}) | |
Button(action: { | |
}) { | |
Text("Tap!") | |
} | |
.avoidKeyboard(tag: 2) | |
} | |
.padding(16) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment