struct NoteEditor: View {
@ObservedObject var note: Note
@KeyboardState private var keyboardState: KeyboardVisibility
@FocusState private var isFocused: Bool
var body: some View {
TextEditor(text: $note.text)
.focused($isFocused)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
if keyboardState == .visible {
Button {
isFocused = false
} label: {
Label("Hide Keyboard", systemImage: "keyboard.chevron.compact.down")
}
}
}
}
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
A property wrapper type that shows whether the keyboard is shown or hidden.
License
0x0001SUI/KeyboardState
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A property wrapper type that shows whether the keyboard is shown or hidden.