react-native-keyboard-controller 1.4.3 → 1.5.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/README.md +1 -1
- package/android/build.gradle +9 -2
- package/android/gradle.properties +2 -2
- package/android/react-native-helpers.gradle +48 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +7 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +47 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/InteractiveKeyboardProvider.kt +6 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +27 -13
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationController.kt +394 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +2 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/Float.kt +4 -4
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +21 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/interpolators/Interpolator.kt +14 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/interpolators/IosInterpolator.kt +18 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/interpolators/LinearInterpolator.kt +11 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +8 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +27 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +192 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +5 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +33 -0
- package/ios/KeyboardControllerView.mm +10 -3
- package/ios/KeyboardControllerViewManager.mm +1 -0
- package/ios/KeyboardControllerViewManager.swift +1 -0
- package/ios/KeyboardMovementObserver.swift +78 -4
- package/jest/index.js +1 -0
- package/lib/commonjs/animated.js +16 -20
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/context.js +0 -3
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +0 -13
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +0 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +13 -22
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.js +3 -12
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/native.js +10 -10
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/replicas.js +3 -19
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +0 -5
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +13 -0
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js +0 -3
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +0 -3
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils.js +0 -2
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/animated.js +16 -8
- package/lib/module/animated.js.map +1 -1
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +13 -16
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.js +4 -10
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/native.js +8 -5
- package/lib/module/native.js.map +1 -1
- package/lib/module/replicas.js +3 -5
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +0 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/animated.d.ts +10 -2
- package/lib/typescript/context.d.ts +3 -3
- package/lib/typescript/internal.d.ts +1 -0
- package/lib/typescript/native.d.ts +2 -1
- package/lib/typescript/replicas.d.ts +1 -1
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +7 -5
- package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +10 -0
- package/lib/typescript/types.d.ts +30 -13
- package/package.json +11 -12
- package/src/animated.tsx +17 -0
- package/src/internal.ts +20 -3
- package/src/native.ts +5 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +6 -6
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +14 -0
- package/src/types.ts +25 -5
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,QAAQ,QAAQ,cAAc;AACvC;AACA,OAAO,KAAKC,oBAAoB,MAAM,2EAA2E;AAEjH,MAAMC,YAAY,GAAGD,oBAAoB,CAACE,OAAO,CAACD,YAAY;AAE9D,MAAME,yBAAyB,GAC7BC,OAAO,CAAC,sCAAsC,CAAC,CAACF,OAAO;;AAEzD;AACA;AACA;AACA,IAAIH,QAAQ,CAACM,EAAE,KAAK,SAAS,EAAE;EAC7BL,oBAAoB,CAACE,OAAO,GAAG;IAC7BD,YAAY;IACZK,QAAQ,CAACC,KAAa,EAAEC,QAAiB,EAAQ;MAC/CL,yBAAyB,CAACG,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;IACrD,CAAC;IAEDC,cAAc,CAACC,WAAoB,EAAQ;MACzCP,yBAAyB,CAACM,cAAc,CAACC,WAAW,CAAC;IACvD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAuB,EAAQ;MACtCT,yBAAyB,CAACQ,QAAQ,CAACC,cAAc,CAAC;IACpD,CAAC;IAEDC,SAAS,CAACC,MAAe,EAAQ;MAC/BX,yBAAyB,CAACU,SAAS,CAACC,MAAM,CAAC;IAC7C;EACF,CAAC;AACH"}
|
package/lib/module/native.js
CHANGED
|
@@ -2,10 +2,10 @@ import { Platform, NativeEventEmitter } from 'react-native';
|
|
|
2
2
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
3
|
ios: "- You have run 'pod install'\n",
|
|
4
4
|
default: ''
|
|
5
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
5
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
6
6
|
|
|
7
|
+
// copied from `android.view.WindowManager.LayoutParams`
|
|
7
8
|
export let AndroidSoftInputModes;
|
|
8
|
-
|
|
9
9
|
(function (AndroidSoftInputModes) {
|
|
10
10
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_NOTHING"] = 48] = "SOFT_INPUT_ADJUST_NOTHING";
|
|
11
11
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_ADJUST_PAN"] = 32] = "SOFT_INPUT_ADJUST_PAN";
|
|
@@ -22,18 +22,21 @@ export let AndroidSoftInputModes;
|
|
|
22
22
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_UNSPECIFIED"] = 0] = "SOFT_INPUT_STATE_UNSPECIFIED";
|
|
23
23
|
AndroidSoftInputModes[AndroidSoftInputModes["SOFT_INPUT_STATE_VISIBLE"] = 4] = "SOFT_INPUT_STATE_VISIBLE";
|
|
24
24
|
})(AndroidSoftInputModes || (AndroidSoftInputModes = {}));
|
|
25
|
-
|
|
26
25
|
const RCTKeyboardController = require('./specs/NativeKeyboardController').default;
|
|
27
|
-
|
|
28
26
|
export const KeyboardController = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
29
27
|
get() {
|
|
30
28
|
throw new Error(LINKING_ERROR);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
});
|
|
34
31
|
const eventEmitter = new NativeEventEmitter(KeyboardController);
|
|
35
32
|
export const KeyboardEvents = {
|
|
36
33
|
addListener: (name, cb) => eventEmitter.addListener('KeyboardController::' + name, cb)
|
|
37
34
|
};
|
|
38
35
|
export const KeyboardControllerView = require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
36
|
+
export const KeyboardGestureArea = Platform.OS === 'android' && Platform.Version >= 30 ? require('./specs/KeyboardGestureAreaNativeComponent').default : _ref => {
|
|
37
|
+
let {
|
|
38
|
+
children
|
|
39
|
+
} = _ref;
|
|
40
|
+
return children;
|
|
41
|
+
};
|
|
39
42
|
//# sourceMappingURL=native.js.map
|
package/lib/module/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 KeyboardControllerProps,\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: React.FC<KeyboardControllerProps> =\n require('./specs/KeyboardControllerViewNativeComponent').default;\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"names":["Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","AndroidSoftInputModes","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","KeyboardGestureArea","OS","Version","children"],"sources":["native.ts"],"sourcesContent":["import { Platform, NativeEventEmitter } from 'react-native';\n\nimport type {\n KeyboardControllerEvents,\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventData,\n KeyboardGestureAreaProps,\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: React.FC<KeyboardControllerProps> =\n require('./specs/KeyboardControllerViewNativeComponent').default;\nexport const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =\n Platform.OS === 'android' && Platform.Version >= 30\n ? require('./specs/KeyboardGestureAreaNativeComponent').default\n : ({ children }: KeyboardGestureAreaProps) => children;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,kBAAkB,QAAQ,cAAc;AAU3D,MAAMC,aAAa,GAChB,2FAA0F,GAC3FF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,WAAYC,qBAAqB;AAehC,WAfWA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;EAArBA,qBAAqB,CAArBA,qBAAqB;AAAA,GAArBA,qBAAqB,KAArBA,qBAAqB;AAiBjC,MAAMC,qBAAqB,GACzBC,OAAO,CAAC,kCAAkC,CAAC,CAACH,OAAO;AACrD,OAAO,MAAMI,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CAAC,CAEoB;AAE7B,MAAMW,YAAY,GAAG,IAAIZ,kBAAkB,CAACQ,kBAAkB,CAAC;AAE/D,OAAO,MAAMK,cAAc,GAAG;EAC5BC,WAAW,EAAE,CACXC,IAA8B,EAC9BC,EAAkC,KAC/BJ,YAAY,CAACE,WAAW,CAAC,sBAAsB,GAAGC,IAAI,EAAEC,EAAE;AACjE,CAAC;AACD,OAAO,MAAMC,sBAAyD,GACpEV,OAAO,CAAC,+CAA+C,CAAC,CAACH,OAAO;AAClE,OAAO,MAAMc,mBAAuD,GAClEnB,QAAQ,CAACoB,EAAE,KAAK,SAAS,IAAIpB,QAAQ,CAACqB,OAAO,IAAI,EAAE,GAC/Cb,OAAO,CAAC,4CAA4C,CAAC,CAACH,OAAO,GAC7D;EAAA,IAAC;IAAEiB;EAAmC,CAAC;EAAA,OAAKA,QAAQ;AAAA"}
|
package/lib/module/replicas.js
CHANGED
|
@@ -3,10 +3,10 @@ import { Animated, Easing, Keyboard, Platform } from 'react-native';
|
|
|
3
3
|
import { runOnUI, useAnimatedReaction, useDerivedValue, useSharedValue, useWorkletCallback, withSpring } from 'react-native-reanimated';
|
|
4
4
|
import { useReanimatedKeyboardAnimation } from './hooks';
|
|
5
5
|
import { AndroidSoftInputModes, KeyboardController } from './native';
|
|
6
|
-
const availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';
|
|
6
|
+
const availableOSEventType = Platform.OS === 'ios' ? 'Will' : 'Did';
|
|
7
7
|
|
|
8
|
+
// cubic-bezier(.17,.67,.34,.94)
|
|
8
9
|
export const defaultAndroidEasing = Easing.bezier(0.4, 0.0, 0.2, 1);
|
|
9
|
-
|
|
10
10
|
/**
|
|
11
11
|
* An experimental implementation of tracing keyboard appearance.
|
|
12
12
|
* Switch an input mode to adjust resize mode. In this case all did* events
|
|
@@ -58,6 +58,7 @@ const IOS_SPRING_CONFIG = {
|
|
|
58
58
|
restDisplacementThreshold: 10,
|
|
59
59
|
restSpeedThreshold: 10
|
|
60
60
|
};
|
|
61
|
+
|
|
61
62
|
/**
|
|
62
63
|
* A close replica to native iOS keyboard animation. The problem is that
|
|
63
64
|
* iOS (unlike Android) can not fire events for each keyboard frame movement.
|
|
@@ -72,7 +73,6 @@ const IOS_SPRING_CONFIG = {
|
|
|
72
73
|
*
|
|
73
74
|
* @returns {height, progress} - animated values
|
|
74
75
|
*/
|
|
75
|
-
|
|
76
76
|
export const useReanimatedKeyboardAnimationReplica = () => {
|
|
77
77
|
const height = useSharedValue(0);
|
|
78
78
|
const heightEvent = useSharedValue(0);
|
|
@@ -86,9 +86,7 @@ export const useReanimatedKeyboardAnimationReplica = () => {
|
|
|
86
86
|
const {
|
|
87
87
|
_keyboardHeight
|
|
88
88
|
} = result;
|
|
89
|
-
|
|
90
89
|
const _previousKeyboardHeight = _previousResult === null || _previousResult === void 0 ? void 0 : _previousResult._keyboardHeight;
|
|
91
|
-
|
|
92
90
|
if (_keyboardHeight !== _previousKeyboardHeight) {
|
|
93
91
|
height.value = withSpring(_keyboardHeight, IOS_SPRING_CONFIG);
|
|
94
92
|
}
|
|
@@ -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 './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,
|
|
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":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Double,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"AAMA,OAAOA,sBAAsB,MAAM,yDAAyD;AAkB5F,eAAeA,sBAAsB,CACnC,wBAAwB,CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","excludedPlatforms"],"sources":["KeyboardGestureAreaNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\nexport interface NativeProps extends ViewProps {\n interpolator?: WithDefault<'linear' | 'ios', 'linear'>;\n allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;\n allowToDragKeyboardFromShownStateBySwipes?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>('KeyboardGestureArea', {\n excludedPlatforms: ['iOS'],\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAGA,OAAOA,sBAAsB,MAAM,yDAAyD;AAQ5F,eAAeA,sBAAsB,CAAc,qBAAqB,EAAE;EACxEC,iBAAiB,EAAE,CAAC,KAAK;AAC3B,CAAC,CAAC"}
|
|
@@ -1 +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,SAASA,
|
|
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,SAASA,mBAAmB,QAAQ,cAAc;AAclD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC"}
|
|
@@ -1 +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,SAASA,
|
|
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,SAASA,mBAAmB,QAAQ,cAAc;AAWlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,wBAAwB,CAAC"}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +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
|
|
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 onKeyboardMoveInteractive?: (\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 navigationBarTranslucent?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator: 'ios' | 'linear';\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n allowToDragKeyboardFromShownStateBySwipes?: 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 = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\n"],"mappings":""}
|
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +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,
|
|
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,MAAM,EAAE,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
type KeyboardProviderProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
/**
|
|
5
5
|
* Set the value to `true`, if you use translucent status bar on Android.
|
|
@@ -11,6 +11,14 @@ declare type KeyboardProviderProps = {
|
|
|
11
11
|
* @platform android
|
|
12
12
|
*/
|
|
13
13
|
statusBarTranslucent?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Set the value to `true`, if you use translucent navigation bar on Android.
|
|
16
|
+
* Defaults to `false`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
|
|
19
|
+
* @platform android
|
|
20
|
+
*/
|
|
21
|
+
navigationBarTranslucent?: boolean;
|
|
14
22
|
};
|
|
15
|
-
export declare const KeyboardProvider: ({ children, statusBarTranslucent, }: KeyboardProviderProps) => JSX.Element;
|
|
23
|
+
export declare const KeyboardProvider: ({ children, statusBarTranslucent, navigationBarTranslucent, }: KeyboardProviderProps) => JSX.Element;
|
|
16
24
|
export {};
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
3
|
import type { SharedValue } from 'react-native-reanimated';
|
|
4
4
|
import type { KeyboardHandlers } from './types';
|
|
5
|
-
export
|
|
5
|
+
export type AnimatedContext = {
|
|
6
6
|
progress: Animated.Value;
|
|
7
7
|
height: Animated.AnimatedMultiplication<number>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type ReanimatedContext = {
|
|
10
10
|
progress: SharedValue<number>;
|
|
11
11
|
height: SharedValue<number>;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type KeyboardAnimationContext = {
|
|
14
14
|
animated: AnimatedContext;
|
|
15
15
|
reanimated: ReanimatedContext;
|
|
16
16
|
setHandlers: (handlers: KeyboardHandlers) => void;
|
|
@@ -4,6 +4,7 @@ export declare function useAnimatedKeyboardHandler<TContext extends Record<strin
|
|
|
4
4
|
onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;
|
|
5
5
|
onKeyboardMove?: (e: NativeEvent, context: TContext) => void;
|
|
6
6
|
onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;
|
|
7
|
+
onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;
|
|
7
8
|
}, dependencies?: ReadonlyArray<unknown>): (e: import("react-native").NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
8
9
|
/**
|
|
9
10
|
* Hook for storing worklet handlers (objects with keys, where values are worklets).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { KeyboardControllerEvents, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventData } from './types';
|
|
2
|
+
import type { KeyboardControllerEvents, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventData, KeyboardGestureAreaProps } from './types';
|
|
3
3
|
export declare enum AndroidSoftInputModes {
|
|
4
4
|
SOFT_INPUT_ADJUST_NOTHING = 48,
|
|
5
5
|
SOFT_INPUT_ADJUST_PAN = 32,
|
|
@@ -21,3 +21,4 @@ export declare const KeyboardEvents: {
|
|
|
21
21
|
addListener: (name: KeyboardControllerEvents, cb: (e: KeyboardEventData) => void) => import("react-native").EmitterSubscription;
|
|
22
22
|
};
|
|
23
23
|
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
24
|
+
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react-native-reanimated" />
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
3
|
export declare const defaultAndroidEasing: import("react-native").EasingFunction;
|
|
4
|
-
|
|
4
|
+
type KeyboardAnimation = {
|
|
5
5
|
progress: Animated.Value;
|
|
6
6
|
height: Animated.Value;
|
|
7
7
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { HostComponent } from 'react-native';
|
|
2
2
|
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
3
|
-
import type { DirectEventHandler,
|
|
4
|
-
|
|
5
|
-
height:
|
|
6
|
-
progress:
|
|
3
|
+
import type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
type KeyboardMoveEvent = Readonly<{
|
|
5
|
+
height: Double;
|
|
6
|
+
progress: Double;
|
|
7
7
|
}>;
|
|
8
8
|
export interface NativeProps extends ViewProps {
|
|
9
9
|
statusBarTranslucent?: boolean;
|
|
10
|
-
|
|
10
|
+
navigationBarTranslucent?: boolean;
|
|
11
11
|
onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;
|
|
12
|
+
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
12
13
|
onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;
|
|
14
|
+
onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;
|
|
13
15
|
}
|
|
14
16
|
declare const _default: HostComponent<NativeProps>;
|
|
15
17
|
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HostComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
3
|
+
import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
export interface NativeProps extends ViewProps {
|
|
5
|
+
interpolator?: WithDefault<'linear' | 'ios', 'linear'>;
|
|
6
|
+
allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;
|
|
7
|
+
allowToDragKeyboardFromShownStateBySwipes?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: HostComponent<NativeProps>;
|
|
10
|
+
export default _default;
|
|
@@ -1,32 +1,49 @@
|
|
|
1
1
|
import type { NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
2
|
-
export
|
|
2
|
+
export type NativeEvent = {
|
|
3
3
|
progress: number;
|
|
4
4
|
height: number;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type EventWithName<T> = {
|
|
7
7
|
eventName: string;
|
|
8
8
|
} & T;
|
|
9
|
-
export
|
|
9
|
+
export type KeyboardControllerProps = {
|
|
10
10
|
onKeyboardMoveStart?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
11
11
|
onKeyboardMove?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
12
12
|
onKeyboardMoveEnd?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
13
|
+
onKeyboardMoveInteractive?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
13
14
|
onKeyboardMoveReanimated?: (e: NativeSyntheticEvent<EventWithName<NativeEvent>>) => void;
|
|
14
15
|
statusBarTranslucent?: boolean;
|
|
16
|
+
navigationBarTranslucent?: boolean;
|
|
15
17
|
} & ViewProps;
|
|
16
|
-
export
|
|
18
|
+
export type KeyboardGestureAreaProps = {
|
|
19
|
+
interpolator: 'ios' | 'linear';
|
|
20
|
+
/**
|
|
21
|
+
* Whether to allow to show a keyboard from dismissed state by swipe up.
|
|
22
|
+
* Default to `false`.
|
|
23
|
+
*/
|
|
24
|
+
allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to allow to control a keyboard by gestures. The strategy how
|
|
27
|
+
* it should be controlled is determined by `interpolator` property.
|
|
28
|
+
* Defaults to `true`.
|
|
29
|
+
*/
|
|
30
|
+
allowToDragKeyboardFromShownStateBySwipes?: boolean;
|
|
31
|
+
} & ViewProps;
|
|
32
|
+
export type KeyboardControllerModule = {
|
|
17
33
|
setDefaultMode: () => void;
|
|
18
34
|
setInputMode: (mode: number) => void;
|
|
19
35
|
addListener: (eventName: string) => void;
|
|
20
36
|
removeListeners: (count: number) => void;
|
|
21
37
|
};
|
|
22
|
-
export
|
|
23
|
-
export
|
|
38
|
+
export type KeyboardControllerEvents = 'keyboardWillShow' | 'keyboardDidShow' | 'keyboardWillHide' | 'keyboardDidHide';
|
|
39
|
+
export type KeyboardEventData = {
|
|
24
40
|
height: number;
|
|
25
41
|
};
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
onStart
|
|
29
|
-
onMove
|
|
30
|
-
onEnd
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
export type Handlers<T> = Record<string, T | undefined>;
|
|
43
|
+
export type KeyboardHandler = Partial<{
|
|
44
|
+
onStart: (e: NativeEvent) => void;
|
|
45
|
+
onMove: (e: NativeEvent) => void;
|
|
46
|
+
onEnd: (e: NativeEvent) => void;
|
|
47
|
+
onInteractive: (e: NativeEvent) => void;
|
|
48
|
+
}>;
|
|
49
|
+
export type KeyboardHandlers = Handlers<KeyboardHandler>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Keyboard manager which works in identical way on both iOS and Android",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -56,24 +56,23 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@commitlint/config-conventional": "^11.0.0",
|
|
59
|
-
"@react-native-community/eslint-config": "^2.0
|
|
59
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
60
60
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
61
|
-
"@types/jest": "^
|
|
62
|
-
"@types/react": "^18.0.
|
|
63
|
-
"@types/react-native": "0.70.6",
|
|
64
|
-
"commitlint": "^11.0.0",
|
|
61
|
+
"@types/jest": "^29.2.1",
|
|
62
|
+
"@types/react": "^18.0.24",
|
|
65
63
|
"clang-format": "^1.8.0",
|
|
66
|
-
"
|
|
64
|
+
"commitlint": "^11.0.0",
|
|
65
|
+
"eslint": "^8.19.0",
|
|
67
66
|
"eslint-config-prettier": "^7.0.0",
|
|
68
67
|
"eslint-plugin-prettier": "^3.1.3",
|
|
69
68
|
"husky": "^6.0.0",
|
|
70
|
-
"jest": "^
|
|
69
|
+
"jest": "^29.2.1",
|
|
71
70
|
"pod-install": "^0.1.0",
|
|
72
|
-
"prettier": "^2.
|
|
73
|
-
"react": "18.
|
|
74
|
-
"react-native": "0.
|
|
71
|
+
"prettier": "^2.4.1",
|
|
72
|
+
"react": "18.2.0",
|
|
73
|
+
"react-native": "0.71.3",
|
|
75
74
|
"react-native-builder-bob": "^0.18.0",
|
|
76
|
-
"react-native-reanimated": "2.
|
|
75
|
+
"react-native-reanimated": "2.14.4",
|
|
77
76
|
"release-it": "^14.2.2",
|
|
78
77
|
"typescript": "^4.8.4"
|
|
79
78
|
},
|
package/src/animated.tsx
CHANGED
|
@@ -49,11 +49,20 @@ type KeyboardProviderProps = {
|
|
|
49
49
|
* @platform android
|
|
50
50
|
*/
|
|
51
51
|
statusBarTranslucent?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Set the value to `true`, if you use translucent navigation bar on Android.
|
|
54
|
+
* Defaults to `false`.
|
|
55
|
+
*
|
|
56
|
+
* @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119
|
|
57
|
+
* @platform android
|
|
58
|
+
*/
|
|
59
|
+
navigationBarTranslucent?: boolean;
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
export const KeyboardProvider = ({
|
|
55
63
|
children,
|
|
56
64
|
statusBarTranslucent,
|
|
65
|
+
navigationBarTranslucent,
|
|
57
66
|
}: KeyboardProviderProps) => {
|
|
58
67
|
// animated values
|
|
59
68
|
const progress = useAnimatedValue(0);
|
|
@@ -121,6 +130,12 @@ export const KeyboardProvider = ({
|
|
|
121
130
|
|
|
122
131
|
broadcast('onEnd', event);
|
|
123
132
|
},
|
|
133
|
+
onKeyboardMoveInteractive: (event: NativeEvent) => {
|
|
134
|
+
'worklet';
|
|
135
|
+
|
|
136
|
+
updateSharedValues(event, ['android', 'ios']);
|
|
137
|
+
broadcast('onInteractive', event);
|
|
138
|
+
},
|
|
124
139
|
},
|
|
125
140
|
[]
|
|
126
141
|
);
|
|
@@ -131,6 +146,8 @@ export const KeyboardProvider = ({
|
|
|
131
146
|
onKeyboardMoveReanimated={handler}
|
|
132
147
|
onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}
|
|
133
148
|
onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}
|
|
149
|
+
onKeyboardMoveInteractive={onKeyboardMove}
|
|
150
|
+
navigationBarTranslucent={navigationBarTranslucent}
|
|
134
151
|
statusBarTranslucent={statusBarTranslucent}
|
|
135
152
|
style={styles.container}
|
|
136
153
|
>
|
package/src/internal.ts
CHANGED
|
@@ -11,6 +11,7 @@ export function useAnimatedKeyboardHandler<
|
|
|
11
11
|
onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;
|
|
12
12
|
onKeyboardMove?: (e: NativeEvent, context: TContext) => void;
|
|
13
13
|
onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;
|
|
14
|
+
onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;
|
|
14
15
|
},
|
|
15
16
|
dependencies?: ReadonlyArray<unknown>
|
|
16
17
|
) {
|
|
@@ -19,8 +20,12 @@ export function useAnimatedKeyboardHandler<
|
|
|
19
20
|
return useEvent(
|
|
20
21
|
(event: EventWithName<NativeEvent>) => {
|
|
21
22
|
'worklet';
|
|
22
|
-
const {
|
|
23
|
-
|
|
23
|
+
const {
|
|
24
|
+
onKeyboardMoveStart,
|
|
25
|
+
onKeyboardMove,
|
|
26
|
+
onKeyboardMoveEnd,
|
|
27
|
+
onKeyboardMoveInteractive,
|
|
28
|
+
} = handlers;
|
|
24
29
|
|
|
25
30
|
if (
|
|
26
31
|
onKeyboardMoveStart &&
|
|
@@ -36,8 +41,20 @@ export function useAnimatedKeyboardHandler<
|
|
|
36
41
|
if (onKeyboardMoveEnd && event.eventName.endsWith('onKeyboardMoveEnd')) {
|
|
37
42
|
onKeyboardMoveEnd(event, context);
|
|
38
43
|
}
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
onKeyboardMoveInteractive &&
|
|
47
|
+
event.eventName.endsWith('onKeyboardMoveInteractive')
|
|
48
|
+
) {
|
|
49
|
+
onKeyboardMoveInteractive(event, context);
|
|
50
|
+
}
|
|
39
51
|
},
|
|
40
|
-
[
|
|
52
|
+
[
|
|
53
|
+
'onKeyboardMoveStart',
|
|
54
|
+
'onKeyboardMove',
|
|
55
|
+
'onKeyboardMoveEnd',
|
|
56
|
+
'onKeyboardMoveInteractive',
|
|
57
|
+
],
|
|
41
58
|
doDependenciesDiffer
|
|
42
59
|
);
|
|
43
60
|
}
|
package/src/native.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
KeyboardControllerModule,
|
|
6
6
|
KeyboardControllerProps,
|
|
7
7
|
KeyboardEventData,
|
|
8
|
+
KeyboardGestureAreaProps,
|
|
8
9
|
} from './types';
|
|
9
10
|
|
|
10
11
|
const LINKING_ERROR =
|
|
@@ -56,3 +57,7 @@ export const KeyboardEvents = {
|
|
|
56
57
|
};
|
|
57
58
|
export const KeyboardControllerView: React.FC<KeyboardControllerProps> =
|
|
58
59
|
require('./specs/KeyboardControllerViewNativeComponent').default;
|
|
60
|
+
export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> =
|
|
61
|
+
Platform.OS === 'android' && Platform.Version >= 30
|
|
62
|
+
? require('./specs/KeyboardGestureAreaNativeComponent').default
|
|
63
|
+
: ({ children }: KeyboardGestureAreaProps) => children;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { HostComponent } from 'react-native';
|
|
2
|
-
// @ts-expect-error - no type definition
|
|
3
2
|
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
4
3
|
import type {
|
|
5
4
|
DirectEventHandler,
|
|
6
|
-
|
|
7
|
-
Int32,
|
|
5
|
+
Double,
|
|
8
6
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
9
7
|
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
10
8
|
|
|
11
9
|
type KeyboardMoveEvent = Readonly<{
|
|
12
|
-
height:
|
|
13
|
-
progress:
|
|
10
|
+
height: Double;
|
|
11
|
+
progress: Double;
|
|
14
12
|
}>;
|
|
15
13
|
|
|
16
14
|
export interface NativeProps extends ViewProps {
|
|
17
15
|
// props
|
|
18
16
|
statusBarTranslucent?: boolean;
|
|
17
|
+
navigationBarTranslucent?: boolean;
|
|
19
18
|
// callbacks
|
|
20
|
-
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
21
19
|
onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;
|
|
20
|
+
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
22
21
|
onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;
|
|
22
|
+
onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export default codegenNativeComponent<NativeProps>(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HostComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
3
|
+
import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
5
|
+
|
|
6
|
+
export interface NativeProps extends ViewProps {
|
|
7
|
+
interpolator?: WithDefault<'linear' | 'ios', 'linear'>;
|
|
8
|
+
allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;
|
|
9
|
+
allowToDragKeyboardFromShownStateBySwipes?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default codegenNativeComponent<NativeProps>('KeyboardGestureArea', {
|
|
13
|
+
excludedPlatforms: ['iOS'],
|
|
14
|
+
}) as HostComponent<NativeProps>;
|