Skip to content

experiment322/rn-soft-input-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published