2017-08-09 13:12:00 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-11-07 16:28:02 +00:00
|
|
|
import { ViewPropTypes } from 'react-native';
|
|
|
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
2018-01-16 18:48:05 +00:00
|
|
|
import scrollPersistTaps from '../utils/scrollPersistTaps';
|
2017-08-09 13:12:00 +00:00
|
|
|
|
|
|
|
export default class KeyboardView extends React.PureComponent {
|
|
|
|
static propTypes = {
|
2017-11-07 16:28:02 +00:00
|
|
|
style: ViewPropTypes.style,
|
|
|
|
contentContainerStyle: ViewPropTypes.style,
|
2017-08-09 13:12:00 +00:00
|
|
|
keyboardVerticalOffset: PropTypes.number,
|
2017-11-07 16:28:02 +00:00
|
|
|
scrollEnabled: PropTypes.bool,
|
2017-08-09 16:19:17 +00:00
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
|
|
|
PropTypes.node
|
2018-02-08 14:08:50 +00:00
|
|
|
])
|
2017-08-09 13:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-09-25 19:28:42 +00:00
|
|
|
const {
|
|
|
|
style, contentContainerStyle, scrollEnabled, keyboardVerticalOffset, children
|
|
|
|
} = this.props;
|
|
|
|
|
2017-08-09 13:12:00 +00:00
|
|
|
return (
|
2017-11-07 16:28:02 +00:00
|
|
|
<KeyboardAwareScrollView
|
2018-01-16 18:48:05 +00:00
|
|
|
{...scrollPersistTaps}
|
2018-09-25 19:28:42 +00:00
|
|
|
style={style}
|
|
|
|
contentContainerStyle={contentContainerStyle}
|
|
|
|
scrollEnabled={scrollEnabled}
|
2017-11-07 16:28:02 +00:00
|
|
|
alwaysBounceVertical={false}
|
2018-09-25 19:28:42 +00:00
|
|
|
extraHeight={keyboardVerticalOffset}
|
2017-11-07 16:28:02 +00:00
|
|
|
behavior='position'
|
|
|
|
>
|
2018-09-25 19:28:42 +00:00
|
|
|
{children}
|
2017-11-07 16:28:02 +00:00
|
|
|
</KeyboardAwareScrollView>
|
2017-08-09 13:12:00 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|