-
Notifications
You must be signed in to change notification settings - Fork 751
Expand file tree
/
Copy pathTextInputKeyboardManager.ios.ts
More file actions
64 lines (57 loc) · 1.91 KB
/
TextInputKeyboardManager.ios.ts
File metadata and controls
64 lines (57 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import ReactNative, {NativeModules, LayoutAnimation} from 'react-native';
const CustomInputControllerTemp = NativeModules.CustomInputControllerTemp;
export default class TextInputKeyboardManager {
static setInputComponent = (textInputRef: any,
{component, initialProps, useSafeArea}: {component?: string; initialProps: any; useSafeArea?: boolean}) => {
if (!textInputRef || !CustomInputControllerTemp) {
return;
}
const reactTag = findNodeHandle(textInputRef);
if (reactTag) {
CustomInputControllerTemp.presentCustomInputComponent(reactTag, {component, initialProps, useSafeArea});
}
};
static removeInputComponent = (textInputRef: any) => {
if (!textInputRef || !CustomInputControllerTemp) {
return;
}
const reactTag = findNodeHandle(textInputRef);
if (reactTag) {
CustomInputControllerTemp.resetInput(reactTag);
}
};
static dismissKeyboard = () => {
CustomInputControllerTemp.dismissKeyboard();
};
static toggleExpandKeyboard = (textInputRef: any, expand: boolean, 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: any) {
return ref.current?.getNodeHandle?.() || ref?.getNodeHandle?.() || 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
}
};