react-native-keyboard-controller 1.1.0 → 1.3.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 +32 -3
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +25 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +32 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +25 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +6 -6
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerModule.kt → KeyboardControllerModuleImpl.kt} +5 -17
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +45 -4
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardControllerViewManager.kt → KeyboardControllerViewManagerImpl.kt} +8 -9
- package/android/src/main/java/com/reactnativekeyboardcontroller/{StatusBarManagerCompatModule.kt → StatusBarManagerCompatImpl.kt} +10 -14
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +31 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +26 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +34 -0
- package/ios/.clang-format +1 -1
- package/ios/KeyboardController.xcodeproj/project.pbxproj +20 -16
- package/ios/KeyboardControllerModule-Header.h +6 -2
- package/ios/KeyboardControllerModule.mm +105 -0
- package/ios/KeyboardControllerView.h +23 -0
- package/ios/KeyboardControllerView.mm +81 -0
- package/ios/{KeyboardControllerViewManager.m → KeyboardControllerViewManager.mm} +0 -0
- package/ios/KeyboardControllerViewManager.swift +2 -2
- package/ios/KeyboardMoveEvent.h +18 -0
- package/ios/KeyboardMoveEvent.m +74 -0
- package/lib/commonjs/animated.js +14 -59
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/context.js +28 -0
- package/lib/commonjs/context.js.map +1 -0
- package/lib/commonjs/hooks.js +39 -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 +27 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +3 -1
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/native.js +24 -19
- 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/specs/KeyboardControllerViewNativeComponent.js +16 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js +13 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +13 -0
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/animated.js +12 -50
- package/lib/module/animated.js.map +1 -1
- package/lib/module/context.js +18 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/hooks.js +20 -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 +19 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/monkey-patch.js +4 -2
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/native.js +23 -16
- 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/specs/KeyboardControllerViewNativeComponent.js +4 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js +3 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -0
- package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/animated.d.ts +1 -17
- package/lib/typescript/context.d.ts +16 -0
- package/lib/typescript/hooks.d.ts +4 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/internal.d.ts +4 -0
- package/lib/typescript/native.d.ts +15 -27
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +13 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +10 -0
- package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
- package/lib/typescript/types.d.ts +23 -0
- package/package.json +20 -8
- package/react-native-keyboard-controller.podspec +21 -1
- package/src/animated.tsx +12 -75
- package/src/context.ts +28 -0
- package/src/hooks.ts +28 -0
- package/src/index.ts +3 -0
- package/src/internal.ts +27 -0
- package/src/{monkey-patch.tsx → monkey-patch.ts} +3 -2
- package/src/native.ts +37 -61
- package/src/replicas.ts +1 -1
- package/src/specs/KeyboardControllerViewNativeComponent.ts +23 -0
- package/src/specs/NativeKeyboardController.ts +16 -0
- package/src/specs/NativeStatusBarManagerCompat.ts +13 -0
- package/src/types.ts +42 -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/ios/KeyboardControllerModule.m +0 -21
- package/ios/KeyboardControllerModule.swift +0 -53
- package/ios/KeyboardMoveEvent.swift +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getConstants","NativeAndroidManager","default","RCTStatusBarManagerCompat","
|
|
1
|
+
{"version":3,"names":["getConstants","NativeAndroidManager","default","RCTStatusBarManagerCompat","require","Platform","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;;AAEA;;;;;;AADA;AAGA,MAAMA,YAAY,GAAGC,oBAAoB,CAACC,OAArB,CAA6BF,YAAlD;;AAEA,MAAMG,yBAAyB,GAC7BC,OAAO,CAAC,sCAAD,CAAP,CAAgDF,OADlD,C,CAGA;AACA;AACA;;;AACA,IAAIG,qBAAA,CAASC,EAAT,KAAgB,SAApB,EAA+B;EAC7BL,oBAAoB,CAACC,OAArB,GAA+B;IAC7BF,YAD6B;;IAE7BO,QAAQ,CAACC,KAAD,EAAgBC,QAAhB,EAAyC;MAC/CN,yBAAyB,CAACI,QAA1B,CAAmCC,KAAnC,EAA0CC,QAA1C;IACD,CAJ4B;;IAM7BC,cAAc,CAACC,WAAD,EAA6B;MACzCR,yBAAyB,CAACO,cAA1B,CAAyCC,WAAzC;IACD,CAR4B;;IAU7B;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAD,EAAgC;MACtCV,yBAAyB,CAACS,QAA1B,CAAmCC,cAAnC;IACD,CAjB4B;;IAmB7BC,SAAS,CAACC,MAAD,EAAwB;MAC/BZ,yBAAyB,CAACW,SAA1B,CAAoCC,MAApC;IACD;;EArB4B,CAA/B;AAuBD"}
|
package/lib/commonjs/native.js
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _react = require("react");
|
|
6
|
+
exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.AndroidSoftInputModes = void 0;
|
|
9
7
|
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
9
|
|
|
12
10
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
13
11
|
ios: "- You have run 'pod install'\n",
|
|
14
12
|
default: ''
|
|
15
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo
|
|
13
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; // copied from `android.view.WindowManager.LayoutParams`
|
|
14
|
+
|
|
16
15
|
let AndroidSoftInputModes;
|
|
17
16
|
exports.AndroidSoftInputModes = AndroidSoftInputModes;
|
|
18
17
|
|
|
@@ -21,28 +20,34 @@ exports.AndroidSoftInputModes = AndroidSoftInputModes;
|
|
|
21
20
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
|
|
22
21
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_RESIZE"] = 16] = "SOFT_INPUT_ADJUST_RESIZE";
|
|
23
22
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_UNSPECIFIED"] = 0] = "SOFT_INPUT_ADJUST_UNSPECIFIED";
|
|
23
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_IS_FORWARD_NAVIGATION"] = 256] = "SOFT_INPUT_IS_FORWARD_NAVIGATION";
|
|
24
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_ADJUST"] = 240] = "SOFT_INPUT_MASK_ADJUST";
|
|
25
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MASK_STATE"] = 15] = "SOFT_INPUT_MASK_STATE";
|
|
26
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_MODE_CHANGED"] = 512] = "SOFT_INPUT_MODE_CHANGED";
|
|
27
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_HIDDEN"] = 3] = "SOFT_INPUT_STATE_ALWAYS_HIDDEN";
|
|
28
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_ALWAYS_VISIBLE"] = 5] = "SOFT_INPUT_STATE_ALWAYS_VISIBLE";
|
|
29
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_HIDDEN"] = 2] = "SOFT_INPUT_STATE_HIDDEN";
|
|
30
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNCHANGED"] = 1] = "SOFT_INPUT_STATE_UNCHANGED";
|
|
31
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
|
|
32
|
+
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
|
|
24
33
|
})(AndroidSoftInputModes || (exports.AndroidSoftInputModes = AndroidSoftInputModes = {}));
|
|
25
34
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const KeyboardController = RCTKeyboardController
|
|
35
|
+
const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
|
|
36
|
+
|
|
37
|
+
const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
38
|
+
get() {
|
|
39
|
+
throw new Error(LINKING_ERROR);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
});
|
|
29
43
|
exports.KeyboardController = KeyboardController;
|
|
30
|
-
const eventEmitter = new _reactNative.NativeEventEmitter(
|
|
44
|
+
const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardController);
|
|
31
45
|
const KeyboardEvents = {
|
|
32
46
|
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
33
47
|
};
|
|
34
48
|
exports.KeyboardEvents = KeyboardEvents;
|
|
35
|
-
const KeyboardControllerView = _reactNative.UIManager.getViewManagerConfig(ComponentName) != null ? (0, _reactNative.requireNativeComponent)(ComponentName) : () => {
|
|
36
|
-
throw new Error(LINKING_ERROR);
|
|
37
|
-
};
|
|
38
|
-
exports.KeyboardControllerView = KeyboardControllerView;
|
|
39
49
|
|
|
40
|
-
const
|
|
41
|
-
(0, _react.useEffect)(() => {
|
|
42
|
-
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
43
|
-
return () => KeyboardController.setDefaultMode();
|
|
44
|
-
}, []);
|
|
45
|
-
};
|
|
50
|
+
const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
46
51
|
|
|
47
|
-
exports.
|
|
52
|
+
exports.KeyboardControllerView = KeyboardControllerView;
|
|
48
53
|
//# sourceMappingURL=native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","AndroidSoftInputModes","
|
|
1
|
+
{"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","AndroidSoftInputModes","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","NativeEventEmitter","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;;AAQA,MAAMA,aAAa,GAChB,2FAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,+BAJF,C,CAMA;;IACYC,qB;;;WAAAA,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,qCAAAA,qB;;AAiBZ,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAD,CAAP,CAA4CH,OAD9C;;AAEO,MAAMI,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBADiB,GAEjB,IAAIG,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUX,aAAV,CAAN;EACD;;AAHH,CAFF,CAHC;;AAaP,MAAMY,YAAY,GAAG,IAAIC,+BAAJ,CAAuBL,kBAAvB,CAArB;AAEO,MAAMM,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IADW,EAEXC,EAFW,KAGRL,YAAY,CAACG,WAAb,CAAyB,yBAAyBC,IAAlD,EAAwDC,EAAxD;AAJuB,CAAvB;;;AAMA,MAAMC,sBAAsB,GACjCX,OAAO,CAAC,+CAAD,CAAP,CAAyDH,OADpD"}
|
package/lib/commonjs/replicas.js
CHANGED
|
@@ -11,7 +11,7 @@ var _reactNative = require("react-native");
|
|
|
11
11
|
|
|
12
12
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _hooks = require("./hooks");
|
|
15
15
|
|
|
16
16
|
var _native = require("./native");
|
|
17
17
|
|
|
@@ -133,6 +133,6 @@ const useReanimatedKeyboardAnimationReplica = () => {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
exports.useReanimatedKeyboardAnimationReplica = useReanimatedKeyboardAnimationReplica;
|
|
136
|
-
const useGradualKeyboardAnimation = _reactNative.Platform.OS === 'ios' ? useReanimatedKeyboardAnimationReplica :
|
|
136
|
+
const useGradualKeyboardAnimation = _reactNative.Platform.OS === 'ios' ? useReanimatedKeyboardAnimationReplica : _hooks.useReanimatedKeyboardAnimation;
|
|
137
137
|
exports.useGradualKeyboardAnimation = useGradualKeyboardAnimation;
|
|
138
138
|
//# sourceMappingURL=replicas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["availableOSEventType","Platform","OS","defaultAndroidEasing","Easing","bezier","useKeyboardAnimationReplica","height","useRef","Animated","Value","progress","animation","useMemo","current","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","Keyboard","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","useSharedValue","heightEvent","useDerivedValue","value","handler","useWorkletCallback","_height","useAnimatedReaction","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","withSpring","show","runOnUI","hide","useGradualKeyboardAnimation","useReanimatedKeyboardAnimation"],"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":["availableOSEventType","Platform","OS","defaultAndroidEasing","Easing","bezier","useKeyboardAnimationReplica","height","useRef","Animated","Value","progress","animation","useMemo","current","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","listener","Keyboard","addListener","e","timing","toValue","endCoordinates","duration","easing","useNativeDriver","start","remove","IOS_SPRING_CONFIG","damping","stiffness","mass","overshootClamping","restDisplacementThreshold","restSpeedThreshold","useReanimatedKeyboardAnimationReplica","useSharedValue","heightEvent","useDerivedValue","value","handler","useWorkletCallback","_height","useAnimatedReaction","_keyboardHeight","result","_previousResult","_previousKeyboardHeight","withSpring","show","runOnUI","hide","useGradualKeyboardAnimation","useReanimatedKeyboardAnimation"],"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":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
// @ts-expect-error - no type definition
|
|
13
|
+
var _default = (0, _codegenNativeComponent.default)('KeyboardControllerView');
|
|
14
|
+
|
|
15
|
+
exports.default = _default;
|
|
16
|
+
//# sourceMappingURL=KeyboardControllerViewNativeComponent.js.map
|
|
@@ -0,0 +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":";;;;;;;AAQA;;;;AAPA;eAmBe,IAAAA,+BAAA,EACb,wBADa,C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _default = _reactNative.TurboModuleRegistry.get('KeyboardController');
|
|
11
|
+
|
|
12
|
+
exports.default = _default;
|
|
13
|
+
//# sourceMappingURL=NativeKeyboardController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>('KeyboardController');\n"],"mappings":";;;;;;;AACA;;eAceA,gCAAA,CAAoBC,GAApB,CAA8B,oBAA9B,C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _default = _reactNative.TurboModuleRegistry.get('StatusBarManagerCompat');
|
|
11
|
+
|
|
12
|
+
exports.default = _default;
|
|
13
|
+
//# sourceMappingURL=NativeStatusBarManagerCompat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeStatusBarManagerCompat.ts"],"sourcesContent":["import type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n setHidden(hidden: boolean): void;\n setColor(color: number, animated: boolean): void;\n setTranslucent(translucent: boolean): void;\n setStyle(style: string): void;\n}\n\nexport default TurboModuleRegistry.get<Spec>('StatusBarManagerCompat');\n"],"mappings":";;;;;;;AACA;;eAWeA,gCAAA,CAAoBC,GAApB,CAA8B,wBAA9B,C"}
|
|
@@ -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 onKeyboardMove: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => 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"],"mappings":""}
|
package/lib/module/animated.js
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useRef } from 'react';
|
|
2
2
|
import { Animated, StyleSheet } from 'react-native';
|
|
3
|
-
import Reanimated, {
|
|
4
|
-
import {
|
|
3
|
+
import Reanimated, { useSharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { KeyboardContext } from './context';
|
|
5
|
+
import { useAnimatedKeyboardHandler } 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,10 +19,13 @@ 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
|
-
const heightSV = useSharedValue(0);
|
|
27
|
+
const heightSV = useSharedValue(0); // memo
|
|
28
|
+
|
|
68
29
|
const context = useMemo(() => ({
|
|
69
30
|
animated: {
|
|
70
31
|
progress: progress,
|
|
@@ -89,7 +50,8 @@ export const KeyboardProvider = _ref => {
|
|
|
89
50
|
}
|
|
90
51
|
}], {
|
|
91
52
|
useNativeDriver: true
|
|
92
|
-
}), []);
|
|
53
|
+
}), []); // handlers
|
|
54
|
+
|
|
93
55
|
const handler = useAnimatedKeyboardHandler({
|
|
94
56
|
onKeyboardMove: event => {
|
|
95
57
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","useMemo","useRef","Animated","StyleSheet","Reanimated","useSharedValue","KeyboardContext","useAnimatedKeyboardHandler","KeyboardControllerView","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","progress","Value","current","height","progressSV","heightSV","context","animated","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","handler","value"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { Animated, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport { useAnimatedKeyboardHandler } from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type { KeyboardControllerProps, NativeEvent } 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 // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: height },\n reanimated: { progress: progressSV, height: heightSV },\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 handler = useAnimatedKeyboardHandler(\n {\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n progressSV.value = event.progress;\n heightSV.value = event.height;\n },\n },\n []\n );\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMove={onKeyboardMove}\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,UAAnB,QAAgD,cAAhD;AACA,OAAOC,UAAP,IAAqBC,cAArB,QAA2C,yBAA3C;AAEA,SAASC,eAAT,QAAgC,WAAhC;AACA,SAASC,0BAAT,QAA2C,YAA3C;AACA,SAASC,sBAAT,QAAuC,UAAvC;AAIA,MAAMC,8BAA8B,GAAGL,UAAU,CAACM,uBAAX,CACrCR,QAAQ,CAACQ,uBAAT,CACEF,sBADF,CADqC,CAAvC;AAWA,OAAO,MAAMG,MAAM,GAAGR,UAAU,CAACS,MAAX,CAA0B;EAC9CC,SAAS,EAAE;IACTC,IAAI,EAAE;EADG,CADmC;EAI9CC,MAAM,EAAE;IACNC,OAAO,EAAE,MADH;IAENC,QAAQ,EAAE;EAFJ;AAJsC,CAA1B,CAAf;AAwBP,OAAO,MAAMC,gBAAgB,GAAG,QAGH;EAAA,IAHI;IAC/BC,QAD+B;IAE/BC;EAF+B,CAGJ;EAC3B;EACA,MAAMC,QAAQ,GAAGpB,MAAM,CAAC,IAAIC,QAAQ,CAACoB,KAAb,CAAmB,CAAnB,CAAD,CAAN,CAA8BC,OAA/C;EACA,MAAMC,MAAM,GAAGvB,MAAM,CAAC,IAAIC,QAAQ,CAACoB,KAAb,CAAmB,CAAnB,CAAD,CAAN,CAA8BC,OAA7C,CAH2B,CAI3B;;EACA,MAAME,UAAU,GAAGpB,cAAc,CAAC,CAAD,CAAjC;EACA,MAAMqB,QAAQ,GAAGrB,cAAc,CAAC,CAAD,CAA/B,CAN2B,CAO3B;;EACA,MAAMsB,OAAO,GAAG3B,OAAO,CACrB,OAAO;IACL4B,QAAQ,EAAE;MAAEP,QAAQ,EAAEA,QAAZ;MAAsBG,MAAM,EAAEA;IAA9B,CADL;IAELK,UAAU,EAAE;MAAER,QAAQ,EAAEI,UAAZ;MAAwBD,MAAM,EAAEE;IAAhC;EAFP,CAAP,CADqB,EAKrB,EALqB,CAAvB;EAOA,MAAMI,KAAK,GAAG9B,OAAO,CACnB,MAAM,CACJW,MAAM,CAACI,MADH,EAEJ;IAAEgB,SAAS,EAAE,CAAC;MAAEC,UAAU,EAAER;IAAd,CAAD,EAAyB;MAAES,UAAU,EAAEZ;IAAd,CAAzB;EAAb,CAFI,CADa,EAKnB,EALmB,CAArB;EAOA,MAAMa,cAAc,GAAGlC,OAAO,CAC5B,MACEE,QAAQ,CAACiC,KAAT,CACE,CACE;IACEC,WAAW,EAAE;MACXf,QADW;MAEXG;IAFW;EADf,CADF,CADF,EASE;IAAEa,eAAe,EAAE;EAAnB,CATF,CAF0B,EAa5B,EAb4B,CAA9B,CAtB2B,CAqC3B;;EACA,MAAMC,OAAO,GAAG/B,0BAA0B,CACxC;IACE2B,cAAc,EAAGC,KAAD,IAAwB;MACtC;;MACAV,UAAU,CAACc,KAAX,GAAmBJ,KAAK,CAACd,QAAzB;MACAK,QAAQ,CAACa,KAAT,GAAiBJ,KAAK,CAACX,MAAvB;IACD;EALH,CADwC,EAQxC,EARwC,CAA1C;EAWA,oBACE,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAEG;EAAjC,gBACE,oBAAC,8BAAD;IACE,wBAAwB,EAAEW,OAD5B;IAEE,cAAc,EAAEJ,cAFlB;IAGE,oBAAoB,EAAEd,oBAHxB;IAIE,KAAK,EAAET,MAAM,CAACE;EAJhB,gBAME,uDACE,oBAAC,QAAD,CAAU,IAAV;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEiB;EATT,EADF,EAYGX,QAZH,CANF,CADF,CADF;AAyBD,CA7EM"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
};
|
|
17
|
+
export const KeyboardContext = /*#__PURE__*/createContext(defaultContext);
|
|
18
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","Animated","defaultContext","animated","progress","Value","height","reanimated","value","KeyboardContext"],"sources":["context.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\n\nimport type { SharedValue } from 'react-native-reanimated';\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.Value;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\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};\nexport const KeyboardContext = createContext(defaultContext);\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAgBA,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;AALmC,CAAjD;AAUA,OAAO,MAAMC,eAAe,gBAAGT,aAAa,CAACE,cAAD,CAArC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useContext, useEffect } from 'react';
|
|
2
|
+
import { KeyboardContext } from './context';
|
|
3
|
+
import { AndroidSoftInputModes, KeyboardController } from './native';
|
|
4
|
+
export const useResizeMode = () => {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
7
|
+
return () => KeyboardController.setDefaultMode();
|
|
8
|
+
}, []);
|
|
9
|
+
};
|
|
10
|
+
export const useKeyboardAnimation = () => {
|
|
11
|
+
useResizeMode();
|
|
12
|
+
const context = useContext(KeyboardContext);
|
|
13
|
+
return context.animated;
|
|
14
|
+
};
|
|
15
|
+
export const useReanimatedKeyboardAnimation = () => {
|
|
16
|
+
useResizeMode();
|
|
17
|
+
const context = useContext(KeyboardContext);
|
|
18
|
+
return context.reanimated;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","KeyboardContext","AndroidSoftInputModes","KeyboardController","useResizeMode","setInputMode","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","animated","useReanimatedKeyboardAnimation","reanimated"],"sources":["hooks.ts"],"sourcesContent":["import { useContext, useEffect } from 'react';\n\nimport { AnimatedContext, KeyboardContext, ReanimatedContext } from './context';\nimport { AndroidSoftInputModes, KeyboardController } from './native';\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"],"mappings":"AAAA,SAASA,UAAT,EAAqBC,SAArB,QAAsC,OAAtC;AAEA,SAA0BC,eAA1B,QAAoE,WAApE;AACA,SAASC,qBAAT,EAAgCC,kBAAhC,QAA0D,UAA1D;AAEA,OAAO,MAAMC,aAAa,GAAG,MAAM;EACjCJ,SAAS,CAAC,MAAM;IACdG,kBAAkB,CAACE,YAAnB,CACEH,qBAAqB,CAACI,wBADxB;IAIA,OAAO,MAAMH,kBAAkB,CAACI,cAAnB,EAAb;EACD,CANQ,EAMN,EANM,CAAT;AAOD,CARM;AAUP,OAAO,MAAMC,oBAAoB,GAAG,MAAuB;EACzDJ,aAAa;EACb,MAAMK,OAAO,GAAGV,UAAU,CAACE,eAAD,CAA1B;EAEA,OAAOQ,OAAO,CAACC,QAAf;AACD,CALM;AAOP,OAAO,MAAMC,8BAA8B,GAAG,MAAyB;EACrEP,aAAa;EACb,MAAMK,OAAO,GAAGV,UAAU,CAACE,eAAD,CAA1B;EAEA,OAAOQ,OAAO,CAACG,UAAf;AACD,CALM"}
|
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,19 @@
|
|
|
1
|
+
import { useEvent, useHandler } from 'react-native-reanimated';
|
|
2
|
+
export function useAnimatedKeyboardHandler(handlers, dependencies) {
|
|
3
|
+
const {
|
|
4
|
+
context,
|
|
5
|
+
doDependenciesDiffer
|
|
6
|
+
} = useHandler(handlers, dependencies);
|
|
7
|
+
return useEvent(event => {
|
|
8
|
+
'worklet';
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
onKeyboardMove
|
|
12
|
+
} = handlers;
|
|
13
|
+
|
|
14
|
+
if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {
|
|
15
|
+
onKeyboardMove(event, context);
|
|
16
|
+
}
|
|
17
|
+
}, ['onKeyboardMove'], doDependenciesDiffer);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEvent","useHandler","useAnimatedKeyboardHandler","handlers","dependencies","context","doDependenciesDiffer","event","onKeyboardMove","eventName","endsWith"],"sources":["internal.ts"],"sourcesContent":["import { useEvent, useHandler } from 'react-native-reanimated';\n\nimport type { EventWithName, NativeEvent } from './types';\n\nexport function useAnimatedKeyboardHandler<\n TContext extends Record<string, unknown>\n>(\n handlers: {\n onKeyboardMove?: (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 { onKeyboardMove } = handlers;\n\n if (onKeyboardMove && event.eventName.endsWith('onKeyboardMove')) {\n onKeyboardMove(event, context);\n }\n },\n ['onKeyboardMove'],\n doDependenciesDiffer\n );\n}\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,UAAnB,QAAqC,yBAArC;AAIA,OAAO,SAASC,0BAAT,CAGLC,QAHK,EAMLC,YANK,EAOL;EACA,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAoCL,UAAU,CAACE,QAAD,EAAWC,YAAX,CAApD;EAEA,OAAOJ,QAAQ,CACZO,KAAD,IAAuC;IACrC;;IACA,MAAM;MAAEC;IAAF,IAAqBL,QAA3B;;IAEA,IAAIK,cAAc,IAAID,KAAK,CAACE,SAAN,CAAgBC,QAAhB,CAAyB,gBAAzB,CAAtB,EAAkE;MAChEF,cAAc,CAACD,KAAD,EAAQF,OAAR,CAAd;IACD;EACF,CARY,EASb,CAAC,gBAAD,CATa,EAUbC,oBAVa,CAAf;AAYD"}
|
|
@@ -1,11 +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
4
|
const getConstants = NativeAndroidManager.default.getConstants;
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default; // On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
6
7
|
// in order to use library on all available platforms we have to monkey patch
|
|
7
8
|
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
if (Platform.OS === 'android') {
|
|
10
12
|
NativeAndroidManager.default = {
|
|
11
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,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requireNativeComponent, UIManager, Platform, NativeModules, NativeEventEmitter } from 'react-native';
|
|
1
|
+
import { Platform, NativeEventEmitter } from 'react-native';
|
|
3
2
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
4
3
|
ios: "- You have run 'pod install'\n",
|
|
5
4
|
default: ''
|
|
6
|
-
}) + '- 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
|
+
|
|
7
7
|
export let AndroidSoftInputModes;
|
|
8
8
|
|
|
9
9
|
(function (AndroidSoftInputModes) {
|
|
@@ -11,22 +11,29 @@ export let AndroidSoftInputModes;
|
|
|
11
11
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
|
|
12
12
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_RESIZE"] = 16] = "SOFT_INPUT_ADJUST_RESIZE";
|
|
13
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";
|
|
14
24
|
})(AndroidSoftInputModes || (AndroidSoftInputModes = {}));
|
|
15
25
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
export const KeyboardController = RCTKeyboardController
|
|
19
|
-
|
|
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);
|
|
20
35
|
export const KeyboardEvents = {
|
|
21
36
|
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
22
37
|
};
|
|
23
|
-
export const KeyboardControllerView =
|
|
24
|
-
throw new Error(LINKING_ERROR);
|
|
25
|
-
};
|
|
26
|
-
export const useResizeMode = () => {
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
KeyboardController.setInputMode(AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
29
|
-
return () => KeyboardController.setDefaultMode();
|
|
30
|
-
}, []);
|
|
31
|
-
};
|
|
38
|
+
export const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
32
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
|
|