A 2020s compatible React Native keyboard avoiding view for Android and iOS that just works.

Overview

react-native-keyboard-shift

GitHub license npm version PRs Welcome

Example

Snack coming soon

Until then:

  1. Clone this repo:
git clone https://github.com/FullStackCraft/react-native-keyboard-shift
  1. Move into the example folder:
cd react-native-keyboard-shift/example
  1. Install dependencies:
npm install
  1. Start Metro
npm start
  1. Start Android or iOS
npm run android
# -or- iOS
npm run ios

Enjoy the juicy keyboard shifty-ness!

Usage In Your Project

Install and save this package as a dependency:

npm install --save @fullstackcraft/react-native-keyboard-shift

Import and use the KeyboardShift component:

import '@fullstackcraft/react-native-keyboard-shift'
// other imports

export default function YourCoolKeyboardScreen () {

    // Other logic, variables, etc.

    return (
        <KeyboardShift>
            {/* Screen components */}
        </KeyboardShift>
    )
}

ANOTHER Keyboard Shifting Component?!

See the original blog post that led to the creation of this library for more information.

Comments
  • Type Declarations Not Found

    Type Declarations Not Found

    As the title states, the current arrangement of this package, the type declarations cannot be found:

    Cannot find module '@fullstackcraft/react-native-keyboard-shift' or its corresponding type declarations.
    

    This error can be immediately seen in example/App.tsx, after installing all dependencies.

    bug help wanted 
    opened by princefishthrower 7
  • fix: keyboardHeight calc error when keyboard is shown at the first time

    fix: keyboardHeight calc error when keyboard is shown at the first time

    we don't need to depend on useKeyboard from react-native-community/hooks since we only want the keyboard height when keyboard displays. we can do that naturally in the keyboardDidShow event.

    opened by chj-damon 1
  • New (apparently with React Native 0.66): undefined is not a function

    New (apparently with React Native 0.66): undefined is not a function

    Haven't seen this until upgrading to React Native 0.66. This is because react native has removed the removeAllListeners from Keyboard: see here

    so the effect:

    useEffect(() => {
        Keyboard.addListener('keyboardDidShow', handleKeyboardDidShow);
        Keyboard.addListener('keyboardDidHide', handleKeyboardDidHide);
        return () => {
          Keyboard.removeAllListeners('keyboardDidShow');
          Keyboard.removeAllListeners('keyboardDidHide');
        }
      }, [])
    

    should now become:

    useEffect(() => {
        setDidShowListener(Keyboard.addListener('keyboardDidShow', handleKeyboardDidShow));
        setDidHideListener(Keyboard.addListener('keyboardDidHide', handleKeyboardDidHide));
        return () => {
          if (didShowListener){
            didShowListener.remove();
          }
          if (didHideListener) {
            didHideListener.remove();
          }
        }
      }, [])
    

    Edit: this didn't actually solve the mysterious error. I still get TypeError: undefined is not a function - tried ErrorBoundary, try / catch in every function of the component, can't find where it's coming from 馃し

    opened by princefishthrower 0
  • Enhancement - Dismiss Keyboard with Swipe Down

    Enhancement - Dismiss Keyboard with Swipe Down

    As is possible in apps like WhatsApp, a swipe downwards on the content above an open keyboard will close the keyboard. This should be realized in an optional prop shouldKeyboardCloseWithSwipe, default true. I can probably tackle this.

    opened by princefishthrower 1
  • null is not an object (evaluating currentlyFocusedInputRef.measure)

    null is not an object (evaluating currentlyFocusedInputRef.measure)

    An error is thrown within the handleKeyboardDidShow callback whenever a nested TextInput within a <KeyboardShift /> is focused (iPhone X, RN 0.63.0).

    opened by cawfree 2
  • Invalid hook call.

    Invalid hook call.

    When nesting my application within the <KeyboardShift />, it fails to render.

    There's a couple of reasons why this could be:

    1. The entire dependency stack for this library (including a duplicate version of React) is included. Many of these could be moved to devDependencies/peerDependencies, with an explicit statement that the library depends upon @react-navigation/elements.
    2. This line which depends on conditional hook execution.

    I was able to resolve the issue locally by installing @react-navigation/elements to my root project and deleting the local node_modules directory installed at node_modules/\@fullstackcraft/.

    The package.json could look something like:

    {
      "name": "@fullstackcraft/react-native-keyboard-shift",
      "version": "1.1.4",
      "description": "A 2020s compatible keyboard avoiding view for Android and iOS that just works.",
      "main": "lib/index.js",
      "types": "lib/index.d.ts",
      "scripts": {
        "test": "jest --config jestconfig.json",
        "build": "tsc",
        "format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
        "lint": "tslint -p tsconfig.json",
        "prepare": "npm run build",
        "prepublishOnly": "npm test && npm run lint",
        "preversion": "npm run lint",
        "version": "npm run format && git add -A src",
        "postversion": "git push && git push --tags"
      },
      "dependencies": {
        "@react-native-community/hooks": "^2.6.0",
    -   "@react-navigation/elements": "^1.1.2",
    +   "@react-navigation/elements": "^1.1.2"
    -    "react": ">= 17.0.2",
    -    "react-native": ">=0.64.0"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/FullStackCraft/react-native-keyboard-shift.git"
      },
      "keywords": [
        "react",
        "native",
        "keyboard",
        "keyboardshift",
        "keyboard",
        "shift",
        "android",
        "ios"
      ],
      "author": "Chris Frewin",
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/FullStackCraft/react-native-keyboard-shift/issues"
      },
      "homepage": "https://github.com/FullStackCraft/react-native-keyboard-shift#readme",
      "devDependencies": {
        "@types/jest": "^27.0.2",
        "@types/node": "^16.10.2",
        "@types/react": "^17.0.26",
        "@types/react-native": "^0.65.3",
        "jest": "^27.2.4",
        "prettier": "^2.4.1",
    +   "react": ">= 17.0.2",
    +   "react-native": ">=0.64.0",
        "ts-jest": "^27.0.5",
        "tslint": "^6.1.3",
        "tslint-config-prettier": "^1.18.0"
      },
      "files": [
        "lib/**/*"
      ]
    }
    
    
    opened by cawfree 2
Owner
Full Stack Craft
Full stack software.
Full Stack Craft
React-native-user-interface - Change React Native userinterface at runtime

react-native-user-interface change RN userinterface at runtime. Installation npm

Ahmed Eid 0 Jan 11, 2022
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.

NativeScript empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile de

NativeScript 22k Dec 31, 2022
An Animated Scrolling View for React Native applications, supported on both iOS and Android

react-native-focused-scroll An Animated Scrolling View for React Native applications, supported on both iOS and Android Preview react-native-focus-scr

Fatemeh Marzoughi (Saba) 3 Aug 12, 2022
Initiate immediate phone call for React Native on iOS and Android.

react-native-immediate-call-library Initiate immediate phone call for React Native on iOS and Android. Getting started Using npm: npm install react-na

null 7 Sep 7, 2022
馃殌 React Native Segmented Control, Pure Javascript for iOS and Android

Installation Add the dependency: npm i react-native-segmented-control-2 Peer Dependencies Zero Dependency ?? Usage Import import SegmentedControl from

FreakyCoder 11 Nov 10, 2022
馃寗 Photo editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and PhotoEditor (Android)

React Native Photo Editor (RNPE) ?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, Brightroom (iOS) and Ph

Baron Ha. 242 Dec 28, 2022
鈿★笍 A supercharged native Web View for iOS and Android 鈿★笍

鈿★笍 A supercharged native Web View for iOS and Android 鈿★笍 Ionic Portals is a supercharged native Web View component for iOS and Android that lets you a

Ionic 46 Dec 27, 2022
React Native Stone SDK Implementation (Support for both Mobile and POS versions)

react-native-stone-pos Stone Android POS Native Module Installation Stone has a private packageCloud repository, so we need to have your token before

8Sistemas 9 Dec 10, 2022
FlorisBoard is a free and open-source keyboard for Android

FlorisBoard FlorisBoard is a free and open-source keyboard for Android 6.0+ devices. It aims at being modern, user-friendly and customizable while ful

FlorisBoard 3.7k Jan 5, 2023
A demo for Android font typeface support in React Native!

A Step-by-step Guide to a Consistent Multi-Platform Font Typeface Experience in React Native Goal Be able to use font typeface modifiers such as fontW

Jules Sam. Randolph 53 Dec 23, 2022
Library to read incoming SMS in Android for Expo (React Native)

react-native-expo-read-sms Maintainers maniac-tech Active maintainer Installation Install this in your managed Expo project by running this command: $

Abhishek Jain 15 Jan 2, 2023
GeckoView implementation on android for React Native.

react-native-geckoview A fully functional implementation of GeckoView on android for react native. The component supports two-way messaging similar to

Ammar Ahmed 7 Nov 24, 2022
Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.

Uncompress React Native Simple library to decompress files .zip, .rar, .cbz and .cbr in React Native. Installation yarn add uncompress-react-native o

Adriano Souza Costa 40 Nov 24, 2022
A react native interface for integrating payments using PayPal

react-native-paypal Getting started Installation npm install react-native-paypal Android Specific Add this to your build.gradle maven { url "https:

eKreative 14 Sep 25, 2022
Make SIP calls from react-native using Linphone SDK

react-native-sip Make SIP calls from react-native using Linphone SDK Installation npm install react-native-sip Usage import { multiply } from "react-n

Woonivers 2 Jun 30, 2022
A framework for building native applications using React

React Native Learn once, write anywhere: Build mobile apps with React. Getting Started 路 Learn the Basics 路 Showcase 路 Contribute 路 Community 路 Suppor

Meta 106.9k Jan 8, 2023
Wrapper for Kustomer SDK v2.0 for react native

This is a wrapper for Kustomer v2 Sdk for react native. This implements the kust

Shivam Rawat 2 Dec 30, 2021
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Bart艂omiej Klocek 60 Dec 29, 2022