UNPKG

react-native-ui-lib

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/1780255/105469025-56759000-5ca0-11eb-993d-3568c1fd54f4.png" height="250px" style="display:block"/> </p> <p align="center">UI Toolset & Components Library for React Native</p> <p a

42 lines (37 loc) 1.26 kB
import React from 'react'; import PropTypes from 'prop-types'; import {ScrollView} from 'react-native'; import KeyboardAwareBase from './KeyboardAwareBase'; /** * @description: A wrapper component which handles the ScrollView insets properly when the keyboard is shown and hides the content, scrolling content above the keybaord. * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/KeyboardAwareScrollViewScreen.js */ export default class KeyboardAwareScrollView extends KeyboardAwareBase { static displayName = 'KeyboardAwareScrollView'; static PropTypes = { getTextInputRefs: PropTypes.func, onScroll: PropTypes.func }; static defaultProps = { ...KeyboardAwareBase.defaultProps, getTextInputRefs: () => { return []; } }; render() { return ( <ScrollView scrollEventThrottle={200} {...this.props} {...this.style} contentInset={{bottom: this.state.keyboardHeight}} ref={r => { this._keyboardAwareView = r; }} onLayout={this._onKeyboardAwareViewLayout} onScroll={this._onKeyboardAwareViewScroll} onContentSizeChange={this._updateKeyboardAwareViewContentSize} /> ); } }