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.
⭐️ 3
🕓 1 year 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: 3
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v1.1.0
1 year ago

Added missing states (hiding and showing).

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