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.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +9 -2
  3. package/android/gradle.properties +2 -2
  4. package/android/react-native-helpers.gradle +48 -0
  5. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +44 -0
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/InteractiveKeyboardProvider.kt +6 -0
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +27 -13
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationController.kt +394 -0
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +1 -1
  10. package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +2 -2
  11. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/Float.kt +4 -4
  12. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +21 -0
  13. package/android/src/main/java/com/reactnativekeyboardcontroller/interpolators/Interpolator.kt +14 -0
  14. package/android/src/main/java/com/reactnativekeyboardcontroller/interpolators/IosInterpolator.kt +18 -0
  15. package/android/src/main/java/com/reactnativekeyboardcontroller/interpolators/LinearInterpolator.kt +11 -0
  16. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -0
  17. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +27 -0
  18. package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +192 -0
  19. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +33 -0
  20. package/ios/KeyboardControllerView.mm +10 -3
  21. package/ios/KeyboardControllerViewManager.mm +1 -0
  22. package/ios/KeyboardControllerViewManager.swift +1 -0
  23. package/ios/KeyboardMovementObserver.swift +78 -4
  24. package/jest/index.js +1 -0
  25. package/lib/commonjs/animated.js +13 -19
  26. package/lib/commonjs/animated.js.map +1 -1
  27. package/lib/commonjs/context.js +0 -3
  28. package/lib/commonjs/context.js.map +1 -1
  29. package/lib/commonjs/hooks.js +0 -13
  30. package/lib/commonjs/hooks.js.map +1 -1
  31. package/lib/commonjs/index.js +0 -13
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/internal.js +13 -22
  34. package/lib/commonjs/internal.js.map +1 -1
  35. package/lib/commonjs/monkey-patch.js +3 -12
  36. package/lib/commonjs/monkey-patch.js.map +1 -1
  37. package/lib/commonjs/native.js +10 -10
  38. package/lib/commonjs/native.js.map +1 -1
  39. package/lib/commonjs/replicas.js +3 -19
  40. package/lib/commonjs/replicas.js.map +1 -1
  41. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +0 -5
  42. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  43. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +13 -0
  44. package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  45. package/lib/commonjs/specs/NativeKeyboardController.js +0 -3
  46. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  47. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +0 -3
  48. package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
  49. package/lib/commonjs/types.js.map +1 -1
  50. package/lib/commonjs/utils.js +0 -2
  51. package/lib/commonjs/utils.js.map +1 -1
  52. package/lib/module/animated.js +13 -7
  53. package/lib/module/animated.js.map +1 -1
  54. package/lib/module/context.js.map +1 -1
  55. package/lib/module/hooks.js.map +1 -1
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/internal.js +13 -16
  58. package/lib/module/internal.js.map +1 -1
  59. package/lib/module/monkey-patch.js +4 -10
  60. package/lib/module/monkey-patch.js.map +1 -1
  61. package/lib/module/native.js +8 -5
  62. package/lib/module/native.js.map +1 -1
  63. package/lib/module/replicas.js +3 -5
  64. package/lib/module/replicas.js.map +1 -1
  65. package/lib/module/specs/KeyboardControllerViewNativeComponent.js +0 -1
  66. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  67. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
  68. package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
  69. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  70. package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
  71. package/lib/module/types.js.map +1 -1
  72. package/lib/module/utils.js.map +1 -1
  73. package/lib/typescript/animated.d.ts +1 -1
  74. package/lib/typescript/context.d.ts +3 -3
  75. package/lib/typescript/internal.d.ts +1 -0
  76. package/lib/typescript/native.d.ts +2 -1
  77. package/lib/typescript/replicas.d.ts +1 -1
  78. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +6 -5
  79. package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +10 -0
  80. package/lib/typescript/types.d.ts +29 -13
  81. package/package.json +11 -12
  82. package/src/animated.tsx +7 -0
  83. package/src/internal.ts +20 -3
  84. package/src/native.ts +5 -0
  85. package/src/specs/KeyboardControllerViewNativeComponent.ts +5 -6
  86. package/src/specs/KeyboardGestureAreaNativeComponent.ts +14 -0
  87. package/src/types.ts +24 -5
@@ -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'; // cubic-bezier(.17,.67,.34,.94)
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,MAAT,EAAiBC,SAAjB,EAA4BC,OAA5B,QAA2C,OAA3C;AACA,SAASC,QAAT,EAAmBC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EAZM,CAAT;EAcA,OAAO;IAAElB,MAAF;IAAUE;EAAV,CAAP;AACD,CAxCM;AA0CP,OAAO,MAAMmC,2BAA2B,GACtCpD,QAAQ,CAACW,EAAT,KAAgB,KAAhB,GACI8B,qCADJ,GAEIlC,8BAHC"}
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,MAAM,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AACnE,SACEC,OAAO,EACPC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,EACdC,kBAAkB,EAClBC,UAAU,QACL,yBAAyB;AAChC,SAASC,8BAA8B,QAAQ,SAAS;AAExD,SAASC,qBAAqB,EAAEC,kBAAkB,QAAQ,UAAU;AAEpE,MAAMC,oBAAoB,GAAGV,QAAQ,CAACW,EAAE,KAAK,KAAK,GAAG,MAAM,GAAG,KAAK;;AAEnE;AACA,OAAO,MAAMC,oBAAoB,GAAGd,MAAM,CAACe,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAMnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,MAAyB;EAClE,MAAMC,MAAM,GAAGrB,MAAM,CAAC,IAAIG,QAAQ,CAACmB,KAAK,CAAC,CAAC,CAAC,CAAC;EAC5C,MAAMC,Q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,MAAM,CAAC4B,KAAK,GAAGrC,UAAU,CAACwC,eAAe,EAAEZ,iBAAiB,CAAC;IAC/D;EACF,CAAC,EACD,EAAE,CACH;EAEDvC,SAAS,CAAC,MAAM;IACd,MAAMuD,IAAI,GAAGnD,QAAQ,CAACyB,WAAW,CAAC,kBAAkB,EAAGC,CAAC,IAAK;MAC3DxB,OAAO,CAAC2C,OAAO,CAAC,CAAC,CAACnB,CAAC,CAACG,cAAc,CAACb,MAAM,CAAC;IAC5C,CAAC,CAAC;IACF,MAAMoC,IAAI,GAAGpD,QAAQ,CAACyB,WAAW,CAAC,kBAAkB,EAAE,MAAM;MAC1DvB,OAAO,CAAC2C,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,MAAM;MACXM,IAAI,CAACjB,MAAM,EAAE;MACbkB,IAAI,CAAClB,MAAM,EAAE;IACf,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAElB,MAAM;IAAEE;EAAS,CAAC;AAC7B,CAAC;AAED,OAAO,MAAMmC,2BAA2B,GACtCpD,QAAQ,CAACW,EAAE,KAAK,KAAK,GACjB8B,qCAAqC,GACrClC,8BAA8B"}
@@ -1,4 +1,3 @@
1
- // @ts-expect-error - no type definition
2
1
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
2
  export default codegenNativeComponent('KeyboardControllerView');
