UNPKG

react-native-ui-lib

Version:

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://stand-with-ukraine.pp.ua)

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} /> ); } }