Skip to content

Instantly share code, notes, and snippets.

@michzio
Created May 4, 2020 16:44
Show Gist options
  • Save michzio/7462b8d201902c6079616d858c21223f to your computer and use it in GitHub Desktop.
Save michzio/7462b8d201902c6079616d858c21223f to your computer and use it in GitHub Desktop.
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