All Projects → nickffox → Keyboardobserving

nickffox / Keyboardobserving

Licence: mit
⌨️A Combine-based way to observe and adjust for Keyboard notifications in SwiftUI

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Keyboardobserving

Switch Desktop
⚡️ Keyboard-driven commands to navigate your apps faster
Stars: ✭ 320 (-19.8%)
Mutual labels:  keyboard
Key And Pad
🎹 Fun experiment with the Web Audio API 🎶
Stars: ✭ 360 (-9.77%)
Mutual labels:  keyboard
Ppstickerkeyboard
iOS 表情键盘
Stars: ✭ 377 (-5.51%)
Mutual labels:  keyboard
Pcb
PCB and PCB related bits
Stars: ✭ 325 (-18.55%)
Mutual labels:  keyboard
Cool ui
用flutter实现一些我认为好看的UI控件,有Popover,仿Weui的Toast,自定义键盘
Stars: ✭ 349 (-12.53%)
Mutual labels:  keyboard
Keyberon
A rust crate to create a pure rust keyboard firmware.
Stars: ✭ 355 (-11.03%)
Mutual labels:  keyboard
Keychron
Settings for Keychron keyboards
Stars: ✭ 312 (-21.8%)
Mutual labels:  keyboard
React Key Handler
React component to handle keyboard events 🔑
Stars: ✭ 386 (-3.26%)
Mutual labels:  keyboard
Keyboardchangelistener
Simple and powerful keyboard show/hidden listeners
Stars: ✭ 352 (-11.78%)
Mutual labels:  keyboard
Rbtray
A fork of RBTray from http://sourceforge.net/p/rbtray/code/.
Stars: ✭ 365 (-8.52%)
Mutual labels:  keyboard
Devicekit
DeviceKit is a value-type replacement of UIDevice.
Stars: ✭ 3,566 (+793.73%)
Mutual labels:  swiftpm
Hidekeyboard
仿iOS输入法点击输入框以外区域 自动隐藏软键盘轻量级库 , Imitation iOS automatic hidden soft keyboard
Stars: ✭ 341 (-14.54%)
Mutual labels:  keyboard
Tswechat
A WeChat alternative. Written in Swift 5.
Stars: ✭ 3,674 (+820.8%)
Mutual labels:  keyboard
React Native Input Scroll View
Perfect TextInput ScrollView
Stars: ✭ 323 (-19.05%)
Mutual labels:  keyboard
Duckhunt
🎯 Prevent RubberDucky (or other keystroke injection) attacks
Stars: ✭ 386 (-3.26%)
Mutual labels:  keyboard
Numeric Keyboard
Number keyboard for mobile browsers
Stars: ✭ 317 (-20.55%)
Mutual labels:  keyboard
Python Keyboard
A hand-wired USB & Bluetooth keyboard powered by Python and more
Stars: ✭ 360 (-9.77%)
Mutual labels:  keyboard
Ucr
Universal Control Remapper [Alpha]
Stars: ✭ 399 (+0%)
Mutual labels:  keyboard
Sharpkeys
SharpKeys is a utility that manages a Registry key that allows Windows to remap one key to any other key.
Stars: ✭ 4,402 (+1003.26%)
Mutual labels:  keyboard
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+829.82%)
Mutual labels:  swiftpm

⌨️ Keyboard Observing

A Combine-based solution for observing and avoiding the keyboard in SwiftUI.

Swift Support Platform CocoaPods Compatible SwiftPM Compatible

Table of Contents

About

This package give you the ability to observe changes to keyboard state using the Keyboard ObservableObject type.

It also provides a KeyboardObservingView that adjusts its content to avoid the keyboard, and a .keyboardObserving() ViewModifier that adjusts the modified view to avoid the keyboard.

Demo

Requirements

  • iOS 13.0+
  • Xcode 11+
  • Swift 5.1+

Installation

This package can be installed using CocoaPods or Swift Package Manager.

CocoaPods

Add the following line to your Podfile:

pod 'KeyboardObserving'

For more information about how to get started with CocoaPods, check out the CocoaPods website.

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(
        url: "https://github.com/nickffox/KeyboardObserving.git", 
        .branch:("master")
    )
]

If you're using SPM through Xcode:

  1. Go to File > Swift Packages > Add Package Dependency
  2. Enter https://github.com/nickffox/KeyboardObserving
  3. Select the branch option, and type "master"

For more information about how to get started with the Swift Package Manager, check out the Official SPM website or the SPM project on GitHub.

Usage

Using the KeyboardObserving ViewModifier

Add the .keyboardObserving() ViewModifier to your custom SwiftUI view.

import KeyboardObserving

struct YourView: View {

  var body: some View {
    VStack {
      // Your Content Here
    }
    .keyboardObserving()
  }
}

Using Keyboard and KeyboardObservingView

1. Add a Keyboard to your environment

In your SceneDelegate.swift file, add a Keyboard property, and add it to your scene's environment.

import KeyboardObserving

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

  var window: UIWindow?

  // A Keyboard that will be added to the environment.
  var keyboard = Keyboard()


  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

    // Use a UIHostingController as window root view controller
    if let windowScene = scene as? UIWindowScene {
      let window = UIWindow(windowScene: windowScene)
      window.rootViewController = UIHostingController(
        rootView: YourRootView()
          // Adds the keyboard to the environment
          .environmentObject(keyboard)
      )
      self.window = window
      window.makeKeyAndVisible()
    }
  }
}
2. Create your View

Add your view's content inside of a KeyboardObservingView .

import KeyboardObserving

struct YourView: View {

  var body: some View {
    KeyboardObservingView {
      // Your content goes here!
    }
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].