rn-soft-input-mode

1.0.0 • Public • Published

rn-soft-input-mode

A react-native module which exposes a simple API to change the soft input mode on Android at runtime. Check:

Note: this modules does nothing on iOS and simply returns 0 to absolve the user from doing tedious platform checks.

Getting started

$ npm install rn-soft-input-mode --save

Linking

Note: linking is required only for react-native < 0.60.0.

$ react-native link rn-soft-input-mode

Usage

import RNSoftInputMode from 'rn-soft-input-mode';

// All possible soft input modes
const { LAYOUT_PARAMS } = RNSoftInputMode;

// Get the current soft input mode
RNSoftInputMode.getSoftInputMode()
    .then(currentSoftInputMode => console.log(currentSoftInputMode))
    // Possible values: https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#softInputMode
    // Does nothing on iOS; returns 0
    .catch(reason => console.error(reason));
    // Possible reason: Current activity is null.

// Set the current soft input mode and return the old one
RNSoftInputMode.setSoftInputMode(LAYOUT_PARAMS.SOFT_INPUT_STATE_HIDDEN | LAYOUT_PARAMS.SOFT_INPUT_ADJUST_RESIZE)
    .then(oldSoftInputMode => console.log(oldSoftInputMode))
    // Possible values: https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#softInputMode
    // Does nothing on iOS; returns 0
    .catch(reason => console.error(reason));
    // Possible reason: Current activity is null.

/rn-soft-input-mode/

    Package Sidebar

    Install

    npm i rn-soft-input-mode

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    75.1 kB

    Total Files

    14

    Last publish

    Collaborators

    • experiment322