4
3
  //# sourceMappingURL=KeyboardControllerViewNativeComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["codegenNativeComponent"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import type { HostComponent } from 'react-native';\n// @ts-expect-error - no type definition\nimport type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';\nimport type {\n DirectEventHandler,\n Float,\n Int32,\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\n\ntype KeyboardMoveEvent = Readonly<{\n height: Int32;\n progress: Float;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n 'KeyboardControllerView'\n) as HostComponent<NativeProps>;\n"],"mappings":"AACA;AAOA,OAAOA,sBAAP,MAAmC,yDAAnC;AAiBA,eAAeA,sBAAsB,CACnC,wBADmC,CAArC"}
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,5 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ export default codegenNativeComponent('KeyboardGestureArea', {
3
+ excludedPlatforms: ['iOS']
4
+ });
5
+ //# sourceMappingURL=KeyboardGestureAreaNativeComponent.js.map
@@ -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,mBAAT,QAAoC,cAApC;AAcA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,oBAA9B,CAAf"}
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,mBAAT,QAAoC,cAApC;AAWA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,wBAA9B,CAAf"}
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"}
@@ -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?: (e: NativeEvent) => void;\n onMove?: (e: NativeEvent) => void;\n onEnd?: (e: NativeEvent) => void;\n};\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\n"],"mappings":""}
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":""}
@@ -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,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAC,CAAlC,CAAnB"}
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
- declare type KeyboardProviderProps = {
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.
@@ -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 declare type AnimatedContext = {
5
+ export type AnimatedContext = {
6
6
  progress: Animated.Value;
7
7
  height: Animated.AnimatedMultiplication<number>;
8
8
  };
9
- export declare type ReanimatedContext = {
9
+ export type ReanimatedContext = {
10
10
  progress: SharedValue<number>;
11
11
  height: SharedValue<number>;
12
12
  };
13
- export declare type KeyboardAnimationContext = {
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
- declare type KeyboardAnimation = {
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, Float, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
4
- declare type KeyboardMoveEvent = Readonly<{
5
- height: Int32;
6
- progress: Float;
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 declare type NativeEvent = {
2
+ export type NativeEvent = {
3
3
  progress: number;
4
4
  height: number;
5
5
  };
6
- export declare type EventWithName<T> = {
6
+ export type EventWithName<T> = {
7
7
  eventName: string;
8
8
  } & T;
9
- export declare type KeyboardControllerProps = {
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 declare type KeyboardControllerModule = {
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 declare type KeyboardControllerEvents = 'keyboardWillShow' | 'keyboardDidShow' | 'keyboardWillHide' | 'keyboardDidHide';
24
- export declare type KeyboardEventData = {
38
+ export type KeyboardControllerEvents = 'keyboardWillShow' | 'keyboardDidShow' | 'keyboardWillHide' | 'keyboardDidHide';
39
+ export type KeyboardEventData = {
25
40
  height: number;
26
41
  };
27
- export declare type Handlers<T> = Record<string, T | undefined>;
28
- export declare type KeyboardHandler = {
29
- onStart?: (e: NativeEvent) => void;
30
- onMove?: (e: NativeEvent) => void;
31
- onEnd?: (e: NativeEvent) => void;
32
- };
33
- export declare type KeyboardHandlers = Handlers<KeyboardHandler>;
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.4.4",
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.0",
59
+ "@react-native-community/eslint-config": "^3.2.0",
60
60
  "@release-it/conventional-changelog": "^2.0.0",
61
- "@types/jest": "^27.4.1",
62
- "@types/react": "^18.0.21",
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
- "eslint": "^7.2.0",
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": "^27.5.1",
69
+ "jest": "^29.2.1",
71
70
  "pod-install": "^0.1.0",
72
- "prettier": "^2.6.2",
73
- "react": "18.1.0",
74
- "react-native": "0.70.2",
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.10.0",
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 { onKeyboardMoveStart, onKeyboardMove, onKeyboardMoveEnd } =
23
- handlers;
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
- ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd'],
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
- Float,
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: Int32;
13
- progress: Float;
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?: (e: NativeEvent) => void;
58
- onMove?: (e: NativeEvent) => void;
59
- onEnd?: (e: NativeEvent) => void;
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>;