{"id":17160675,"url":"https://github.com/nickffox/keyboardobserving","last_synced_at":"2025-04-04T23:08:21.939Z","repository":{"id":47460385,"uuid":"202786811","full_name":"nickffox/KeyboardObserving","owner":"nickffox","description":"⌨️A Combine-based way to observe and adjust for Keyboard notifications in SwiftUI","archived":false,"fork":false,"pushed_at":"2023-03-31T08:38:05.000Z","size":354,"stargazers_count":484,"open_issues_count":6,"forks_count":36,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-30T08:19:05.650Z","etag":null,"topics":["combine","ios","keyboard","swift","swiftpackage","swiftpm","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nickffox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-08-16T19:22:22.000Z","updated_at":"2024-10-23T08:42:08.000Z","dependencies_parsed_at":"2024-01-14T02:37:15.429Z","dependency_job_id":"ffe78f7a-6768-4a6e-9dc4-1a872b2f500c","html_url":"https://github.com/nickffox/KeyboardObserving","commit_stats":{"total_commits":19,"total_committers":9,"mean_commits":2.111111111111111,"dds":0.631578947368421,"last_synced_commit":"df105a7c43a93b06492ee5832037e20c8f472b46"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickffox%2FKeyboardObserving","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickffox%2FKeyboardObserving/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickffox%2FKeyboardObserving/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickffox%2FKeyboardObserving/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickffox","download_url":"https://codeload.github.com/nickffox/KeyboardObserving/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261604,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["combine","ios","keyboard","swift","swiftpackage","swiftpm","swiftui"],"created_at":"2024-10-14T22:25:37.170Z","updated_at":"2025-04-04T23:08:21.919Z","avatar_url":"https://github.com/nickffox.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⌨️ Keyboard Observing\n### A Combine-based solution for observing and avoiding the keyboard in SwiftUI.\n\n![Swift Support](https://img.shields.io/badge/Swift-5.1-orange.svg) \n![Platform](https://img.shields.io/badge/Platforms-iOS-lightgray.svg?style=flat)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/KeyboardObserving.svg)](https://img.shields.io/cocoapods/v/KeyboardObserving.svg)\n[![SwiftPM Compatible](https://img.shields.io/badge/SwiftPM-Compatible-brightgreen.svg)](https://swift.org/package-manager/)\n\n\n## Table of Contents\n- [About](#about)\n- [Requirements](#requirements)\n- [Installation](#installation)\n    - [CocoaPods](#cocoapods)\n    - [Swift Package Manager](#swift-package-manager)\n- [Usage](#usage)\n    - [KeyboardObserving](#using-the-keyboardobserving-viewmodifier)\n    - [Keyboard and KeyboardObservingView](#using-keyboard-and-keyboardobservingview)\n\n\n## About\n\nThis package give you the ability to observe changes to keyboard state using the `Keyboard` `ObservableObject` type.\n\nIt 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.\n\n![Demo](./images/demo.gif)\n\n\n## Requirements\n\n- iOS 13.0+\n- Xcode 11+\n- Swift 5.1+\n\n## Installation\n\nThis package can be installed using CocoaPods or Swift Package Manager.\n\n#### CocoaPods\n\nAdd the following line to your `Podfile`:\n\n```\npod 'KeyboardObserving'\n```\n\nFor more information about how to get started with CocoaPods, check out the [CocoaPods website](https://cocoapods.org/).\n\n#### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```\ndependencies: [\n    .package(\n        url: \"https://github.com/nickffox/KeyboardObserving.git\", \n        .branch:(\"master\")\n    )\n]\n```\n\nIf you're using SPM through Xcode:\n\n1. Go to `File \u003e Swift Packages \u003e Add Package Dependency` \n2. Enter https://github.com/nickffox/KeyboardObserving\n3. Select the `branch` option, and type \"master\"\n\nFor more information about how to get started with the Swift Package Manager, check out the [Official SPM website](https://swift.org/package-manager/) or the [SPM project on GitHub](https://github.com/apple/swift-package-manager).\n\n## Usage\n\n#### Using the `KeyboardObserving` ViewModifier\n\nAdd the `.keyboardObserving()` ViewModifier to your custom SwiftUI view. \n\n```swift\nimport KeyboardObserving\n\nstruct YourView: View {\n\n  var body: some View {\n    VStack {\n      // Your Content Here\n    }\n    .keyboardObserving()\n  }\n}\n```\n\n#### Using `Keyboard` and `KeyboardObservingView`\n\n\n##### 1. Add a Keyboard to your environment\n\nIn your SceneDelegate.swift file, add a `Keyboard` property, and add it to your scene's environment.\n\n```swift\nimport KeyboardObserving\n\nclass SceneDelegate: UIResponder, UIWindowSceneDelegate {\n\n  var window: UIWindow?\n\n  // A Keyboard that will be added to the environment.\n  var keyboard = Keyboard()\n\n\n  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {\n    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.\n    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.\n    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).\n\n    // Use a UIHostingController as window root view controller\n    if let windowScene = scene as? UIWindowScene {\n      let window = UIWindow(windowScene: windowScene)\n      window.rootViewController = UIHostingController(\n        rootView: YourRootView()\n          // Adds the keyboard to the environment\n          .environmentObject(keyboard)\n      )\n      self.window = window\n      window.makeKeyAndVisible()\n    }\n  }\n}\n```\n\n##### 2. Create your View\n\nAdd your view's content inside of a `KeyboardObservingView` .\n\n```swift\nimport KeyboardObserving\n\nstruct YourView: View {\n\n  var body: some View {\n    KeyboardObservingView {\n      // Your content goes here!\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickffox%2Fkeyboardobserving","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickffox%2Fkeyboardobserving","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickffox%2Fkeyboardobserving/lists"}