Created
November 11, 2019 07:19
-
-
Save nickffox/7606965ff9737deab80fd3e0dbba27c4 to your computer and use it in GitHub Desktop.
An example of using the KeyboardObserving Swift Package
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 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