react-native-keyboard-controller 1.9.5 → 1.10.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.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +20 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +36 -0
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt +7 -0
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +17 -0
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +12 -0
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -0
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +13 -0
  10. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
  11. package/ios/KeyboardController.xcodeproj/project.pbxproj +10 -0
  12. package/ios/KeyboardControllerModule.mm +14 -0
  13. package/ios/events/FocusedInputTextChangedEvent.h +16 -0
  14. package/ios/events/FocusedInputTextChangedEvent.m +72 -0
  15. package/ios/observers/FocusedInputObserver.swift +29 -14
  16. package/ios/observers/TextChangeObserver.swift +41 -0
  17. package/ios/views/KeyboardControllerView.mm +53 -31
  18. package/ios/views/KeyboardControllerViewManager.mm +1 -0
  19. package/ios/views/KeyboardControllerViewManager.swift +21 -10
  20. package/jest/index.js +2 -0
  21. package/lib/commonjs/animated.js +20 -14
  22. package/lib/commonjs/animated.js.map +1 -1
  23. package/lib/commonjs/bindings.js +1 -0
  24. package/lib/commonjs/bindings.js.map +1 -1
  25. package/lib/commonjs/components/KeyboardAvoidingView/index.js +7 -4
  26. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  27. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +199 -0
  28. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
  29. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +100 -0
  30. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  31. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +28 -0
  32. package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
  33. package/lib/commonjs/components/KeyboardStickyView/index.js +0 -1
  34. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  35. package/lib/commonjs/components/index.js +7 -0
  36. package/lib/commonjs/components/index.js.map +1 -1
  37. package/lib/commonjs/context.js +2 -1
  38. package/lib/commonjs/context.js.map +1 -1
  39. package/lib/commonjs/hooks.js +17 -2
  40. package/lib/commonjs/hooks.js.map +1 -1
  41. package/lib/commonjs/index.js +8 -1
  42. package/lib/commonjs/index.js.map +1 -1
  43. package/lib/commonjs/internal.js +2 -5
  44. package/lib/commonjs/internal.js.map +1 -1
  45. package/lib/commonjs/reanimated.js +5 -3
  46. package/lib/commonjs/reanimated.js.map +1 -1
  47. package/lib/commonjs/reanimated.native.js +20 -3
  48. package/lib/commonjs/reanimated.native.js.map +1 -1
  49. package/lib/commonjs/replicas.js +3 -1
  50. package/lib/commonjs/replicas.js.map +1 -1
  51. package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  52. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  53. package/lib/commonjs/types.js.map +1 -1
  54. package/lib/module/animated.js +21 -15
  55. package/lib/module/animated.js.map +1 -1
  56. package/lib/module/bindings.js +1 -0
  57. package/lib/module/bindings.js.map +1 -1
  58. package/lib/module/components/KeyboardAvoidingView/index.js +8 -5
  59. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  60. package/lib/module/components/KeyboardAwareScrollView/index.js +190 -0
  61. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
  62. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +93 -0
  63. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
  64. package/lib/module/components/KeyboardAwareScrollView/utils.js +21 -0
  65. package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
  66. package/lib/module/components/KeyboardStickyView/index.js +0 -1
  67. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  68. package/lib/module/components/index.js +1 -0
  69. package/lib/module/components/index.js.map +1 -1
  70. package/lib/module/context.js +2 -1
  71. package/lib/module/context.js.map +1 -1
  72. package/lib/module/hooks.js +16 -2
  73. package/lib/module/hooks.js.map +1 -1
  74. package/lib/module/index.js +1 -1
  75. package/lib/module/index.js.map +1 -1
  76. package/lib/module/internal.js +2 -5
  77. package/lib/module/internal.js.map +1 -1
  78. package/lib/module/reanimated.js +2 -1
  79. package/lib/module/reanimated.js.map +1 -1
  80. package/lib/module/reanimated.native.js +17 -1
  81. package/lib/module/reanimated.native.js.map +1 -1
  82. package/lib/module/replicas.js +5 -3
  83. package/lib/module/replicas.js.map +1 -1
  84. package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
  85. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  86. package/lib/module/types.js.map +1 -1
  87. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +45 -0
  88. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
  89. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -0
  90. package/lib/typescript/components/index.d.ts +1 -0
  91. package/lib/typescript/context.d.ts +3 -2
  92. package/lib/typescript/hooks.d.ts +2 -1
  93. package/lib/typescript/index.d.ts +1 -1
  94. package/lib/typescript/internal.d.ts +8 -5
  95. package/lib/typescript/reanimated.d.ts +3 -2
  96. package/lib/typescript/reanimated.native.d.ts +3 -2
  97. package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
  98. package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
  99. package/lib/typescript/types.d.ts +15 -2
  100. package/package.json +5 -2
  101. package/react-native-keyboard-controller.podspec +1 -1
  102. package/src/animated.tsx +27 -10
  103. package/src/bindings.ts +1 -0
  104. package/src/components/KeyboardAvoidingView/index.tsx +7 -5
  105. package/src/components/KeyboardAwareScrollView/index.tsx +262 -0
  106. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +123 -0
  107. package/src/components/KeyboardAwareScrollView/utils.ts +26 -0
  108. package/src/components/KeyboardStickyView/index.tsx +1 -6
  109. package/src/components/index.ts +1 -0
  110. package/src/context.ts +9 -3
  111. package/src/hooks.ts +20 -3
  112. package/src/index.ts +5 -1
  113. package/src/internal.ts +17 -8
  114. package/src/reanimated.native.ts +27 -2
  115. package/src/reanimated.ts +8 -2
  116. package/src/replicas.ts +4 -3
  117. package/src/specs/KeyboardControllerViewNativeComponent.ts +7 -0
  118. package/src/specs/NativeKeyboardController.ts +1 -0
  119. package/src/types.ts +28 -2
@@ -5,7 +5,7 @@ import { KeyboardControllerView } from './bindings';
5
5
  import { KeyboardContext } from './context';
6
6
  import { useAnimatedValue, useSharedHandlers } from './internal';
