Skip to content

Instantly share code, notes, and snippets.

@nickffox
Created November 11, 2019 07:19
Show Gist options
  • Save nickffox/7606965ff9737deab80fd3e0dbba27c4 to your computer and use it in GitHub Desktop.
Save nickffox/7606965ff9737deab80fd3e0dbba27c4 to your computer and use it in GitHub Desktop.
An example of using the KeyboardObserving Swift Package
struct ContentView: View {
var body: some View {
VStack {
ColorList()
TextInputView()
}.keyboardObserving()
}
}
struct ColorList: View {
var colors: [Color] = [
.red,
.orange,
.yellow,
.green,
.blue,
.purple,
]
var body: some View {
List(colors, id: \.self) {
$0
.frame(height: 100)
}
}
}
struct TextInputView: View {
@State var message: String = ""
var body: some View {
TextField("Message", text: $message)
.padding()
.background(Color.gray)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment