All Projects → flyerhq → React Native Keyboard Accessory View

flyerhq / React Native Keyboard Accessory View

Licence: mit
Keyboard accessory (sticky) view for your React Native app. Supports interactive dismiss on iOS.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Native Keyboard Accessory View

React Hotkeys
React component to listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts.
Stars: ✭ 279 (+117.97%)
Mutual labels:  keyboard, react-component
React Key Handler
React component to handle keyboard events 🔑
Stars: ✭ 386 (+201.56%)
Mutual labels:  keyboard, react-component
Readline Sync
Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).
Stars: ✭ 601 (+369.53%)
Mutual labels:  keyboard, interactive
React Magnifier
🔍 React image zoom component
Stars: ✭ 116 (-9.37%)
Mutual labels:  react-component
React Router Active Component
Factory function for React components which are active for a particular React Router route
Stars: ✭ 116 (-9.37%)
Mutual labels:  react-component
React Structured Data
React Structured Data provides an easy way to add structured data to your React apps
Stars: ✭ 120 (-6.25%)
Mutual labels:  react-component
Browser Media Keys
Lets you control many web players using the media keys on your keyboard.
Stars: ✭ 125 (-2.34%)
Mutual labels:  keyboard
React Interactive
Better hover, active and focus states than CSS pseudo classes, and a callback when the interactive state changes
Stars: ✭ 115 (-10.16%)
Mutual labels:  interactive
Git Cheats
Git Cheats - Interactive Cheatsheet For Git Commands
Stars: ✭ 124 (-3.12%)
Mutual labels:  interactive
React Native Emoticons
react native emoticons(表情), including emoji😁
Stars: ✭ 119 (-7.03%)
Mutual labels:  keyboard
React Lazy
Universal lazy loader components using IntersectionObserver for React
Stars: ✭ 118 (-7.81%)
Mutual labels:  react-component
Apexcharts.js
📊 Interactive JavaScript Charts built on SVG
Stars: ✭ 10,991 (+8486.72%)
Mutual labels:  interactive
Ng Keyboard Shortcuts
Dead Simple Keyboard Shortcuts Management for Angular
Stars: ✭ 121 (-5.47%)
Mutual labels:  keyboard
React Auto Form
Simplifies getting user input from forms via onChange and onSubmit events, using DOM forms APIs
Stars: ✭ 116 (-9.37%)
Mutual labels:  react-component
React Ckeditor
CKEditor component for React with plugin and custom event listeners support
Stars: ✭ 124 (-3.12%)
Mutual labels:  react-component
Fixed Sticky
DEPRECATED: A position: sticky polyfill that works with filamentgroup/fixed-fixed for a safer position:fixed fallback.
Stars: ✭ 1,490 (+1064.06%)
Mutual labels:  sticky
React Native Fading Slides
➰ Simple looped fading slides carousel for React Native.
Stars: ✭ 123 (-3.91%)
Mutual labels:  react-component
React Audio Recorder
A React Component using the Web Audio API to record, save, and play audio.
Stars: ✭ 118 (-7.81%)
Mutual labels:  react-component
Sentaku
Utility to make sentaku (selection, 選択(sentaku)) window with shell command.
Stars: ✭ 117 (-8.59%)
Mutual labels:  interactive
Ergotravel
A Portable Ergonomic Split Keyboard inspired from the ErgoDox, Let's Split and Minidox
Stars: ✭ 120 (-6.25%)
Mutual labels:  keyboard

React Native Keyboard Accessory View

npm build Maintainability Test Coverage type-coverage

Keyboard accessory (sticky) view for your React Native app. Supports interactive dismiss on iOS, respects safe area and works in both portrait and landscape, on both iOS and Android.

keyboard-accessory-view

Getting Started

This library depends on react-native-safe-area-context. If you use React Navigation you probably already have it in your dependencies, so you're good to go. If not, please follow the instructions here to install it. Then run:

yarn add @flyerhq/react-native-keyboard-accessory-view

Usage

import { KeyboardAccessoryView } from '@flyerhq/react-native-keyboard-accessory-view'
import { GestureResponderHandlers } from 'react-native'
// ...
const renderScrollable = (panHandlers: GestureResponderHandlers) => (
  // Can be anything scrollable
  <ScrollView keyboardDismissMode='interactive' {...panHandlers} />
)
// ...
return (
  <KeyboardAccessoryView renderScrollable={renderScrollable}>
    // Your accessory view
  </KeyboardAccessoryView>
)

Handling wrong offsets

Sometimes when you use a tab bar or similar component, the accessory view does not work correctly. In order to fix this, you need to use a combination of next props: contentContainerStyle, contentOffsetKeyboardClosed, contentOffsetKeyboardOpened and spaceBetweenKeyboardAndAccessoryView.

First of all, you need to decide if you need this extra safe area margin at the bottom (as you can see the size of the accessory view is different when the keyboard is open and closed, that's because when it's closed, safe area bottom margin is added). If you have, for example, a tab bar, most likely you don't need this margin, because safe is area already occupied by the tab bar. To remove it pass this style: contentContainerStyle={{ marginBottom: 0 }}.

When the first step is done, you need to check if you have a space between the accessory view and the keyboard, when the latter is opened. If you do, pass the offset to the spaceBetweenKeyboardAndAccessoryView prop. Usually, it can be calculated based on a bottom safe area inset from react-native-safe-area-context and/or the height of the tab bar, for example.

Lastly, validate if the content above the accessory view has correct offsets, if no, you can adjust it using contentOffsetKeyboardClosed and contentOffsetKeyboardOpened props. Sometimes offsets are correct for the one keyboard state, use one of these props if this is the case. As with the spaceBetweenKeyboardAndAccessoryView prop, offsets are calculated based on the bottom safe area inset and/or the height of the tab bar, for example.

Props

KeyboardAccessoryView

  • renderScrollable (required) - accepts a ReactNode. Your scrollable component.

  • style (optional) - accepts View Style Props. Use to style the view which includes both content container and safe area insets. A common use case will be setting backgroundColor so the content container and safe area insets are of the matching color.

  • contentContainerStyle (optional) - accepts View Style Props. Use to style the content container, but not the safe area insets.

  • contentOffsetKeyboardClosed (optional) - accepts a number. Use to adjust content offset when the keyboard is open. Read more here.

  • contentOffsetKeyboardOpened (optional) - accepts a number. Use to adjust content offset when the keyboard is closed. Read more here.

  • renderBackground (optional) - accepts a function returning React node. This is useful when you want to have a custom node as a background (e.g. <ImageBackground style={StyleSheet.absoluteFill} /> ). Remember about absolute positioning.

  • spaceBetweenKeyboardAndAccessoryView (optional) - accepts a number. Use to adjust space between the accessory view and the keyboard, when the latter is open. Read more here.

  • useListenersOnAndroid (optional) - accepts a boolean. By default, Android OS will resize the window when the keyboard is open and accessory view will automatically be positioned above the keyboard. This behavior can be amended, so if for some reason accessory view doesn't appear on top of the keyboard, try setting this prop, it will calculate the content height based on a keyboard listener. Has no impact on iOS.

License

MIT

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].