7
7
  import { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';
8
- import { useAnimatedKeyboardHandler, useFocusedInputHandler } from './reanimated';
8
+ import { useAnimatedKeyboardHandler, useFocusedInputLayoutHandler, useFocusedInputTextHandler } from './reanimated';
9
9
  const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(Animated.createAnimatedComponent(KeyboardControllerView));
10
10
  const styles = StyleSheet.create({
11
11
  container: {
@@ -23,6 +23,7 @@ export const KeyboardProvider = _ref => {
23
23
  navigationBarTranslucent,
24
24
  enabled: initiallyEnabled = true
25
25
  } = _ref;
26
+ // state
26
27
  const [enabled, setEnabled] = useState(initiallyEnabled);
27
28
  // animated values
28
29
  const progress = useAnimatedValue(0);
@@ -31,10 +32,8 @@ export const KeyboardProvider = _ref => {
31
32
  const progressSV = useSharedValue(0);
32
33
  const heightSV = useSharedValue(0);
33
34
  const layout = useSharedValue(null);
34
- const {
35
- setHandlers,
36
- broadcast
37
- } = useSharedHandlers();
35
+ const [setKeyboardHandlers, broadcastKeyboardEvents] = useSharedHandlers();
36
+ const [setInputHandlers, broadcastInputEvents] = useSharedHandlers();
38
37
  // memo
39
38
  const context = useMemo(() => ({
40
39
  enabled,
@@ -47,7 +46,8 @@ export const KeyboardProvider = _ref => {
47
46
  height: heightSV
48
47
  },
49
48
  layout,
50
- setHandlers,
49
+ setKeyboardHandlers,
50
+ setInputHandlers,
51
51
  setEnabled
52
52
  }), [enabled]);
53
53
  const style = useMemo(() => [styles.hidden, {
@@ -78,28 +78,28 @@ export const KeyboardProvider = _ref => {
78
78
  onKeyboardMoveStart: event => {
79
79
  'worklet';
80
80
 
81
- broadcast('onStart', event);
81
+ broadcastKeyboardEvents('onStart', event);
82
82
  updateSharedValues(event, ['ios']);
83
83
  },
84
84
  onKeyboardMove: event => {
85
85
  'worklet';
86
86
 
87
- broadcast('onMove', event);
87
+ broadcastKeyboardEvents('onMove', event);
88
88
  updateSharedValues(event, ['android']);
89
89
  },
90
90
  onKeyboardMoveEnd: event => {
91
91
  'worklet';
92
92
 
93
- broadcast('onEnd', event);
93
+ broadcastKeyboardEvents('onEnd', event);
94
94
  },
95
95
  onKeyboardMoveInteractive: event => {
96
96
  'worklet';
97
97
 
98
98
  updateSharedValues(event, ['android', 'ios']);
99
- broadcast('onInteractive', event);
99
+ broadcastKeyboardEvents('onInteractive', event);
100
100
  }
101
101
  }, []);
102
- const inputHandler = useFocusedInputHandler({
102
+ const inputLayoutHandler = useFocusedInputLayoutHandler({
103
103
  onFocusedInputLayoutChanged: e => {
104
104
  'worklet';
105
105
 
@@ -110,6 +110,13 @@ export const KeyboardProvider = _ref => {
110
110
  }
111
111
  }
112
112
  }, []);
113
+ const inputTextHandler = useFocusedInputTextHandler({
114
+ onFocusedInputTextChanged: e => {
115
+ 'worklet';
116
+
117
+ broadcastInputEvents('onChangeText', e);
118
+ }
119
+ }, []);
113
120
  // effects
114
121
  useEffect(() => {
115
122
  if (enabled) {
@@ -126,11 +133,10 @@ export const KeyboardProvider = _ref => {
126
133
  onKeyboardMoveStart: Platform.OS === 'ios' ? onKeyboardMove : undefined,
127
134
  onKeyboardMove: Platform.OS === 'android' ? onKeyboardMove : undefined,
128
135
  onKeyboardMoveInteractive: onKeyboardMove,
129
- onFocusedInputLayoutChangedReanimated: inputHandler,
136
+ onFocusedInputLayoutChangedReanimated: inputLayoutHandler,
137
+ onFocusedInputTextChangedReanimated: inputTextHandler,
130
138
  navigationBarTranslucent: navigationBarTranslucent,
131
- statusBarTranslucent: statusBarTranslucent
132
- // @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923
133
- ,
139
+ statusBarTranslucent: statusBarTranslucent,
134
140
  style: styles.container
135
141
  }, children), /*#__PURE__*/React.createElement(Animated.View, {
136
142
  // we are using this small hack, because if the component (where
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useMemo","useState","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","useAnimatedValue","useSharedHandlers","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputHandler","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","progress","height","progressSV","heightSV","layout","setHandlers","broadcast","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","OS","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputHandler","onFocusedInputLayoutChanged","e","target","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { Animated, Platform, StyleSheet } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardControllerView } from './bindings';\nimport { KeyboardContext } from './context';\nimport { useAnimatedValue, useSharedHandlers } from './internal';\nimport { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputHandler,\n} from './reanimated';\n\nimport type { KeyboardAnimationContext } from './context';\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\nimport type { ViewStyle } from 'react-native';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setHandlers,\n setEnabled,\n }),\n [enabled]\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcast('onInteractive', event);\n },\n },\n []\n );\n const inputHandler = useFocusedInputHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n 'worklet';\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n []\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC3D,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAC7D,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,YAAY;AAChE,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpE,SACEC,0BAA0B,EAC1BC,sBAAsB,QACjB,cAAc;AAWrB,MAAMC,8BAA8B,GAAGV,UAAU,CAACW,uBAAuB,CACvEd,QAAQ,CAACc,uBAAuB,CAC9BT,sBAAsB,CACvB,CACF;AAOD,MAAMU,MAAM,GAAGb,UAAU,CAACc,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,E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;;MAET,IAAIA,CAAC,CAACC,MAAM,KAAK,CAAC,CAAC,EAAE;QACnB3B,MAAM,CAACmB,KAAK,GAAGO,CAAC;MAClB,CAAC,MAAM;QACL1B,MAAM,CAACmB,KAAK,GAAG,IAAI;MACrB;IACF;EACF,CAAC,EACD,EAAE,CACH;EACD;EACAvD,SAAS,CAAC,MAAM;IACd,IAAI6B,OAAO,EAAE;MACXjB,gBAAgB,EAAE;IACpB,CAAC,MAAM;MACLC,iBAAiB,EAAE;IACrB;EACF,CAAC,EAAE,CAACgB,OAAO,CAAC,CAAC;EAEb,oBACE,oBAAC,eAAe,CAAC,QAAQ;IAAC,KAAK,EAAEU;EAAQ,gBACvC,oBAAC,8BAA8B;IAC7B,OAAO,EAAEV,OAAQ;IACjB,wBAAwB,EAAE2B,eAAgB;IAC1C,mBAAmB,EAAEpD,QAAQ,CAACkD,EAAE,KAAK,KAAK,GAAGP,cAAc,GAAGiB,SAAU;IACxE,cAAc,EAAE5D,QAAQ,CAACkD,EAAE,KAAK,SAAS,GAAGP,cAAc,GAAGiB,SAAU;IACvE,yBAAyB,EAAEjB,cAAe;IAC1C,qCAAqC,EAAEa,YAAa;IACpD,wBAAwB,EAAEhC,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAET,MAAM,CAACE;EAAU,GAEvBM,QAAQ,CACsB,eACjC,oBAAC,QAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEiB;EAAM,EACb,CACuB;AAE/B,CAAC"}
1
+ {"version":3,"names":["React","useEffect","useMemo","useState","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","useAnimatedValue","useSharedHandlers","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","useFocusedInputTextHandler","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","broadcastKeyboardEvents","setInputHandlers","broadcastInputEvents","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","OS","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","inputTextHandler","onFocusedInputTextChanged","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { Animated, Platform, StyleSheet } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardControllerView } from './bindings';\nimport { KeyboardContext } from './context';\nimport { useAnimatedValue, useSharedHandlers } from './internal';\nimport { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n useFocusedInputTextHandler,\n} from './reanimated';\n\nimport type { KeyboardAnimationContext } from './context';\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\nimport type { ViewStyle } from 'react-native';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const [setKeyboardHandlers, broadcastKeyboardEvents] =\n useSharedHandlers<KeyboardHandler>();\n const [setInputHandlers, broadcastInputEvents] =\n useSharedHandlers<FocusedInputHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled]\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcastKeyboardEvents('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcastKeyboardEvents('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcastKeyboardEvents('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcastKeyboardEvents('onInteractive', event);\n },\n },\n []\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n 'worklet';\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n []\n );\n const inputTextHandler = useFocusedInputTextHandler(\n {\n onFocusedInputTextChanged: (e) => {\n 'worklet';\n\n broadcastInputEvents('onChangeText', e);\n },\n },\n []\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n onFocusedInputTextChangedReanimated={inputTextHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}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;MACLC,iBAAiB,EAAE;IACrB;EACF,CAAC,EAAE,CAACiB,OAAO,CAAC,CAAC;EAEb,oBACE,oBAAC,eAAe,CAAC,QAAQ;IAAC,KAAK,EAAEY;EAAQ,gBACvC,oBAAC,8BAA8B;IAC7B,OAAO,EAAEZ,OAAQ;IACjB,wBAAwB,EAAE6B,eAAgB;IAC1C,mBAAmB,EAAEvD,QAAQ,CAACqD,EAAE,KAAK,KAAK,GAAGP,cAAc,GAAGmB,SAAU;IACxE,cAAc,EAAEjE,QAAQ,CAACqD,EAAE,KAAK,SAAS,GAAGP,cAAc,GAAGmB,SAAU;IACvE,yBAAyB,EAAEnB,cAAe;IAC1C,qCAAqC,EAAEa,kBAAmB;IAC1D,mCAAmC,EAAEI,gBAAiB;IACtD,wBAAwB,EAAEtC,wBAAyB;IACnD,oBAAoB,EAAED,oBAAqB;IAC3C,KAAK,EAAET,MAAM,CAACE;EAAU,GAEvBM,QAAQ,CACsB,eACjC,oBAAC,QAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEmB;EAAM,EACb,CACuB;AAE/B,CAAC"}
@@ -3,6 +3,7 @@ const NOOP = () => {};
3
3
  export const KeyboardController = {
4
4
  setDefaultMode: NOOP,
5
5
  setInputMode: NOOP,
6
+ dismiss: NOOP,
6
7
  addListener: NOOP,
7
8
  removeListeners: NOOP
8
9
  };
@@ -1 +1 @@
1
- {"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\nimport type { EmitterSubscription } from 'react-native';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAUnC,MAAMC,IAAI,GAAG,MAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,WAAW,EAAEJ,IAAI;EACjBK,eAAe,EAAEL;AACnB,CAAC;AACD,OAAO,MAAMM,cAAoC,GAAG;EAClDF,WAAW,EAAE,OAAO;IAAEG,MAAM,EAAEP;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMQ,sBAAsB,GACjCT,IAAoD;AACtD,OAAO,MAAMU,mBAAmB,GAC9BV,IAAqD"}
1
+ {"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\nimport type { EmitterSubscription } from 'react-native';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAUnC,MAAMC,IAAI,GAAG,MAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,WAAW,EAAEL,IAAI;EACjBM,eAAe,EAAEN;AACnB,CAAC;AACD,OAAO,MAAMO,cAAoC,GAAG;EAClDF,WAAW,EAAE,OAAO;IAAEG,MAAM,EAAER;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMS,sBAAsB,GACjCV,IAAoD;AACtD,OAAO,MAAMW,mBAAmB,GAC9BX,IAAqD"}
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import React, { forwardRef, useCallback, useMemo } from 'react';
3
3
  import { View, useWindowDimensions } from 'react-native';
4
- import Reanimated, { interpolate, runOnUI, useAnimatedStyle, useDerivedValue, useSharedValue, useWorkletCallback } from 'react-native-reanimated';
4
+ import Reanimated, { interpolate, runOnUI, useAnimatedStyle, useDerivedValue, useSharedValue } from 'react-native-reanimated';
5
5
  import { useKeyboardAnimation } from './hooks';
6
6
  const defaultLayout = {
7
7
  x: 0,
@@ -31,15 +31,19 @@ const KeyboardAvoidingView = /*#__PURE__*/forwardRef((_ref, ref) => {
31
31
  const {
32
32
  height: screenHeight
33
33
  } = useWindowDimensions();
34
- const relativeKeyboardHeight = useWorkletCallback(() => {
34
+ const relativeKeyboardHeight = useCallback(() => {
35
+ 'worklet';
36
+
35
37
  const keyboardY = screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;
36
38
  return Math.max(frame.value.y + frame.value.height - keyboardY, 0);
37
39
  }, [screenHeight, keyboardVerticalOffset]);
38
- const onLayoutWorklet = useWorkletCallback(layout => {
40
+ const onLayoutWorklet = useCallback(layout => {
41
+ 'worklet';
42
+
39
43
  if (keyboard.isClosed.value) {
40
44
  initialFrame.value = layout;
41
45
  }
42
- });
46
+ }, []);
43
47
  const onLayout = useCallback(e => {
44
48
  runOnUI(onLayoutWorklet)(e.nativeEvent.layout);
45
49
  onLayoutProps === null || onLayoutProps === void 0 ? void 0 : onLayoutProps(e);
@@ -81,7 +85,6 @@ const KeyboardAvoidingView = /*#__PURE__*/forwardRef((_ref, ref) => {
81
85
  }, children));
82
86
  }
83
87
  return /*#__PURE__*/React.createElement(Reanimated.View, _extends({
84
- // @ts-expect-error because `ref` from reanimated is not compatible with react-native
85
88
  ref: ref,
86
89
  onLayout: onLayout,
87
90
  style: combinedStyles
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useMemo","View","useWindowDimensions","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","useWorkletCallback","useKeyboardAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","ref","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","initialFrame","frame","value","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","e","nativeEvent","animatedStyle","bottom","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from 'react';\nimport { View, useWindowDimensions } from 'react-native';\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n} from 'react-native-reanimated';\n\nimport { useKeyboardAnimation } from './hooks';\n\nimport type { LayoutRectangle, ViewProps } from 'react-native';\n\ntype Props = {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: 'height' | 'position' | 'padding';\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps['style'];\n\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<View, React.PropsWithChildren<Props>>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useWorkletCallback(() => {\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n\n const onLayoutWorklet = useWorkletCallback((layout: LayoutRectangle) => {\n if (keyboard.isClosed.value) {\n initialFrame.value = layout;\n }\n });\n const onLayout = useCallback<NonNullable<ViewProps['onLayout']>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps]\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolate(\n keyboard.progress.value,\n [0, 1],\n [0, relativeKeyboardHeight()]\n );\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case 'height':\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case 'position':\n return { bottom: bottomHeight };\n\n case 'padding':\n return { paddingBottom: bottomHeight };\n\n default:\n return {};\n }\n }, [behavior, enabled, relativeKeyboardHeight]);\n const isPositionBehavior = behavior === 'position';\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle]\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n // @ts-expect-error because `ref` from reanimated is not compatible with react-native\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n }\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,EAAEC,mBAAmB,QAAQ,cAAc;AACxD,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,EACdC,kBAAkB,QACb,yBAAyB;AAEhC,SAASC,oBAAoB,QAAQ,SAAS;AA4B9C,MAAMC,aAA8B,GAAG;EACrCC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,gBAAGlB,UAAU,CACrC,OAWEmB,GAAG,KACA;EAAA,IAXH;IACEC,QAAQ;IACRC,QAAQ;IACRC,qBAAqB;IACrBC,OAAO,GAAG,IAAI;IACdC,sBAAsB,GAAG,CAAC;IAC1BC,KAAK;IACLC,QAAQ,EAAEC,aAAa;IACvB,GAAGC;EACL,CAAC;EAGD,MAAMC,YAAY,GAAGnB,cAAc,CAAyB,IAAI,CAAC;EACjE,MAAMoB,KAAK,GAAGrB,eAAe,CAAC,MAAMoB,YAAY,CAACE,KAAK,IAAIlB,aAAa,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AC5B,OAAO;YACLd,MAAM,EAAEa,KAAK,CAACC,KAAK,CAACd,MAAM,GAAG8B,YAAY;YACzCC,IAAI,EAAE;UACR,CAAC;QACH;QAEA,OAAO,CAAC,CAAC;MAEX,KAAK,UAAU;QACb,OAAO;UAAEH,MAAM,EAAEE;QAAa,CAAC;MAEjC,KAAK,SAAS;QACZ,OAAO;UAAEE,aAAa,EAAEF;QAAa,CAAC;MAExC;QACE,OAAO,CAAC,CAAC;IAAC;EAEhB,CAAC,EAAE,CAAC3B,QAAQ,EAAEG,OAAO,EAAEW,sBAAsB,CAAC,CAAC;EAC/C,MAAMgB,kBAAkB,GAAG9B,QAAQ,KAAK,UAAU;EAClD,MAAM+B,cAAc,GAAGD,kBAAkB,GAAG5B,qBAAqB,GAAGG,KAAK;EACzE,MAAM2B,cAAc,GAAGlD,OAAO,CAC5B,MAAM,CAACiD,cAAc,EAAEP,aAAa,CAAC,EACrC,CAACO,cAAc,EAAEP,aAAa,CAAC,CAChC;EAED,IAAIM,kBAAkB,EAAE;IACtB,oBACE,oBAAC,IAAI;MAAC,GAAG,EAAE/B,GAAI;MAAC,KAAK,EAAEM,KAAM;MAAC,QAAQ,EAAEC;IAAS,GAAKE,KAAK,gBACzD,oBAAC,UAAU,CAAC,IAAI;MAAC,KAAK,EAAEwB;IAAe,GAAE/B,QAAQ,CAAmB,CAC/D;EAEX;EAEA,oBACE,oBAAC,UAAU,CAAC,IAAI;IACd;IACA,GAAG,EAAEF,GAAI;IACT,QAAQ,EAAEO,QAAS;IACnB,KAAK,EAAE0B;EAAe,GAClBxB,KAAK,GAERP,QAAQ,CACO;AAEtB,CAAC,CACF;AAED,eAAeH,oBAAoB"}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useMemo","View","useWindowDimensions","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","useKeyboardAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","ref","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","initialFrame","frame","value","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","e","nativeEvent","animatedStyle","bottom","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from 'react';\nimport { View, useWindowDimensions } from 'react-native';\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from 'react-native-reanimated';\n\nimport { useKeyboardAnimation } from './hooks';\n\nimport type { LayoutRectangle, ViewProps } from 'react-native';\n\ntype Props = {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: 'height' | 'position' | 'padding';\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps['style'];\n\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<View, React.PropsWithChildren<Props>>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n 'worklet';\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\n 'worklet';\n\n if (keyboard.isClosed.value) {\n initialFrame.value = layout;\n }\n }, []);\n const onLayout = useCallback<NonNullable<ViewProps['onLayout']>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps]\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolate(\n keyboard.progress.value,\n [0, 1],\n [0, relativeKeyboardHeight()]\n );\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case 'height':\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case 'position':\n return { bottom: bottomHeight };\n\n case 'padding':\n return { paddingBottom: bottomHeight };\n\n default:\n return {};\n }\n }, [behavior, enabled, relativeKeyboardHeight]);\n const isPositionBehavior = behavior === 'position';\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle]\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n }\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,EAAEC,mBAAmB,QAAQ,cAAc;AACxD,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SAASC,oBAAoB,QAAQ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AG,EAAE/B,GAAI;MAAC,KAAK,EAAEM,KAAM;MAAC,QAAQ,EAAEC;IAAS,GAAKE,KAAK,gBACzD,oBAAC,UAAU,CAAC,IAAI;MAAC,KAAK,EAAEwB;IAAe,GAAE/B,QAAQ,CAAmB,CAC/D;EAEX;EAEA,oBACE,oBAAC,UAAU,CAAC,IAAI;IACd,GAAG,EAAEF,GAAI;IACT,QAAQ,EAAEO,QAAS;IACnB,KAAK,EAAE0B;EAAe,GAClBxB,KAAK,GAERP,QAAQ,CACO;AAEtB,CAAC,CACF;AAED,eAAeH,oBAAoB"}
@@ -0,0 +1,190 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { useWindowDimensions } from 'react-native';
4
+ import Reanimated, { interpolate, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
5
+ import { useFocusedInputHandler, useReanimatedFocusedInput } from 'react-native-keyboard-controller';
6
+ import { useSmoothKeyboardHandler } from './useSmoothKeyboardHandler';
7
+ import { debounce } from './utils';
8
+ /**
9
+ * Everything begins from `onStart` handler. This handler is called every time,
10
+ * when keyboard changes its size or when focused `TextInput` was changed. In
11
+ * this handler we are calculating/memoizing values which later will be used
12
+ * during layout movement. For that we calculate:
13
+ * - layout of focused field (`layout`) - to understand whether there will be overlap
14
+ * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
15
+ * - future keyboard height (`keyboardHeight`) - used in scroll interpolation
16
+ * - current scroll position (`scrollPosition`) - used to scroll from this point
17
+ *
18
+ * Once we've calculated all necessary variables - we can actually start to use them.
19
+ * It happens in `onMove` handler - this function simply calls `maybeScroll` with
20
+ * current keyboard frame height. This functions makes the smooth transition.
21
+ *
22
+ * When the transition has finished we go to `onEnd` handler. In this handler
23
+ * we verify, that the current field is not overlapped within a keyboard frame.
24
+ * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
25
+ * however there could be some cases, when `onMove` is not called:
26
+ * - on iOS when TextInput was changed - keyboard transition is instant
27
+ * - on Android when TextInput was changed and keyboard size wasn't changed
28
+ * So `onEnd` handler handle the case, when `onMove` wasn't triggered.
29
+ *
30
+ * ====================================================================================================================+
31
+ * -----------------------------------------------------Flow chart-----------------------------------------------------+
32
+ * ====================================================================================================================+
33
+ *
34
+ * +============================+ +============================+ +==================================+
35
+ * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
36
+ * + + + (run `onStart`) + + `onMove` is getting called +
37
+ * +============================+ +============================+ +==================================+
38
+ *
39
+ *
40
+ * +============================+ +============================+ +=====================================+
41
+ * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
42
+ * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
43
+ * +============================+ +============================+ +=====================================+
44
+ *
45
+ */
46
+ const KeyboardAwareScrollView = _ref => {
47
+ let {
48
+ children,
49
+ bottomOffset = 0,
50
+ ...rest
51
+ } = _ref;
52
+ const scrollViewAnimatedRef = useAnimatedRef();
53
+ const scrollPosition = useSharedValue(0);
54
+ const position = useSharedValue(0);
55
+ const keyboardHeight = useSharedValue(0);
56
+ const tag = useSharedValue(-1);
57
+ const initialKeyboardSize = useSharedValue(0);
58
+ const scrollBeforeKeyboardMovement = useSharedValue(0);
59
+ const {
60
+ input
61
+ } = useReanimatedFocusedInput();
62
+ const layout = useSharedValue(null);
63
+ const {
64
+ height
65
+ } = useWindowDimensions();
66
+ const onScroll = useAnimatedScrollHandler({
67
+ onScroll: e => {
68
+ position.value = e.contentOffset.y;
69
+ }
70
+ }, []);
71
+
72
+ /**
73
+ * Function that will scroll a ScrollView as keyboard gets moving
74
+ */
75
+ const maybeScroll = useCallback(function (e) {
76
+ 'worklet';
77
+
78
+ var _layout$value, _layout$value2;
79
+ let animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
80
+ const visibleRect = height - keyboardHeight.value;
81
+ const absoluteY = ((_layout$value = layout.value) === null || _layout$value === void 0 ? void 0 : _layout$value.layout.absoluteY) || 0;
82
+ const inputHeight = ((_layout$value2 = layout.value) === null || _layout$value2 === void 0 ? void 0 : _layout$value2.layout.height) || 0;
83
+ const point = absoluteY + inputHeight;
84
+ if (visibleRect - point <= bottomOffset) {
85
+ const interpolatedScrollTo = interpolate(e, [initialKeyboardSize.value, keyboardHeight.value], [0, keyboardHeight.value - (height - point) + bottomOffset]);
86
+ const targetScrollY = Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
87
+ scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);
88
+ return interpolatedScrollTo;
89
+ }
90
+ if (absoluteY < 0) {
91
+ const positionOnScreen = visibleRect - inputHeight - bottomOffset;
92
+ const topOfScreen = scrollPosition.value + absoluteY;
93
+ scrollTo(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
94
+ }
95
+ return 0;
96
+ }, [bottomOffset]);
97
+ const onChangeText = useCallback(() => {
98
+ 'worklet';
99
+
100
+ // if typing a text caused layout shift, then we need to ignore this handler
101
+ // because this event will be handled in `useAnimatedReaction` below
102
+ var _layout$value3, _input$value;
103
+ if (((_layout$value3 = layout.value) === null || _layout$value3 === void 0 ? void 0 : _layout$value3.layout.height) !== ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.layout.height)) {
104
+ return;
105
+ }
106
+ const prevScrollPosition = scrollPosition.value;
107
+ const prevLayout = layout.value;
108
+ scrollPosition.value = position.value;
109
+ layout.value = input.value;
110
+ maybeScroll(keyboardHeight.value, true);
111
+ scrollPosition.value = prevScrollPosition;
112
+ layout.value = prevLayout;
113
+ }, [maybeScroll]);
114
+ const onChangeTextHandler = useMemo(() => debounce(onChangeText, 200), [onChangeText]);
115
+ useFocusedInputHandler({
116
+ onChangeText: onChangeTextHandler
117
+ }, [onChangeTextHandler]);
118
+ useSmoothKeyboardHandler({
119
+ onStart: e => {
120
+ 'worklet';
121
+
122
+ const keyboardWillChangeSize = keyboardHeight.value !== e.height && e.height > 0;
123
+ const keyboardWillAppear = e.height > 0 && keyboardHeight.value === 0;
124
+ const keyboardWillHide = e.height === 0;
125
+ const focusWasChanged = tag.value !== e.target && e.target !== -1 || keyboardWillChangeSize;
126
+ if (keyboardWillChangeSize) {
127
+ initialKeyboardSize.value = keyboardHeight.value;
128
+ }
129
+ if (keyboardWillHide) {
130
+ // on back transition need to interpolate as [0, keyboardHeight]
131
+ initialKeyboardSize.value = 0;
132
+ scrollPosition.value = scrollBeforeKeyboardMovement.value;
133
+ }
134
+ if (keyboardWillAppear || keyboardWillChangeSize || focusWasChanged) {
135
+ // persist scroll value
136
+ scrollPosition.value = position.value;
137
+ // just persist height - later will be used in interpolation
138
+ keyboardHeight.value = e.height;
139
+ }
140
+
141
+ // focus was changed
142
+ if (focusWasChanged) {
143
+ tag.value = e.target;
144
+
145
+ // save position of focused text input when keyboard starts to move
146
+ layout.value = input.value;
147
+ // save current scroll position - when keyboard will hide we'll reuse
148
+ // this value to achieve smooth hide effect
149
+ scrollBeforeKeyboardMovement.value = position.value;
150
+ }
151
+ if (focusWasChanged && !keyboardWillAppear) {
152
+ // update position on scroll value, so `onEnd` handler
153
+ // will pick up correct values
154
+ position.value += maybeScroll(e.height, true);
155
+ }
156
+ },
157
+ onMove: e => {
158
+ 'worklet';
159
+
160
+ maybeScroll(e.height);
161
+ },
162
+ onEnd: e => {
163
+ 'worklet';
164
+
165
+ keyboardHeight.value = e.height;
166
+ scrollPosition.value = position.value;
167
+ }
168
+ }, [height, maybeScroll]);
169
+ useAnimatedReaction(() => input.value, (current, previous) => {
170
+ if ((current === null || current === void 0 ? void 0 : current.target) === (previous === null || previous === void 0 ? void 0 : previous.target) && (current === null || current === void 0 ? void 0 : current.layout.height) !== (previous === null || previous === void 0 ? void 0 : previous.layout.height)) {
171
+ const prevLayout = layout.value;
172
+ layout.value = input.value;
173
+ scrollPosition.value += maybeScroll(keyboardHeight.value, true);
174
+ layout.value = prevLayout;
175
+ }
176
+ }, []);
177
+ const view = useAnimatedStyle(() => ({
178
+ paddingBottom: keyboardHeight.value
179
+ }), []);
180
+ return /*#__PURE__*/React.createElement(Reanimated.ScrollView, _extends({
181
+ ref: scrollViewAnimatedRef
182
+ }, rest, {
183
+ onScroll: onScroll,
184
+ scrollEventThrottle: 16
185
+ }), /*#__PURE__*/React.createElement(Reanimated.View, {
186
+ style: view
187
+ }, children));
188
+ };
189
+ export default KeyboardAwareScrollView;
190
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useMemo","useWindowDimensions","Reanimated","interpolate","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useAnimatedStyle","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useSmoothKeyboardHandler","debounce","KeyboardAwareScrollView","children","bottomOffset","rest","scrollViewAnimatedRef","scrollPosition","position","keyboardHeight","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","height","onScroll","e","value","contentOffset","y","maybeScroll","animated","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","onChangeText","prevScrollPosition","prevLayout","onChangeTextHandler","onStart","keyboardWillChangeSize","keyboardWillAppear","keyboardWillHide","focusWasChanged","target","onMove","onEnd","current","previous","view","paddingBottom"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { useWindowDimensions } from 'react-native';\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useSharedValue,\n} from 'react-native-reanimated';\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n} from 'react-native-keyboard-controller';\n\nimport { useSmoothKeyboardHandler } from './useSmoothKeyboardHandler';\nimport { debounce } from './utils';\n\nimport type { FC } from 'react';\nimport type { ScrollViewProps } from 'react-native';\nimport type { FocusedInputLayoutChangedEvent } from 'react-native-keyboard-controller';\n\ntype KeyboardAwareScrollViewProps = {\n bottomOffset?: number;\n} & ScrollViewProps;\n\n/**\n * Everything begins from `onStart` handler. This handler is called every time,\n * when keyboard changes its size or when focused `TextInput` was changed. In\n * this handler we are calculating/memoizing values which later will be used\n * during layout movement. For that we calculate:\n * - layout of focused field (`layout`) - to understand whether there will be overlap\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n * - current scroll position (`scrollPosition`) - used to scroll from this point\n *\n * Once we've calculated all necessary variables - we can actually start to use them.\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\n * current keyboard frame height. This functions makes the smooth transition.\n *\n * When the transition has finished we go to `onEnd` handler. In this handler\n * we verify, that the current field is not overlapped within a keyboard frame.\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n * however there could be some cases, when `onMove` is not called:\n * - on iOS when TextInput was changed - keyboard transition is instant\n * - on Android when TextInput was changed and keyboard size wasn't changed\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n *\n * ====================================================================================================================+\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\n * ====================================================================================================================+\n *\n * +============================+ +============================+ +==================================+\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n * + + + (run `onStart`) + + `onMove` is getting called +\n * +============================+ +============================+ +==================================+\n *\n *\n * +============================+ +============================+ +=====================================+\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n * +============================+ +============================+ +=====================================+\n *\n */\nconst KeyboardAwareScrollView: FC<KeyboardAwareScrollViewProps> = ({\n children,\n bottomOffset = 0,\n ...rest\n}) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useAnimatedScrollHandler(\n {\n onScroll: (e) => {\n position.value = e.contentOffset.y;\n },\n },\n []\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n 'worklet';\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [0, keyboardHeight.value - (height - point) + bottomOffset]\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated\n );\n }\n\n return 0;\n },\n [bottomOffset]\n );\n\n const onChangeText = useCallback(() => {\n 'worklet';\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText]\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler]\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n 'worklet';\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n const keyboardWillAppear = e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) || keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (keyboardWillAppear || keyboardWillChangeSize || focusWasChanged) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n 'worklet';\n\n maybeScroll(e.height);\n },\n onEnd: (e) => {\n 'worklet';\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n },\n },\n [height, maybeScroll]\n );\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n []\n );\n\n const view = useAnimatedStyle(\n () => ({\n paddingBottom: keyboardHeight.value,\n }),\n []\n );\n\n return (\n <Reanimated.ScrollView\n ref={scrollViewAnimatedRef}\n {...rest}\n onScroll={onScroll}\n scrollEventThrottle={16}\n >\n <Reanimated.View style={view}>{children}</Reanimated.View>\n </Reanimated.ScrollView>\n );\n};\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,mBAAmB,QAAQ,cAAc;AAClD,OAAOC,UAAU,IACfC,WAAW,EACXC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,gBAAgB,EAChBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,QACpB,kCAAkC;AAEzC,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,QAAQ,SAAS;AAUlC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAyD,GAAG,QAI5D;EAAA,IAJ6D;IACjEC,QAAQ;IACRC,YAAY,GAAG,CAAC;IAChB,GAAGC;EACL,CAAC;EACC,MAAMC,qBAAqB,GAAGZ,cAAc,EAAyB;EACrE,MAAMa,cAAc,GAAGV,cAAc,CAAC,CAAC,CAAC;EACxC,MAAMW,QAAQ,GAAGX,cAAc,CAAC,CAAC,CAAC;EAClC,MAAMY,cAAc,GAAGZ,cAAc,CAAC,CAAC,CAAC;EACxC,MAAMa,GAAG,GAAGb,cAAc,CAAC,CAAC,CAAC,CAAC;EAC9B,MAAMc,mBAAmB,GAAGd,cAAc,CAAC,CAAC,CAAC;EAC7C,MAAMe,4BAA4B,GAAGf,cAAc,CAAC,CAAC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AAuB"}
@@ -0,0 +1,93 @@
1
+ import { Platform } from 'react-native';
2
+ import { Easing, useAnimatedReaction, useSharedValue, withTiming } from 'react-native-reanimated';
3
+ import { useKeyboardHandler } from 'react-native-keyboard-controller';
4
+ const IS_ANDROID_ELEVEN_OR_HIGHER = Platform.OS === 'android' && Platform.Version >= 30;
5
+ // on these platforms keyboard transitions will be smooth
6
+ const IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS = IS_ANDROID_ELEVEN_OR_HIGHER || Platform.OS === 'ios';
7
+ // on Android Telegram is not using androidx.core values and uses custom interpolation
8
+ // duration is taken from here: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java#L39
9
+ // and bezier is taken from: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java#L40
10
+ const TELEGRAM_ANDROID_TIMING_CONFIG = {
11
+ duration: 250,
12
+ easing: Easing.bezier(0.19919472913616398, 0.010644531250000006, 0.27920937042459737, 0.91025390625)
13
+ };
14
+
15
+ /**
16
+ * Hook that uses default transitions for iOS and Android > 11, and uses
17
+ * custom interpolation on Android < 11 to achieve more smooth animation
18
+ */
19
+ export const useSmoothKeyboardHandler = (handler, deps) => {
20
+ const target = useSharedValue(-1);
21
+ const persistedHeight = useSharedValue(0);
22
+ const animatedKeyboardHeight = useSharedValue(0);
23
+ useAnimatedReaction(() => {
24
+ if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {
25
+ return;
26
+ }
27
+ const event = {
28
+ // it'll be always 250, since we're running animation via `withTiming` where
29
+ // duration in config (TELEGRAM_ANDROID_TIMING_CONFIG.duration) = 250ms
30
+ duration: 250,
31
+ target: target.value,
32
+ height: animatedKeyboardHeight.value,
33
+ progress: animatedKeyboardHeight.value / persistedHeight.value
34
+ };
35
+ return event;
36
+ }, evt => {
37
+ var _handler$onMove;
38
+ if (!evt) {
39
+ return;
40
+ }
41
+ (_handler$onMove = handler.onMove) === null || _handler$onMove === void 0 ? void 0 : _handler$onMove.call(handler, evt);
42
+
43
+ // dispatch `onEnd`
44
+ if (evt.height === persistedHeight.value) {
45
+ var _handler$onEnd;
46
+ (_handler$onEnd = handler.onEnd) === null || _handler$onEnd === void 0 ? void 0 : _handler$onEnd.call(handler, evt);
47
+ }
48
+ }, [handler]);
49
+ useKeyboardHandler({
50
+ onStart: e => {
51
+ 'worklet';
52
+
53
+ // immediately dispatch onStart/onEnd events if onStart dispatched with the same height
54
+ // and don't wait for animation 250ms
55
+ var _handler$onStart2;
56
+ if (!IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS && e.height === persistedHeight.value) {
57
+ var _handler$onStart, _handler$onEnd2;
58
+ (_handler$onStart = handler.onStart) === null || _handler$onStart === void 0 ? void 0 : _handler$onStart.call(handler, e);
59
+ (_handler$onEnd2 = handler.onEnd) === null || _handler$onEnd2 === void 0 ? void 0 : _handler$onEnd2.call(handler, e);
60
+ return;
61
+ }
62
+ target.value = e.target;
63
+ if (e.height > 0) {
64
+ persistedHeight.value = e.height;
65
+ }
66
+ // if we are running on Android < 9, then we are using custom interpolation
67
+ // to achieve smoother animation and use `animatedKeyboardHeight` as animation
68
+ // driver
69
+ if (!IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {
70
+ animatedKeyboardHeight.value = withTiming(e.height, TELEGRAM_ANDROID_TIMING_CONFIG);
71
+ }
72
+ (_handler$onStart2 = handler.onStart) === null || _handler$onStart2 === void 0 ? void 0 : _handler$onStart2.call(handler, e);
73
+ },
74
+ onMove: e => {
75
+ 'worklet';
76
+
77
+ if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {
78
+ var _handler$onMove2;
79
+ (_handler$onMove2 = handler.onMove) === null || _handler$onMove2 === void 0 ? void 0 : _handler$onMove2.call(handler, e);
80
+ }
81
+ },
82
+ onEnd: e => {
83
+ 'worklet';
84
+
85
+ if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {
86
+ var _handler$onEnd3;
87
+ (_handler$onEnd3 = handler.onEnd) === null || _handler$onEnd3 === void 0 ? void 0 : _handler$onEnd3.call(handler, e);
88
+ }
89
+ persistedHeight.value = e.height;
90
+ }
91
+ }, deps);
92
+ };
93
+ //# sourceMappingURL=useSmoothKeyboardHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","Easing","useAnimatedReaction","useSharedValue","withTiming","useKeyboardHandler","IS_ANDROID_ELEVEN_OR_HIGHER","OS","Version","IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS","TELEGRAM_ANDROID_TIMING_CONFIG","duration","easing","bezier","useSmoothKeyboardHandler","handler","deps","target","persistedHeight","animatedKeyboardHeight","event","value","height","progress","evt","onMove","onEnd","onStart","e"],"sources":["useSmoothKeyboardHandler.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport {\n Easing,\n useAnimatedReaction,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\n\nimport { useKeyboardHandler } from 'react-native-keyboard-controller';\n\nconst IS_ANDROID_ELEVEN_OR_HIGHER =\n Platform.OS === 'android' && Platform.Version >= 30;\n// on these platforms keyboard transitions will be smooth\nconst IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS =\n IS_ANDROID_ELEVEN_OR_HIGHER || Platform.OS === 'ios';\n// on Android Telegram is not using androidx.core values and uses custom interpolation\n// duration is taken from here: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java#L39\n// and bezier is taken from: https://github.com/DrKLO/Telegram/blob/e9a35cea54c06277c69d41b8e25d94b5d7ede065/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java#L40\nconst TELEGRAM_ANDROID_TIMING_CONFIG = {\n duration: 250,\n easing: Easing.bezier(\n 0.19919472913616398,\n 0.010644531250000006,\n 0.27920937042459737,\n 0.91025390625\n ),\n};\n\n/**\n * Hook that uses default transitions for iOS and Android > 11, and uses\n * custom interpolation on Android < 11 to achieve more smooth animation\n */\nexport const useSmoothKeyboardHandler: typeof useKeyboardHandler = (\n handler,\n deps\n) => {\n const target = useSharedValue(-1);\n const persistedHeight = useSharedValue(0);\n const animatedKeyboardHeight = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n return;\n }\n const event = {\n // it'll be always 250, since we're running animation via `withTiming` where\n // duration in config (TELEGRAM_ANDROID_TIMING_CONFIG.duration) = 250ms\n duration: 250,\n target: target.value,\n height: animatedKeyboardHeight.value,\n progress: animatedKeyboardHeight.value / persistedHeight.value,\n };\n return event;\n },\n (evt) => {\n if (!evt) {\n return;\n }\n handler.onMove?.(evt);\n\n // dispatch `onEnd`\n if (evt.height === persistedHeight.value) {\n handler.onEnd?.(evt);\n }\n },\n [handler]\n );\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n 'worklet';\n\n // immediately dispatch onStart/onEnd events if onStart dispatched with the same height\n // and don't wait for animation 250ms\n if (\n !IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS &&\n e.height === persistedHeight.value\n ) {\n handler.onStart?.(e);\n handler.onEnd?.(e);\n\n return;\n }\n\n target.value = e.target;\n\n if (e.height > 0) {\n persistedHeight.value = e.height;\n }\n // if we are running on Android < 9, then we are using custom interpolation\n // to achieve smoother animation and use `animatedKeyboardHeight` as animation\n // driver\n if (!IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n animatedKeyboardHeight.value = withTiming(\n e.height,\n TELEGRAM_ANDROID_TIMING_CONFIG\n );\n }\n\n handler.onStart?.(e);\n },\n onMove: (e) => {\n 'worklet';\n\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n handler.onMove?.(e);\n }\n },\n onEnd: (e) => {\n 'worklet';\n\n if (IS_ANDROID_ELEVEN_OR_HIGHER_OR_IOS) {\n handler.onEnd?.(e);\n }\n\n persistedHeight.value = e.height;\n },\n },\n deps\n );\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SACEC,MAAM,EACNC,mBAAmB,EACnBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,kBAAkB,QAAQ,kCAAkC;AAErE,MAAMC,2BAA2B,GAC/BN,QAAQ,CAACO,EAAE,KAAK,SAAS,IAAIP,QAAQ,CAACQ,OAAO,IAAI,EAAE;AACrD;AACA,MAAMC,kCAAkC,GACtCH,2BAA2B,IAAIN,QAAQ,CAACO,EAAE,KAAK,KAAK;AACtD;AACA;AACA;AACA,MAAMG,8BAA8B,GAAG;EACrCC,QAAQ,EAAE,GAAG;EACbC,MAAM,EAAEX,MAAM,CAACY,MAAM,CACnB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa;AAEjB,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAmD,GAAG,CACjEC,OAAO,EACPC,IAAI,KACD;EACH,MAAMC,MAAM,GAAGd,cAAc,CAAC,CAAC,CAAC,CAAC;EACjC,MAAMe,eAAe,GAAGf,cAAc,CAAC,CAAC,CAAC;EACzC,MAAMgB,sBAAsB,GAAGhB,cAAc,CAAC,CAAC,CAAC;EAEhDD,mBAAmB,CACjB,MAAM;IACJ,IAAIO,kCAAkC,EAAE;MACtC;IACF;IACA,MAAMW,KAAK,GAAG;MACZ;MACA;MACAT,QAAQ,EAAE,GAAG;MACbM,MAAM,EAAEA,MAAM,CAACI,KAAK;MACpBC,MAAM,EAAEH,sBAAsB,CAACE,KAAK;MACpCE,QAAQ,EAAEJ,sBAAsB,CAACE,KAAK,GAAGH,eAAe,CAACG;IAC3D,CAAC;IACD,OAAOD,KAAK;EACd,CAAC,EACAI,GAAG,IAAK;IAAA;IACP,IAAI,CAACA,GAAG,EAAE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A;QACtC,mBAAAM,OAAO,CAACW,KAAK,oDAAb,qBAAAX,OAAO,EAASa,CAAC,CAAC;MACpB;MAEAV,eAAe,CAACG,KAAK,GAAGO,CAAC,CAACN,MAAM;IAClC;EACF,CAAC,EACDN,IAAI,CACL;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ export const debounce = function (worklet) {
2
+ 'worklet';
3
+
4
+ let wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
5
+ const value = {
6
+ time: 0
7
+ };
8
+ return function () {
9
+ 'worklet';
10
+
11
+ const t = Date.now();
12
+ const now = t - value.time;
13
+ if (now < wait) {
14
+ value.time = t;
15
+ return;
16
+ }
17
+ value.time = t;
18
+ return worklet(...arguments);
19
+ };
20
+ };
21
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["debounce","worklet","wait","value","time","t","Date","now"],"sources":["utils.ts"],"sourcesContent":["export const debounce = <F extends (...args: Parameters<F>) => ReturnType<F>>(\n worklet: F,\n wait = 0\n) => {\n 'worklet';\n\n const value = {\n time: 0,\n };\n\n return (...args: Parameters<F>): ReturnType<F> | void => {\n 'worklet';\n\n const t = Date.now();\n const now = t - value.time;\n\n if (now < wait) {\n value.time = t;\n return;\n }\n\n value.time = t;\n\n return worklet(...args);\n };\n};\n"],"mappings":"AAAA,OAAO,MAAMA,QAAQ,GAAG,UACtBC,OAAU,EAEP;EACH,SAAS;;EAAC,IAFVC,IAAI,uEAAG,CAAC;EAIR,MAAMC,KAAK,GAAG;IACZC,IAAI,EAAE;EACR,CAAC;EAED,OAAO,YAAkD;IACvD,SAAS;;IAET,MAAMC,CAAC,GAAGC,IAAI,CAACC,GAAG,EAAE;IACpB,MAAMA,GAAG,GAAGF,CAAC,GAAGF,KAAK,CAACC,IAAI;IAE1B,IAAIG,GAAG,GAAGL,IAAI,EAAE;MACdC,KAAK,CAACC,IAAI,GAAGC,CAAC;MACd;IACF;IAEAF,KAAK,CAACC,IAAI,GAAGC,CAAC;IAEd,OAAOJ,OAAO,CAAC,YAAO,CAAC;EACzB,CAAC;AACH,CAAC"}