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
73 lines (62 loc) • 1.96 kB
JavaScript
import TextInputKeyboardManager from "./../TextInputKeyboardManager/TextInputKeyboardManager.ios";
import KeyboardRegistry from "./../KeyboardRegistry";
import CustomKeyboardViewBase from "./../CustomKeyboardViewBase";
export default class CustomKeyboardView extends CustomKeyboardViewBase {
static displayName = 'IGNORE';
static defaultProps = {
initialProps: {},
useSafeArea: true
};
constructor(props) {
super(props);
const {
component
} = props;
if (component) {
this.registeredRequestShowKeyboard = false;
}
KeyboardRegistry.addListener('onToggleExpandedKeyboard', args => {
const {
inputRef,
initialProps
} = this.props;
if (inputRef) {
if (this.keyboardExpandedToggle[args.keyboardId] === undefined) {
this.keyboardExpandedToggle[args.keyboardId] = false;
}
this.keyboardExpandedToggle[args.keyboardId] = !this.keyboardExpandedToggle[args.keyboardId];
TextInputKeyboardManager.toggleExpandKeyboard(inputRef, this.keyboardExpandedToggle[args.keyboardId], initialProps.expandWithLayoutAnimation);
}
});
}
componentWillUnmount() {
KeyboardRegistry.removeListeners('onToggleExpandedKeyboard');
super.componentWillUnmount();
}
componentDidUpdate(prevProps) {
const {
inputRef: nextInputRef,
component: nextComponent,
initialProps: nextInitialProps,
useSafeArea
} = this.props;
const {
component
} = prevProps;
if (nextInputRef && nextComponent !== component) {
if (nextComponent) {
TextInputKeyboardManager.setInputComponent(nextInputRef, {
component: nextComponent,
initialProps: nextInitialProps,
useSafeArea
});
} else {
TextInputKeyboardManager.removeInputComponent(nextInputRef);
}
}
super.componentDidUpdate(prevProps);
}
render() {
return null;
}
}