react-native-keyboard-controller 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +0 -40
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +8 -4
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +44 -8
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManagerImpl.kt +6 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +2 -6
- package/ios/.swiftlint.yml +4 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +2 -2
- package/ios/KeyboardControllerModule.mm +1 -1
- package/ios/KeyboardControllerView.mm +28 -10
- package/ios/KeyboardControllerViewManager.mm +2 -0
- package/ios/KeyboardControllerViewManager.swift +4 -1
- package/ios/KeyboardMoveEvent.h +1 -0
- package/ios/KeyboardMoveEvent.m +2 -1
- package/ios/KeyboardMovementObserver.swift +89 -4
- package/lib/commonjs/animated.js +44 -63
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/context.js +29 -0
- package/lib/commonjs/context.js.map +1 -0
- package/lib/commonjs/hooks.js +64 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +91 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +3 -3
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/native.js +24 -21
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/replicas.js +2 -2
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/{KeyboardControllerViewNativeComponent.js → specs/KeyboardControllerViewNativeComponent.js} +0 -0
- package/lib/commonjs/{KeyboardControllerViewNativeComponent.js.map → specs/KeyboardControllerViewNativeComponent.js.map} +1 -1
- package/lib/commonjs/{NativeKeyboardController.js → specs/NativeKeyboardController.js} +0 -0
- package/lib/commonjs/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map} +0 -0
- package/lib/commonjs/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js} +0 -0
- package/lib/commonjs/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map} +0 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +11 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/animated.js +43 -55
- package/lib/module/animated.js.map +1 -1
- package/lib/module/context.js +19 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/hooks.js +39 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +80 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/monkey-patch.js +4 -3
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/native.js +23 -17
- package/lib/module/native.js.map +1 -1
- package/lib/module/replicas.js +1 -1
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/{KeyboardControllerViewNativeComponent.js → specs/KeyboardControllerViewNativeComponent.js} +0 -0
- package/lib/module/{KeyboardControllerViewNativeComponent.js.map → specs/KeyboardControllerViewNativeComponent.js.map} +1 -1
- package/lib/module/{NativeKeyboardController.js → specs/NativeKeyboardController.js} +0 -0
- package/lib/module/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map} +0 -0
- package/lib/module/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js} +0 -0
- package/lib/module/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map} +0 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +2 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/animated.d.ts +1 -17
- package/lib/typescript/context.d.ts +18 -0
- package/lib/typescript/hooks.d.ts +8 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/internal.d.ts +21 -0
- package/lib/typescript/native.d.ts +14 -26
- package/lib/typescript/{KeyboardControllerViewNativeComponent.d.ts → specs/KeyboardControllerViewNativeComponent.d.ts} +2 -0
- package/lib/typescript/{NativeKeyboardController.d.ts → specs/NativeKeyboardController.d.ts} +0 -0
- package/lib/typescript/{NativeStatusBarManagerCompat.d.ts → specs/NativeStatusBarManagerCompat.d.ts} +0 -0
- package/lib/typescript/types.d.ts +32 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/package.json +17 -20
- package/react-native-keyboard-controller.podspec +2 -1
- package/src/animated.tsx +42 -78
- package/src/context.ts +31 -0
- package/src/hooks.ts +56 -0
- package/src/index.ts +3 -0
- package/src/internal.ts +87 -0
- package/src/{monkey-patch.tsx → monkey-patch.ts} +3 -6
- package/src/native.ts +37 -66
- package/src/replicas.ts +1 -1
- package/src/{KeyboardControllerViewNativeComponent.ts → specs/KeyboardControllerViewNativeComponent.ts} +4 -0
- package/src/{NativeKeyboardController.ts → specs/NativeKeyboardController.ts} +0 -0
- package/src/{NativeStatusBarManagerCompat.ts → specs/NativeStatusBarManagerCompat.ts} +0 -0
- package/src/types.ts +60 -0
- package/src/utils.ts +1 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerComponentsRegistry.kt +0 -31
- package/android/src/main/jni/Android.mk +0 -42
- package/android/src/main/jni/KeyboardControllerComponentsRegistry.cpp +0 -71
- package/android/src/main/jni/KeyboardControllerComponentsRegistry.h +0 -35
- package/android/src/main/jni/OnLoad.cpp +0 -9
- package/lib/commonjs/architecture.js +0 -13
- package/lib/commonjs/architecture.js.map +0 -1
- package/lib/module/architecture.js +0 -5
- package/lib/module/architecture.js.map +0 -1
- package/lib/typescript/architecture.d.ts +0 -2
- package/src/architecture.ts +0 -4
package/lib/module/animated.js
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { Animated, StyleSheet } from 'react-native';
|
|
3
|
-
import Reanimated, {
|
|
4
|
-
import {
|
|
1
|
+
import React, { useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated, Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import Reanimated, { useSharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { KeyboardContext } from './context';
|
|
5
|
+
import { useAnimatedKeyboardHandler, useSharedHandlers } from './internal';
|
|
6
|
+
import { KeyboardControllerView } from './native';
|
|
5
7
|
const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(Animated.createAnimatedComponent(KeyboardControllerView));
|
|
6
|
-
const defaultContext = {
|
|
7
|
-
animated: {
|
|
8
|
-
progress: new Animated.Value(0),
|
|
9
|
-
height: new Animated.Value(0)
|
|
10
|
-
},
|
|
11
|
-
reanimated: {
|
|
12
|
-
progress: {
|
|
13
|
-
value: 0
|
|
14
|
-
},
|
|
15
|
-
height: {
|
|
16
|
-
value: 0
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
export const KeyboardContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
21
|
-
export const useKeyboardAnimation = () => {
|
|
22
|
-
useResizeMode();
|
|
23
|
-
const context = useContext(KeyboardContext);
|
|
24
|
-
return context.animated;
|
|
25
|
-
};
|
|
26
|
-
export const useReanimatedKeyboardAnimation = () => {
|
|
27
|
-
useResizeMode();
|
|
28
|
-
const context = useContext(KeyboardContext);
|
|
29
|
-
return context.reanimated;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
33
|
-
const {
|
|
34
|
-
context,
|
|
35
|
-
doDependenciesDiffer
|
|
36
|
-
} = useHandler(handlers, dependencies);
|
|
37
|
-
return useEvent(event => {
|
|
38
|
-
'worklet';
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
onKeyboardMove
|
|
42
|
-
} = handlers;
|
|
43
|
-
|
|
44
|
-
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
45
|
-
onKeyboardMove(event, context);
|
|
46
|
-
}
|
|
47
|
-
}, ['onKeyboardMove'], doDependenciesDiffer);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
8
|
export const styles = StyleSheet.create({
|
|
51
9
|
container: {
|
|
52
10
|
flex: 1
|
|
@@ -61,19 +19,27 @@ export const KeyboardProvider = _ref => {
|
|
|
61
19
|
children,
|
|
62
20
|
statusBarTranslucent
|
|
63
21
|
} = _ref;
|
|
22
|
+
// animated values
|
|
64
23
|
const progress = useRef(new Animated.Value(0)).current;
|
|
65
|
-
const height = useRef(new Animated.Value(0)).current;
|
|
24
|
+
const height = useRef(new Animated.Value(0)).current; // shared values
|
|
25
|
+
|
|
66
26
|
const progressSV = useSharedValue(0);
|
|
67
27
|
const heightSV = useSharedValue(0);
|
|
28
|
+
const {
|
|
29
|
+
setHandlers,
|
|
30
|
+
broadcast
|
|
31
|
+
} = useSharedHandlers(); // memo
|
|
32
|
+
|
|
68
33
|
const context = useMemo(() => ({
|
|
69
34
|
animated: {
|
|
70
35
|
progress: progress,
|
|
71
|
-
height: height
|
|
36
|
+
height: Animated.multiply(height, -1)
|
|
72
37
|
},
|
|
73
38
|
reanimated: {
|
|
74
39
|
progress: progressSV,
|
|
75
40
|
height: heightSV
|
|
76
|
-
}
|
|
41
|
+
},
|
|
42
|
+
setHandlers
|
|
77
43
|
}), []);
|
|
78
44
|
const style = useMemo(() => [styles.hidden, {
|
|
79
45
|
transform: [{
|
|
@@ -89,20 +55,42 @@ export const KeyboardProvider = _ref => {
|
|
|
89
55
|
}
|
|
90
56
|
}], {
|
|
91
57
|
useNativeDriver: true
|
|
92
|
-
}), []);
|
|
58
|
+
}), []); // handlers
|
|
59
|
+
|
|
60
|
+
const updateSharedValues = (event, platforms) => {
|
|
61
|
+
'worklet';
|
|
62
|
+
|
|
63
|
+
if (platforms.includes(Platform.OS)) {
|
|
64
|
+
progressSV.value = event.progress;
|
|
65
|
+
heightSV.value = -event.height;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
93
69
|
const handler = useAnimatedKeyboardHandler({
|
|
70
|
+
onKeyboardMoveStart: event => {
|
|
71
|
+
'worklet';
|
|
72
|
+
|
|
73
|
+
broadcast('onStart', event);
|
|
74
|
+
updateSharedValues(event, ['ios']);
|
|
75
|
+
},
|
|
94
76
|
onKeyboardMove: event => {
|
|
95
77
|
'worklet';
|
|
96
78
|
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
broadcast('onMove', event);
|
|
80
|
+
updateSharedValues(event, ['android']);
|
|
81
|
+
},
|
|
82
|
+
onKeyboardMoveEnd: event => {
|
|
83
|
+
'worklet';
|
|
84
|
+
|
|
85
|
+
broadcast('onEnd', event);
|
|
99
86
|
}
|
|
100
87
|
}, []);
|
|
101
88
|
return /*#__PURE__*/React.createElement(KeyboardContext.Provider, {
|
|
102
89
|
value: context
|
|
103
90
|
}, /*#__PURE__*/React.createElement(KeyboardControllerViewAnimated, {
|
|
104
91
|
onKeyboardMoveReanimated: handler,
|
|
105
|
-
onKeyboardMove:
|
|
92
|
+
onKeyboardMoveStart: Platform.OS === 'ios' ? onKeyboardMove : undefined,
|
|
93
|
+
onKeyboardMove: Platform.OS === 'android' ? onKeyboardMove : undefined,
|
|
106
94
|
statusBarTranslucent: statusBarTranslucent,
|
|
107
95
|
style: styles.container
|
|
108
96
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Animated.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","useMemo","useRef","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardContext","useAnimatedKeyboardHandler","useSharedHandlers","KeyboardControllerView","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","progress","Value","current","height","progressSV","heightSV","setHandlers","broadcast","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","OS","value","handler","onKeyboardMoveStart","onKeyboardMoveEnd","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useAnimatedKeyboardHandler, useSharedHandlers } from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nexport const styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n}: KeyboardProviderProps) => {\n // animated values\n const progress = useRef(new Animated.Value(0)).current;\n const height = useRef(new Animated.Value(0)).current;\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onEnd', event);\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n <>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n {children}\n </>\n </KeyboardControllerViewAnimated>\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,MAAzB,QAAuC,OAAvC;AACA,SAASC,QAAT,EAAmBC,QAAnB,E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V,CAAT;IACD;EAjBH,CADwC,EAoBxC,EApBwC,CAA1C;EAuBA,oBACE,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAET;EAAjC,gBACE,oBAAC,8BAAD;IACE,wBAAwB,EAAEiB,OAD5B;IAEE,mBAAmB,EAAE7C,QAAQ,CAAC2C,EAAT,KAAgB,KAAhB,GAAwBP,cAAxB,GAAyCY,SAFhE;IAGE,cAAc,EAAEhD,QAAQ,CAAC2C,EAAT,KAAgB,SAAhB,GAA4BP,cAA5B,GAA6CY,SAH/D;IAIE,oBAAoB,EAAE7B,oBAJxB;IAKE,KAAK,EAAET,MAAM,CAACE;EALhB,gBAOE,uDACE,oBAAC,QAAD,CAAU,IAAV;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEoB;EATT,EADF,EAYGd,QAZH,CAPF,CADF,CADF;AA0BD,CApGM"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
const defaultContext = {
|
|
4
|
+
animated: {
|
|
5
|
+
progress: new Animated.Value(0),
|
|
6
|
+
height: new Animated.Value(0)
|
|
7
|
+
},
|
|
8
|
+
reanimated: {
|
|
9
|
+
progress: {
|
|
10
|
+
value: 0
|
|
11
|
+
},
|
|
12
|
+
height: {
|
|
13
|
+
value: 0
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setHandlers: () => {}
|
|
17
|
+
};
|
|
18
|
+
export const KeyboardContext = /*#__PURE__*/createContext(defaultContext);
|
|
19
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","Animated","defaultContext","animated","progress","Value","height","reanimated","value","setHandlers","KeyboardContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { KeyboardHandlers } from './types';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n setHandlers: (handlers: KeyboardHandlers) => void;\n};\nconst defaultContext: KeyboardAnimationContext = {\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: { value: 0 },\n height: { value: 0 },\n },\n setHandlers: () => {},\n};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAkBA,MAAMC,cAAwC,GAAG;EAC/CC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIH,QAAQ,CAACI,KAAb,CAAmB,CAAnB,CADF;IAERC,MAAM,EAAE,IAAIL,QAAQ,CAACI,KAAb,CAAmB,CAAnB;EAFA,CADqC;EAK/CE,UAAU,EAAE;IACVH,QAAQ,EAAE;MAAEI,KAAK,EAAE;IAAT,CADA;IAEVF,MAAM,EAAE;MAAEE,KAAK,EAAE;IAAT;EAFE,CALmC;EAS/CC,WAAW,EAAE,MAAM,CAAE;AAT0B,CAAjD;AAWA,OAAO,MAAMC,eAAe,gBAAGV,aAAa,CAACE,cAAD,CAArC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useContext, useEffect } from 'react';
|
|
2
|
+
import { KeyboardContext } from './context';
|
|
3
|
+
import { AndroidSoftInputModes, KeyboardController } from './native';
|
|
4
|
+
import { uuid } from './utils';
|
|
5
|
+
export const useResizeMode = () => {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
8
|
+
return () => KeyboardController.setDefaultMode();
|
|
9
|
+
}, []);
|
|
10
|
+
};
|
|
11
|
+
export const useKeyboardAnimation = () => {
|
|
12
|
+
useResizeMode();
|
|
13
|
+
const context = useContext(KeyboardContext);
|
|
14
|
+
return context.animated;
|
|
15
|
+
};
|
|
16
|
+
export const useReanimatedKeyboardAnimation = () => {
|
|
17
|
+
useResizeMode();
|
|
18
|
+
const context = useContext(KeyboardContext);
|
|
19
|
+
return context.reanimated;
|
|
20
|
+
};
|
|
21
|
+
export function useGenericKeyboardHandler(handler, deps) {
|
|
22
|
+
const context = useContext(KeyboardContext);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const key = uuid();
|
|
25
|
+
context.setHandlers({
|
|
26
|
+
[key]: handler
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
context.setHandlers({
|
|
30
|
+
[key]: undefined
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
}, deps);
|
|
34
|
+
}
|
|
35
|
+
export function useKeyboardHandler(handler, deps) {
|
|
36
|
+
useResizeMode();
|
|
37
|
+
useGenericKeyboardHandler(handler, deps);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","KeyboardContext","AndroidSoftInputModes","KeyboardController","uuid","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","key","setHandlers","undefined","useKeyboardHandler"],"sources":["hooks.ts"],"sourcesContent":["import { DependencyList, useContext, useEffect } from 'react';\n\nimport { AnimatedContext, KeyboardContext, ReanimatedContext } from './context';\nimport { AndroidSoftInputModes, KeyboardController } from './native';\nimport { uuid } from './utils';\n\nimport type { KeyboardHandler } from './types';\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useContext(KeyboardContext);\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n const context = useContext(KeyboardContext);\n\n useEffect(() => {\n const key = uuid();\n\n context.setHandlers({ [key]: handler });\n\n return () => {\n context.setHandlers({ [key]: undefined });\n };\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n"],"mappings":"AAAA,SAAyBA,UAAzB,EAAqCC,SAArC,QAAsD,OAAtD;AAEA,SAA0BC,eAA1B,QAAoE,WAApE;AACA,SAASC,qBAAT,EAAgCC,kBAAhC,QAA0D,UAA1D;AACA,SAASC,IAAT,QAAqB,SAArB;AAIA,OAAO,MAAMC,aAAa,GAAG,MAAM;EACjCL,SAAS,CAAC,MAAM;IACdG,kBAAkB,CAACG,YAAnB,CACEJ,qBAAqB,CAACK,wBADxB;IAIA,OAAO,MAAMJ,kBAAkB,CAACK,cAAnB,EAAb;EACD,CANQ,EAMN,EANM,CAAT;AAOD,CARM;AAUP,OAAO,MAAMC,oBAAoB,GAAG,MAAuB;EACzDJ,aAAa;EACb,MAAMK,OAAO,GAAGX,UAAU,CAACE,eAAD,CAA1B;EAEA,OAAOS,OAAO,CAACC,QAAf;AACD,CALM;AAOP,OAAO,MAAMC,8BAA8B,GAAG,MAAyB;EACrEP,aAAa;EACb,MAAMK,OAAO,GAAGX,UAAU,CAACE,eAAD,CAA1B;EAEA,OAAOS,OAAO,CAACG,UAAf;AACD,CALM;AAOP,OAAO,SAASC,yBAAT,CACLC,OADK,EAELC,IAFK,EAGL;EACA,MAAMN,OAAO,GAAGX,UAAU,CAACE,eAAD,CAA1B;EAEAD,SAAS,CAAC,MAAM;IACd,MAAMiB,GAAG,GAAGb,IAAI,EAAhB;IAEAM,OAAO,CAACQ,WAAR,CAAoB;MAAE,CAACD,GAAD,GAAOF;IAAT,CAApB;IAEA,OAAO,MAAM;MACXL,OAAO,CAACQ,WAAR,CAAoB;QAAE,CAACD,GAAD,GAAOE;MAAT,CAApB;IACD,CAFD;EAGD,CARQ,EAQNH,IARM,CAAT;AASD;AAED,OAAO,SAASI,kBAAT,CACLL,OADK,EAELC,IAFK,EAGL;EACAX,aAAa;EACbS,yBAAyB,CAACC,OAAD,EAAUC,IAAV,CAAzB;AACD"}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\n"],"mappings":"AAAA,OAAO,gBAAP;AAEA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,YAAd"}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './monkey-patch';\n\nexport * from './native';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './types';\n"],"mappings":"AAAA,OAAO,gBAAP;AAEA,cAAc,UAAd;AACA,cAAc,YAAd;AACA,cAAc,YAAd;AACA,cAAc,WAAd;AACA,cAAc,SAAd;AACA,cAAc,SAAd"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
import { useEvent, useHandler, useSharedValue } from 'react-native-reanimated';
|
|
3
|
+
export function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
4
|
+
const {
|
|
5
|
+
context,
|
|
6
|
+
doDependenciesDiffer
|
|
7
|
+
} = useHandler(handlers, dependencies);
|
|
8
|
+
return useEvent(event => {
|
|
9
|
+
'worklet';
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
onKeyboardMoveStart,
|
|
13
|
+
onKeyboardMove,
|
|
14
|
+
onKeyboardMoveEnd
|
|
15
|
+
} = handlers;
|
|
16
|
+
|
|
17
|
+
if (onKeyboardMoveStart && event.eventName.endsWith('onKeyboardMoveStart')) {
|
|
18
|
+
onKeyboardMoveStart(event, context);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
22
|
+
onKeyboardMove(event, context);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {
|
|
26
|
+
onKeyboardMoveEnd(event, context);
|
|
27
|
+
}
|
|
28
|
+
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd'], doDependenciesDiffer);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Hook for storing worklet handlers (objects with keys, where values are worklets).
|
|
32
|
+
* Returns methods for setting handlers and broadcasting events in them.
|
|
33
|
+
*
|
|
34
|
+
* T is a generic that looks like:
|
|
35
|
+
* @example
|
|
36
|
+
* {
|
|
37
|
+
* onEvent: () => {},
|
|
38
|
+
* onEvent2: () => {},
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
export function useSharedHandlers() {
|
|
43
|
+
const handlers = useSharedValue({});
|
|
44
|
+
const jsHandlers = useRef({}); // since js -> worklet -> js call is asynchronous, we can not write handlers
|
|
45
|
+
// straight into shared variable (using current shared value as a previous result),
|
|
46
|
+
// since there may be a race condition in a call, and closure may have out-of-dated
|
|
47
|
+
// values. As a result, some of handlers may be not written to "all handlers" object.
|
|
48
|
+
// Below we are writing all handlers to `ref` and afterwards synchronize them with
|
|
49
|
+
// shared value (since `refs` are not referring to actual value in worklets).
|
|
50
|
+
// This approach allow us to update synchronously handlers in js thread (and it assures,
|
|
51
|
+
// that it will have all of them) and then update them in worklet thread (calls are
|
|
52
|
+
// happening in FIFO order, so we will always have actual value).
|
|
53
|
+
|
|
54
|
+
const updateSharedHandlers = () => {
|
|
55
|
+
handlers.value = jsHandlers.current;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const setHandlers = useCallback(handler => {
|
|
59
|
+
jsHandlers.current = { ...jsHandlers.current,
|
|
60
|
+
...handler
|
|
61
|
+
};
|
|
62
|
+
updateSharedHandlers();
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const broadcast = (type, event) => {
|
|
66
|
+
'worklet';
|
|
67
|
+
|
|
68
|
+
Object.keys(handlers.value).forEach(key => {
|
|
69
|
+
var _handlers$value$key, _handlers$value$key$t;
|
|
70
|
+
|
|
71
|
+
return (_handlers$value$key = handlers.value[key]) === null || _handlers$value$key === void 0 ? void 0 : (_handlers$value$key$t = _handlers$value$key[type]) === null || _handlers$value$key$t === void 0 ? void 0 : _handlers$value$key$t.call(_handlers$value$key, event);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
setHandlers,
|
|
77
|
+
broadcast
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useEvent","useHandler","useSharedValue","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMoveStart","onKeyboardMove","onKeyboardMoveEnd","eventName","endsWith","useSharedHandlers","jsHandlers","updateSharedHandlers","value","current","setHandlers","handler","broadcast","type","Object","keys","forEach","key"],"sources":["internal.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\nimport { useEvent, useHandler, useSharedValue } from 'react-native-reanimated';\n\nimport type { EventWithName, Handlers, NativeEvent } from './types';\n\nexport function useAnimatedKeyboardHandler<\n TContext extends Record<string, unknown>\n>(\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: ReadonlyArray<unknown>\n) {\n const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n\n return useEvent(\n (event: EventWithName<NativeEvent>) => {\n 'worklet';\n const { onKeyboardMoveStart, onKeyboardMove, onKeyboardMoveEnd } =\n handlers;\n\n if (\n onKeyboardMoveStart &&\n event.eventName.endsWith('onKeyboardMoveStart')\n ) {\n onKeyboardMoveStart(event, context);\n }\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n\n if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {\n onKeyboardMoveEnd(event, context);\n }\n },\n ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd'],\n doDependenciesDiffer\n );\n}\n\n/**\n * Hook for storing worklet handlers (objects with keys, where values are worklets).\n * Returns methods for setting handlers and broadcasting events in them.\n *\n * T is a generic that looks like:\n * @example\n * {\n * onEvent: () => {},\n * onEvent2: () => {},\n * }\n */\nexport function useSharedHandlers<T extends Record<string, Function>>() {\n const handlers = useSharedValue<Handlers<T>>({});\n const jsHandlers = useRef<Handlers<T>>({});\n\n // since js -> worklet -> js call is asynchronous, we can not write handlers\n // straight into shared variable (using current shared value as a previous result),\n // since there may be a race condition in a call, and closure may have out-of-dated\n // values. As a result, some of handlers may be not written to \"all handlers\" object.\n // Below we are writing all handlers to `ref` and afterwards synchronize them with\n // shared value (since `refs` are not referring to actual value in worklets).\n // This approach allow us to update synchronously handlers in js thread (and it assures,\n // that it will have all of them) and then update them in worklet thread (calls are\n // happening in FIFO order, so we will always have actual value).\n const updateSharedHandlers = () => {\n handlers.value = jsHandlers.current;\n };\n const setHandlers = useCallback((handler: Handlers<T>) => {\n jsHandlers.current = {\n ...jsHandlers.current,\n ...handler,\n };\n updateSharedHandlers();\n }, []);\n const broadcast = (type: keyof T, event: NativeEvent) => {\n 'worklet';\n\n Object.keys(handlers.value).forEach((key) =>\n handlers.value[key]?.[type]?.(event)\n );\n };\n\n return { setHandlers, broadcast };\n}\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,OAApC;AACA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,cAA/B,QAAqD,yBAArD;AAIA,OAAO,SAASC,0BAAT,CAGLC,QAHK,EAQLC,YARK,EASL;EACA,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoCN,UAAU,CAACG,QAAD,EAAWC,YAAX,CAApD;EAEA,OAAOL,QAAQ,CACZQ,KAAD,IAAuC;IACrC;;IACA,MAAM;MAAEC,mBAAF;MAAuBC,cAAvB;MAAuCC;IAAvC,IACJP,QADF;;IAGA,IACEK,mBAAmB,IACnBD,KAAK,CAACI,SAAN,CAAgBC,QAAhB,CAAyB,qBAAzB,CAFF,EAGE;MACAJ,mBAAmB,CAACD,KAAD,EAAQF,OAAR,CAAnB;IACD;;IAED,IAAII,cAAc,IAAIF,KAAK,CAACI,SAAN,CAAgBC,QAAhB,CAAyB,gBAAzB,CAAtB,EAAkE;MAChEH,cAAc,CAACF,KAAD,EAAQF,OAAR,CAAd;IACD;;IAED,IAAIK,iBAAiB,IAAIH,KAAK,CAACI,SAAN,CAAgBC,QAAhB,CAAyB,mBAAzB,CAAzB,EAAwE;MACtEF,iBAAiB,CAACH,KAAD,EAAQF,OAAR,CAAjB;IACD;EACF,CApBY,EAqBb,CAAC,qBAAD,EAAwB,gBAAxB,EAA0C,mBAA1C,CArBa,EAsBbC,oBAtBa,CAAf;AAwBD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,iBAAT,GAAiE;EACtE,MAAMV,QAAQ,GAAGF,cAAc,CAAc,EAAd,CAA/B;EACA,MAAMa,UAAU,GAAGhB,MAAM,CAAc,EAAd,CAAzB,CAFsE,CAItE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EACA,MAAMiB,oBAAoB,GAAG,MAAM;IACjCZ,QAAQ,CAACa,KAAT,GAAiBF,UAAU,CAACG,OAA5B;EACD,CAFD;;EAGA,MAAMC,WAAW,GAAGrB,WAAW,CAAEsB,OAAD,IAA0B;IACxDL,UAAU,CAACG,OAAX,GAAqB,EACnB,GAAGH,UAAU,CAACG,OADK;MAEnB,GAAGE;IAFgB,CAArB;IAIAJ,oBAAoB;EACrB,CAN8B,EAM5B,EAN4B,CAA/B;;EAOA,MAAMK,SAAS,GAAG,CAACC,IAAD,EAAgBd,KAAhB,KAAuC;IACvD;;IAEAe,MAAM,CAACC,IAAP,CAAYpB,QAAQ,CAACa,KAArB,EAA4BQ,OAA5B,CAAqCC,GAAD;MAAA;;MAAA,8BAClCtB,QAAQ,CAACa,KAAT,CAAeS,GAAf,CADkC,iFAClC,oBAAsBJ,IAAtB,CADkC,0DAClC,gDAA8Bd,KAA9B,CADkC;IAAA,CAApC;EAGD,CAND;;EAQA,OAAO;IAAEW,WAAF;IAAeE;EAAf,CAAP;AACD"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform } from 'react-native'; // @ts-expect-error because there is no corresponding type definition
|
|
2
2
|
|
|
3
3
|
import * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';
|
|
4
|
-
import { isTurboModuleEnabled } from './architecture';
|
|
5
4
|
const getConstants = NativeAndroidManager.default.getConstants;
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
7
7
|
// in order to use library on all available platforms we have to monkey patch
|
|
8
8
|
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
if (Platform.OS === 'android') {
|
|
11
12
|
NativeAndroidManager.default = {
|
|
12
13
|
getConstants,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Platform","NativeAndroidManager","getConstants","default","RCTStatusBarManagerCompat","require","OS","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden"],"sources":["monkey-patch.ts"],"sourcesContent":["import { Platform } from 'react-native';\n// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from 'react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid';\n\nconst getConstants = NativeAndroidManager.default.getConstants;\n\nconst RCTStatusBarManagerCompat =\n require('./specs/NativeStatusBarManagerCompat').default;\n\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nif (Platform.OS === 'android') {\n NativeAndroidManager.default = {\n getConstants,\n setColor(color: number, animated: boolean): void {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n\n setTranslucent(translucent: boolean): void {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle(statusBarStyle?: string): void {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n\n setHidden(hidden: boolean): void {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n };\n}\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB,C,CACA;;AACA,OAAO,KAAKC,oBAAZ,MAAsC,2EAAtC;AAEA,MAAMC,YAAY,GAAGD,oBAAoB,CAACE,OAArB,CAA6BD,YAAlD;;AAEA,MAAME,yBAAyB,GAC7BC,OAAO,CAAC,sCAAD,CAAP,CAAgDF,OADlD,C,CAGA;AACA;AACA;;;AACA,IAAIH,QAAQ,CAACM,EAAT,KAAgB,SAApB,EAA+B;EAC7BL,oBAAoB,CAACE,OAArB,GAA+B;IAC7BD,YAD6B;;IAE7BK,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CL,yBAAyB,CAACG,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCP,yBAAyB,CAACM,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCT,yBAAyB,CAACQ,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BX,yBAAyB,CAACU,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
|
package/lib/module/native.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requireNativeComponent, UIManager, Platform, NativeModules, NativeEventEmitter } from 'react-native';
|
|
3
|
-
import { isFabricEnabled, isTurboModuleEnabled } from './architecture';
|
|
1
|
+
import { Platform, NativeEventEmitter } from 'react-native';
|
|
4
2
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
3
|
ios: "- You have run 'pod install'\n",
|
|
6
4
|
default: ''
|
|
7
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo
|
|
5
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; // copied from `android.view.WindowManager.LayoutParams`
|
|
6
|
+
|
|
8
7
|
export let AndroidSoftInputModes;
|
|
9
8
|
|
|
10
9
|
(function (AndroidSoftInputModes) {
|
|
@@ -12,22 +11,29 @@ export let AndroidSoftInputModes;
|
|
|
12
11
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
|
|
13
12
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_RESIZE"] = 16] = "SOFT_INPUT_ADJUST_RESIZE";
|
|
14
13
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_UNSPECIFIED"] = 0] = "SOFT_INPUT_ADJUST_UNSPECIFIED";
|
|
14
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_IS_FORWARD_NAVIGATION"] = 256] = "SOFT_INPUT_IS_FORWARD_NAVIGATION";
|
|
15
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_ADJUST"] = 240] = "SOFT_INPUT_MASK_ADJUST";
|
|
16
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_STATE"] = 15] = "SOFT_INPUT_MASK_STATE";
|
|
17
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MODE_CHANGED"] = 512] = "SOFT_INPUT_MODE_CHANGED";
|
|
18
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_HIDDEN"] = 3] = "SOFT_INPUT_STATE_ALWAYS_HIDDEN";
|
|
19
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_VISIBLE"] = 5] = "SOFT_INPUT_STATE_ALWAYS_VISIBLE";
|
|
20
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_HIDDEN"] = 2] = "SOFT_INPUT_STATE_HIDDEN";
|
|
21
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNCHANGED"] = 1] = "SOFT_INPUT_STATE_UNCHANGED";
|
|
22
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
|
|
23
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
|
|
15
24
|
})(AndroidSoftInputModes || (AndroidSoftInputModes = {}));
|
|
16
25
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
export const KeyboardController = RCTKeyboardController
|
|
20
|
-
|
|
26
|
+
const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
|
|
27
|
+
|
|
28
|
+
export const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
29
|
+
get() {
|
|
30
|
+
throw new Error(LINKING_ERROR);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
});
|
|
34
|
+
const eventEmitter = new NativeEventEmitter(KeyboardController);
|
|
21
35
|
export const KeyboardEvents = {
|
|
22
36
|
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
23
37
|
};
|
|
24
|
-
export const KeyboardControllerView =
|
|
25
|
-
throw new Error(LINKING_ERROR);
|
|
26
|
-
};
|
|
27
|
-
export const useResizeMode = () => {
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
30
|
-
return () => KeyboardController.setDefaultMode();
|
|
31
|
-
}, []);
|
|
32
|
-
};
|
|
38
|
+
export const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
33
39
|
//# sourceMappingURL=native.js.map
|
package/lib/module/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","AndroidSoftInputModes","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView"],"sources":["native.ts"],"sourcesContent":["import { Platform, NativeEventEmitter } from 'react-native';\n\nimport type {\n KeyboardControllerEvents,\n KeyboardControllerModule,\n KeyboardEventData,\n} from './types';\n\nconst LINKING_ERROR =\n `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\n// copied from `android.view.WindowManager.LayoutParams`\nexport enum AndroidSoftInputModes {\n SOFT_INPUT_ADJUST_NOTHING = 48,\n SOFT_INPUT_ADJUST_PAN = 32,\n SOFT_INPUT_ADJUST_RESIZE = 16,\n SOFT_INPUT_ADJUST_UNSPECIFIED = 0,\n SOFT_INPUT_IS_FORWARD_NAVIGATION = 256,\n SOFT_INPUT_MASK_ADJUST = 240,\n SOFT_INPUT_MASK_STATE = 15,\n SOFT_INPUT_MODE_CHANGED = 512,\n SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3,\n SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5,\n SOFT_INPUT_STATE_HIDDEN = 2,\n SOFT_INPUT_STATE_UNCHANGED = 1,\n SOFT_INPUT_STATE_UNSPECIFIED = 0,\n SOFT_INPUT_STATE_VISIBLE = 4,\n}\n\nconst RCTKeyboardController =\n require('./specs/NativeKeyboardController').default;\nexport const KeyboardController = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n )\n) as KeyboardControllerModule;\n\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void\n ) => eventEmitter.addListener('KeyboardController::' + name, cb),\n};\nexport const KeyboardControllerView =\n require('./specs/KeyboardControllerViewNativeComponent').default;\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,kBAAnB,QAA6C,cAA7C;AAQA,MAAMC,aAAa,GAChB,2FAAD,GACAF,QAAQ,CAACG,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,+BAJF,C,CAMA;;AACA,WAAYC,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AAiBZ,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAD,CAAP,CAA4CH,OAD9C;;AAEA,OAAO,MAAMI,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBADiB,GAEjB,IAAIG,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAFF,CAHC;AAaP,MAAMW,YAAY,GAAG,IAAIZ,kBAAJ,CAAuBQ,kBAAvB,CAArB;AAEA,OAAO,MAAMK,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IADW,EAEXC,EAFW,KAGRJ,YAAY,CAACE,WAAb,CAAyB,yBAAyBC,IAAlD,EAAwDC,EAAxD;AAJuB,CAAvB;AAMP,OAAO,MAAMC,sBAAsB,GACjCV,OAAO,CAAC,+CAAD,CAAP,CAAyDH,OADpD"}
|
package/lib/module/replicas.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef, useEffect, useMemo } from 'react';
|
|
2
2
|
import { Animated, Easing, Keyboard, Platform } from 'react-native';
|
|
3
3
|
import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue, useWorkletCallback, withSpring } from 'react-native-reanimated';
|
|
4
|
-
import { useReanimatedKeyboardAnimation } from './
|
|
4
|
+
import { useReanimatedKeyboardAnimation } from './hooks';
|
|
5
5
|
import { AndroidSoftInputModes, KeyboardController } from './native';
|
|
6
6
|
const availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did'; // cubic-bezier(.17,.67,.34,.94)
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useEffect","useMemo","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","useReanimatedKeyboardAnimation","AndroidSoftInputModes","KeyboardController","availableOSEventType","OS","defaultAndroidEasing","bezier","useKeyboardAnimationReplica","height","Value","progress","animation","current","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","heightEvent","value","handler","_height","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","show","hide","useGradualKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './
|
|
1
|
+
{"version":3,"names":["useRef","useEffect","useMemo","Animated","Easing","Keyboard","Platform","runOnUI","useAnimatedReaction","useDerivedValue","useSharedValue","useWorkletCallback","withSpring","useReanimatedKeyboardAnimation","AndroidSoftInputModes","KeyboardController","availableOSEventType","OS","defaultAndroidEasing","bezier","useKeyboardAnimationReplica","height","Value","progress","animation","current","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","heightEvent","value","handler","_height","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","show","hide","useGradualKeyboardAnimation"],"sources":["replicas.ts"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react';\nimport { Animated, Easing, Keyboard, Platform } from 'react-native';\nimport {\n runOnUI,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n withSpring,\n} from 'react-native-reanimated';\nimport { useReanimatedKeyboardAnimation } from './hooks';\n\nimport { AndroidSoftInputModes, KeyboardController } from './native';\n\nconst availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';\n\n// cubic-bezier(.17,.67,.34,.94)\nexport const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);\ntype KeyboardAnimation = {\n progress: Animated.Value;\n height: Animated.Value;\n};\n\n/**\n * An experimental implementation of tracing keyboard appearance.\n * Switch an input mode to adjust resize mode. In this case all did* events\n * are triggering before keyboard appears, and using some approximations\n * it tries to mimicries a native transition.\n *\n * @returns {Animated.Value}\n */\nexport const useKeyboardAnimationReplica = (): KeyboardAnimation => {\n const height = useRef(new Animated.Value(0));\n const progress = useRef(new Animated.Value(0));\n const animation = useMemo(\n () => ({\n height: height.current,\n progress: progress.current,\n }),\n []\n );\n\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Show`,\n (e) => {\n Animated.timing(height.current, {\n toValue: -e.endCoordinates.height,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n useEffect(() => {\n const listener = Keyboard.addListener(\n `keyboard${availableOSEventType}Hide`,\n (e) => {\n Animated.timing(height.current, {\n toValue: 0,\n duration: e.duration !== 0 ? e.duration : 300,\n easing: Easing.bezier(0.4, 0.0, 0.2, 1),\n useNativeDriver: true,\n }).start();\n\n return () => listener.remove();\n }\n );\n }, []);\n\n return animation;\n};\n\nconst IOS_SPRING_CONFIG = {\n damping: 500,\n stiffness: 1000,\n mass: 3,\n overshootClamping: true,\n restDisplacementThreshold: 10,\n restSpeedThreshold: 10,\n};\n\n/**\n * A close replica to native iOS keyboard animation. The problem is that\n * iOS (unlike Android) can not fire events for each keyboard frame movement.\n * As a result we can not get gradual values (for example, for progress it always\n * will be 1 or 0). So if you want to rely on gradual values you will need to use\n * this replica.\n *\n * The transition is hardcoded and may vary from one to another OS versions. But it\n * seems like last time it has been changed in iOS 7. Since RN supports at least iOS\n * 11 it doesn't make sense to replicate iOS 7 behavior. If it changes in next OS\n * versions, then this implementation should be revisited and reflect necessary changes.\n *\n * @returns {height, progress} - animated values\n */\nexport const useReanimatedKeyboardAnimationReplica = () => {\n const height = useSharedValue(0);\n const heightEvent = useSharedValue(0);\n\n const progress = useDerivedValue(() => height.value / heightEvent.value);\n\n const handler = useWorkletCallback((_height: number) => {\n heightEvent.value = _height;\n }, []);\n\n useAnimatedReaction(\n () => ({\n _keyboardHeight: heightEvent.value,\n }),\n (result, _previousResult) => {\n const { _keyboardHeight } = result;\n const _previousKeyboardHeight = _previousResult?._keyboardHeight;\n\n if (_keyboardHeight !== _previousKeyboardHeight) {\n height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);\n }\n },\n []\n );\n\n useEffect(() => {\n const show = Keyboard.addListener('keyboardWillShow', (e) => {\n runOnUI(handler)(-e.endCoordinates.height);\n });\n const hide = Keyboard.addListener('keyboardWillHide', () => {\n runOnUI(handler)(0);\n });\n\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n return { height, progress };\n};\n\nexport const useGradualKeyboardAnimation =\n Platform.OS === 'ios'\n ? useReanimatedKeyboardAnimationReplica\n : useReanimatedKeyboardAnimation;\n"],"mappings":"AAAA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,QAA2C,OAA3C;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,QAA3B,EAAqCC,QAArC,QAAqD,cAArD;AACA,SACE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,CAxCM;AA0CP,OAAO,MAAMmC,2BAA2B,GACtCpD,QAAQ,CAACW,EAAT,KAAgB,KAAhB,GACI8B,qCADJ,GAEIlC,8BAHC"}
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\n// @ts-expect-error - no type definition\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Float,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Int32;\n progress: Float;\n}>;\n\nexport interface NativeProps extends ViewProps {\n statusBarTranslucent?: boolean;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"AACA;AAOA,OAAOA,sBAAP,MAAmC,yDAAnC;
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\n// @ts-expect-error - no type definition\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Float,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Int32;\n progress: Float;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n // callbacks\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"AACA;AAOA,OAAOA,sBAAP,MAAmC,yDAAnC;AAgBA,eAAeA,sBAAsB,CACnC,wBADmC,CAArC"}
|
|
File without changes
|
package/lib/module/{NativeKeyboardController.js.map → specs/NativeKeyboardController.js.map}
RENAMED
|
File without changes
|
package/lib/module/{NativeStatusBarManagerCompat.js → specs/NativeStatusBarManagerCompat.js}
RENAMED
|
File without changes
|
package/lib/module/{NativeStatusBarManagerCompat.js.map → specs/NativeStatusBarManagerCompat.js.map}
RENAMED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { NativeSyntheticEvent, ViewProps } from 'react-native';\n\n// DirectEventHandler events declaration\n\nexport type NativeEvent = {\n progress: number;\n height: number;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\n\nexport type KeyboardControllerProps = {\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n // fake prop used to activate reanimated bindings\n onKeyboardMoveReanimated: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>\n ) => void;\n statusBarTranslucent?: boolean;\n} & ViewProps;\n\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\n\nexport type KeyboardControllerEvents =\n | 'keyboardWillShow'\n | 'keyboardDidShow'\n | 'keyboardWillHide'\n | 'keyboardDidHide';\nexport type KeyboardEventData = {\n height: number;\n};\n\n// package types\n\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = {\n onStart?: (e: NativeEvent) => void;\n onMove?: (e: NativeEvent) => void;\n onEnd?: (e: NativeEvent) => void;\n};\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["uuid","Math","random","toString","slice"],"sources":["utils.ts"],"sourcesContent":["export const uuid = () => Math.random().toString(36).slice(-6);\n"],"mappings":"AAAA,OAAO,MAAMA,IAAI,GAAG,MAAMC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAC,CAAlC,CAAnB"}
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import Reanimated from 'react-native-reanimated';
|
|
4
|
-
declare type AnimatedContext = {
|
|
5
|
-
progress: Animated.Value;
|
|
6
|
-
height: Animated.Value;
|
|
7
|
-
};
|
|
8
|
-
declare type ReanimatedContext = {
|
|
9
|
-
progress: Reanimated.SharedValue<number>;
|
|
10
|
-
height: Reanimated.SharedValue<number>;
|
|
11
|
-
};
|
|
12
|
-
declare type KeyboardAnimationContext = {
|
|
13
|
-
animated: AnimatedContext;
|
|
14
|
-
reanimated: ReanimatedContext;
|
|
15
|
-
};
|
|
16
|
-
export declare const KeyboardContext: React.Context<KeyboardAnimationContext>;
|
|
17
|
-
export declare const useKeyboardAnimation: () => AnimatedContext;
|
|
18
|
-
export declare const useReanimatedKeyboardAnimation: () => ReanimatedContext;
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
19
3
|
declare type Styles = {
|
|
20
4
|
container: ViewStyle;
|
|
21
5
|
hidden: ViewStyle;
|