react-native-keyboard-controller 1.4.4 → 1.5.1
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/KeyboardGestureAreaViewManager.kt +44 -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 +2 -0
- 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/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 +13 -19
- 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 +13 -7
- 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 +1 -1
- 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 +6 -5
- package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +10 -0
- package/lib/typescript/types.d.ts +29 -13
- package/package.json +11 -12
- package/src/animated.tsx +7 -0
- package/src/internal.ts +20 -3
- package/src/native.ts +5 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +5 -6
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +14 -0
- package/src/types.ts +24 -5
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 showOnSwipeUp?: boolean;\n enableSwipeToDismiss?: 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 navigationBarTranslucent?: 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 showOnSwipeUp?: 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 enableSwipeToDismiss?: 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"}
|
|
@@ -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,16 +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
|
-
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
12
11
|
onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;
|
|
12
|
+
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
13
13
|
onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;
|
|
14
|
+
onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;
|
|
14
15
|
}
|
|
15
16
|
declare const _default: HostComponent<NativeProps>;
|
|
16
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
|
+
showOnSwipeUp?: boolean;
|
|
7
|
+
enableSwipeToDismiss?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: HostComponent<NativeProps>;
|
|
10
|
+
export default _default;
|
|
@@ -1,33 +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;
|
|
15
16
|
navigationBarTranslucent?: boolean;
|
|
16
17
|
} & ViewProps;
|
|
17
|
-
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
|
+
showOnSwipeUp?: 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
|
+
enableSwipeToDismiss?: boolean;
|
|
31
|
+
} & ViewProps;
|
|
32
|
+
export type KeyboardControllerModule = {
|
|
18
33
|
setDefaultMode: () => void;
|
|
19
34
|
setInputMode: (mode: number) => void;
|
|
20
35
|
addListener: (eventName: string) => void;
|
|
21
36
|
removeListeners: (count: number) => void;
|
|
22
37
|
};
|
|
23
|
-
export
|
|
24
|
-
export
|
|
38
|
+
export type KeyboardControllerEvents = 'keyboardWillShow' | 'keyboardDidShow' | 'keyboardWillHide' | 'keyboardDidHide';
|
|
39
|
+
export type KeyboardEventData = {
|
|
25
40
|
height: number;
|
|
26
41
|
};
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
onStart
|
|
30
|
-
onMove
|
|
31
|
-
onEnd
|
|
32
|
-
|
|
33
|
-
|
|
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.1",
|
|
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
|
@@ -130,6 +130,12 @@ export const KeyboardProvider = ({
|
|
|
130
130
|
|
|
131
131
|
broadcast('onEnd', event);
|
|
132
132
|
},
|
|
133
|
+
onKeyboardMoveInteractive: (event: NativeEvent) => {
|
|
134
|
+
'worklet';
|
|
135
|
+
|
|
136
|
+
updateSharedValues(event, ['android', 'ios']);
|
|
137
|
+
broadcast('onInteractive', event);
|
|
138
|
+
},
|
|
133
139
|
},
|
|
134
140
|
[]
|
|
135
141
|
);
|
|
@@ -140,6 +146,7 @@ export const KeyboardProvider = ({
|
|
|
140
146
|
onKeyboardMoveReanimated={handler}
|
|
141
147
|
onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}
|
|
142
148
|
onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}
|
|
149
|
+
onKeyboardMoveInteractive={onKeyboardMove}
|
|
143
150
|
navigationBarTranslucent={navigationBarTranslucent}
|
|
144
151
|
statusBarTranslucent={statusBarTranslucent}
|
|
145
152
|
style={styles.container}
|
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,16 +1,14 @@
|
|
|
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 {
|
|
@@ -18,9 +16,10 @@ export interface NativeProps extends ViewProps {
|
|
|
18
16
|
statusBarTranslucent?: boolean;
|
|
19
17
|
navigationBarTranslucent?: boolean;
|
|
20
18
|
// callbacks
|
|
21
|
-
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
22
19
|
onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;
|
|
20
|
+
onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;
|
|
23
21
|
onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;
|
|
22
|
+
onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
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
|
+
showOnSwipeUp?: boolean;
|
|
9
|
+
enableSwipeToDismiss?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default codegenNativeComponent<NativeProps>('KeyboardGestureArea', {
|
|
13
|
+
excludedPlatforms: ['iOS'],
|
|
14
|
+
}) as HostComponent<NativeProps>;
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,9 @@ export type KeyboardControllerProps = {
|
|
|
22
22
|
onKeyboardMoveEnd?: (
|
|
23
23
|
e: NativeSyntheticEvent<EventWithName<NativeEvent>>
|
|
24
24
|
) => void;
|
|
25
|
+
onKeyboardMoveInteractive?: (
|
|
26
|
+
e: NativeSyntheticEvent<EventWithName<NativeEvent>>
|
|
27
|
+
) => void;
|
|
25
28
|
// fake prop used to activate reanimated bindings
|
|
26
29
|
onKeyboardMoveReanimated?: (
|
|
27
30
|
e: NativeSyntheticEvent<EventWithName<NativeEvent>>
|
|
@@ -30,6 +33,21 @@ export type KeyboardControllerProps = {
|
|
|
30
33
|
navigationBarTranslucent?: boolean;
|
|
31
34
|
} & ViewProps;
|
|
32
35
|
|
|
36
|
+
export type KeyboardGestureAreaProps = {
|
|
37
|
+
interpolator: 'ios' | 'linear';
|
|
38
|
+
/**
|
|
39
|
+
* Whether to allow to show a keyboard from dismissed state by swipe up.
|
|
40
|
+
* Default to `false`.
|
|
41
|
+
*/
|
|
42
|
+
showOnSwipeUp?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether to allow to control a keyboard by gestures. The strategy how
|
|
45
|
+
* it should be controlled is determined by `interpolator` property.
|
|
46
|
+
* Defaults to `true`.
|
|
47
|
+
*/
|
|
48
|
+
enableSwipeToDismiss?: boolean;
|
|
49
|
+
} & ViewProps;
|
|
50
|
+
|
|
33
51
|
export type KeyboardControllerModule = {
|
|
34
52
|
// android only
|
|
35
53
|
setDefaultMode: () => void;
|
|
@@ -53,9 +71,10 @@ export type KeyboardEventData = {
|
|
|
53
71
|
// package types
|
|
54
72
|
|
|
55
73
|
export type Handlers<T> = Record<string, T | undefined>;
|
|
56
|
-
export type KeyboardHandler = {
|
|
57
|
-
onStart
|
|
58
|
-
onMove
|
|
59
|
-
onEnd
|
|
60
|
-
|
|
74
|
+
export type KeyboardHandler = Partial<{
|
|
75
|
+
onStart: (e: NativeEvent) => void;
|
|
76
|
+
onMove: (e: NativeEvent) => void;
|
|
77
|
+
onEnd: (e: NativeEvent) => void;
|
|
78
|
+
onInteractive: (e: NativeEvent) => void;
|
|
79
|
+
}>;
|
|
61
80
|
export type KeyboardHandlers = Handlers<KeyboardHandler>;
|