2 Star 0 Fork 0

mirrors_opencollective/react-native-keyboard-manager

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

React-Native Keyboard Manager

Licence MIT npm version npm downloads

Library to prevent issues of keyboard sliding up and cover inputs on React-Native iOS projects ⚛. Thanks to awesome IQKeyboardManager ❤️.

This is only for iOS, Android no needed. For Android just add android:windowSoftInputMode="adjustResize" to your activity.

Screenshots

Enabled Disabled
Credits: IQKeyboardManager

NOTES:

  • for RN 0.60.0 or later use react-native-keyboard-manager@latest
  • for RN 0.53.0 ... 0.59.10, use react-native-keyboard-manager@4.0.13-12
  • for RN 0.47.0 ... 0.52.2, use react-native-keyboard-manager@4.0.13-5
  • for RN 0.40.0 ... 0.46.4, use react-native-keyboard-manager@4.0.13-1

Install

yarn add react-native-keyboard-manager

Or

npm i -S react-native-keyboard-manager

Auto linking

If you are using React Native 0.60.+ go to the folder your-project/ios and run pod install, and you're done.

If not, use one of the following methods to link.

Link with react-native link:

  1. Link the native project

    react-native link react-native-keyboard-manager
    
  2. (Optional) If you want to use Next/Previous buttons, link the IQKeyboardManager resources to your Xcode project.

    1. Open your Xcode project

    2. Got to folder your-project/node_modules/react-native-keyboard-manager/ios/IQKeyboardManager/

    3. Drag and drop the Resources folder to your project root. (If you already have Resources group, drag and drop the IQKeyboardManager.bundle)


    4. In your index.js:

      if (Platform.OS === 'ios') {
          KeyboardManager.setToolbarPreviousNextButtonEnable(true);
      }
      

Link with cocoapods:

  1. Add this line to your Podfile

    pod 'ReactNativeKeyboardManager', :path => '../node_modules/react-native-keyboard-manager'
    
  2. run

    pod install
    

Use

It does not need any library setup to work, just install and go.

But, if you need some configuration, there are some options available. (with default values)

import { Platform } from 'react-native';
import KeyboardManager from 'react-native-keyboard-manager';

if (Platform.OS === 'ios') {
    KeyboardManager.setEnable(true);
    KeyboardManager.setEnableDebugging(false);
    KeyboardManager.setKeyboardDistanceFromTextField(10);
    KeyboardManager.setPreventShowingBottomBlankSpace(true);
    KeyboardManager.setEnableAutoToolbar(true);
    KeyboardManager.setToolbarDoneBarButtonItemText("Done");
    KeyboardManager.setToolbarManageBehaviour(0);
    KeyboardManager.setToolbarPreviousNextButtonEnable(false);
    KeyboardManager.setShouldToolbarUsesTextFieldTintColor(false);
    KeyboardManager.setShouldShowTextFieldPlaceholder(true); // deprecated, use setShouldShowToolbarPlaceholder
    KeyboardManager.setShouldShowToolbarPlaceholder(true);
    KeyboardManager.setOverrideKeyboardAppearance(false);
    KeyboardManager.setShouldResignOnTouchOutside(true);
    KeyboardManager.resignFirstResponder();
    KeyboardManager.isKeyboardShowing()
      .then((isShowing) => {
          // ...
      });
}

Enable Next/Previous buttons

If you want to use Next/Previous buttons, enable it.

If you linked using react-native link, make sure you linked the resource file.

if (Platform.OS === 'ios') {
    KeyboardManager.setToolbarPreviousNextButtonEnable(true);
}

And if you want to use Next/Previous buttons inside a Modal, you need to wrap the fields in a PreviousNextView.

class App extends Component {
  render() {
      return (
          <View {...} >
              // others views
              <Modal {...} >
                  // others views
                  <PreviousNextView style={...} >
                      // all TextInput
                  </PreviousNextView>
              </Modal>
          </View>
      );
  }
}

For more details, see the Sample Project and the official IQKeyboardManager documentation.

Contribute

New features, bug fixes and improvements are welcome! For questions and suggestions use the issues.

Become a Patron! Donate

Licence

The MIT License (MIT)

Copyright (c) 2017 Douglas Nassif Roma Junior

See the full licence file.

IQKeyboardManager License

The MIT License (MIT)

Copyright (c) 2013-16 Iftekhar Qurashi

See the full IQKeyboardManager licence file.

MIT License Copyright (c) 2017 Douglas Nassif Roma Junior Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Releases

No release

Contributors

All

Activities

can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_opencollective/react-native-keyboard-manager.git
git@gitee.com:mirrors_opencollective/react-native-keyboard-manager.git
mirrors_opencollective
react-native-keyboard-manager
react-native-keyboard-manager
master

Search