Swiftpack.co - 0x0001SUI/KeyboardState as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by 0x0001SUI.
0x0001SUI/KeyboardState v1.1.0
A property wrapper type that shows whether the keyboard is shown or hidden.
⭐️ 2
🕓 2 weeks ago
iOS
.package(url: "https://github.com/0x0001SUI/KeyboardState.git", from: "v1.1.0")

KeyboardState

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")
                        }
                    }
                }
            }
    }
}

GitHub

link
Stars: 2
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

v1.1.0
2 weeks ago

Added missing states (hiding and showing).

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics