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
72 lines (64 loc) • 1.85 kB
JavaScript
import ReactNative, { NativeModules, LayoutAnimation } from 'react-native';
const CustomInputControllerTemp = NativeModules.CustomInputControllerTemp;
export default class TextInputKeyboardManager {
static setInputComponent = (textInputRef, {
component,
initialProps,
useSafeArea
}) => {
if (!textInputRef || !CustomInputControllerTemp) {
return;
}
const reactTag = findNodeHandle(textInputRef);
if (reactTag) {
CustomInputControllerTemp.presentCustomInputComponent(reactTag, {
component,
initialProps,
useSafeArea
});
}
};
static removeInputComponent = textInputRef => {
if (!textInputRef || !CustomInputControllerTemp) {
return;
}
const reactTag = findNodeHandle(textInputRef);
if (reactTag) {
CustomInputControllerTemp.resetInput(reactTag);
}
};
static dismissKeyboard = () => {
CustomInputControllerTemp.dismissKeyboard();
};
static toggleExpandKeyboard = (textInputRef, expand, performLayoutAnimation = false) => {
if (textInputRef) {
if (performLayoutAnimation) {
LayoutAnimation.configureNext(springAnimation);
}
const reactTag = findNodeHandle(textInputRef);
if (expand) {
CustomInputControllerTemp.expandFullScreenForInput(reactTag);
} else {
CustomInputControllerTemp.resetSizeForInput(reactTag);
}
}
};
}
function findNodeHandle(ref) {
return ReactNative.findNodeHandle(ref.current || ref);
}
const springAnimation = {
duration: 400,
create: {
type: LayoutAnimation.Types.linear,
property: LayoutAnimation.Properties.opacity
},
update: {
type: LayoutAnimation.Types.spring,
springDamping: 1.0
},
delete: {
type: LayoutAnimation.Types.linear,
property: LayoutAnimation.Properties.opacity
}
};