react-native-keyboard-controller 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +5 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt +5 -3
- package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationController.kt +8 -2
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +14 -1
- package/ios/KeyboardMovementObserver.swift +10 -25
- package/lib/commonjs/animated.js +3 -1
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/module/animated.js +3 -1
- package/lib/module/animated.js.map +1 -1
- package/package.json +2 -2
- package/src/animated.tsx +1 -0
package/android/build.gradle
CHANGED
|
@@ -40,6 +40,11 @@ if (isNewArchitectureEnabled()) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
android {
|
|
43
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
44
|
+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
45
|
+
namespace "com.reactnativekeyboardcontroller"
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
44
49
|
defaultConfig {
|
|
45
50
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationCallback.kt
CHANGED
|
@@ -145,12 +145,14 @@ class KeyboardAnimationCallback(
|
|
|
145
145
|
super.onEnd(animation)
|
|
146
146
|
|
|
147
147
|
isTransitioning = false
|
|
148
|
+
|
|
149
|
+
var keyboardHeight = this.persistentKeyboardHeight
|
|
148
150
|
// if keyboard becomes shown after interactive animation completion
|
|
149
151
|
// getCurrentKeyboardHeight() will be `0` and isKeyboardVisible will be `false`
|
|
150
152
|
// it's not correct behavior, so we are handling it here
|
|
151
153
|
val isKeyboardShown = InteractiveKeyboardProvider.shown
|
|
152
154
|
if (!isKeyboardShown) {
|
|
153
|
-
|
|
155
|
+
keyboardHeight = getCurrentKeyboardHeight()
|
|
154
156
|
} else {
|
|
155
157
|
// if keyboard is shown after interactions and the animation has finished
|
|
156
158
|
// then we need to reset the state
|
|
@@ -158,8 +160,8 @@ class KeyboardAnimationCallback(
|
|
|
158
160
|
}
|
|
159
161
|
isKeyboardVisible = isKeyboardVisible || isKeyboardShown
|
|
160
162
|
|
|
161
|
-
this.emitEvent("KeyboardController::" + if (!isKeyboardVisible) "keyboardDidHide" else "keyboardDidShow", getEventParams(
|
|
162
|
-
this.sendEventToJS(KeyboardTransitionEvent(view.id, "topKeyboardMoveEnd",
|
|
163
|
+
this.emitEvent("KeyboardController::" + if (!isKeyboardVisible) "keyboardDidHide" else "keyboardDidShow", getEventParams(keyboardHeight))
|
|
164
|
+
this.sendEventToJS(KeyboardTransitionEvent(view.id, "topKeyboardMoveEnd", keyboardHeight, if (!isKeyboardVisible) 0.0 else 1.0))
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
private fun isKeyboardVisible(): Boolean {
|
package/android/src/main/java/com/reactnativekeyboardcontroller/KeyboardAnimationController.kt
CHANGED
|
@@ -284,8 +284,14 @@ internal class KeyboardAnimationController {
|
|
|
284
284
|
velocityY = velocityY,
|
|
285
285
|
)
|
|
286
286
|
// The current inset matches either the shown/hidden inset, finish() immediately
|
|
287
|
-
current == shown ->
|
|
288
|
-
|
|
287
|
+
current == shown -> {
|
|
288
|
+
InteractiveKeyboardProvider.shown = true
|
|
289
|
+
controller.finish(true)
|
|
290
|
+
}
|
|
291
|
+
current == hidden -> {
|
|
292
|
+
InteractiveKeyboardProvider.shown = false
|
|
293
|
+
controller.finish(false)
|
|
294
|
+
}
|
|
289
295
|
else -> {
|
|
290
296
|
// Otherwise, we'll look at the current position...
|
|
291
297
|
if (controller.currentFraction >= SCROLL_THRESHOLD) {
|
package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt
CHANGED
|
@@ -35,7 +35,7 @@ class EdgeToEdgeReactViewGroup(private val reactContext: ThemedReactContext) : R
|
|
|
35
35
|
onApplyWindowInsetsListener = { v, insets ->
|
|
36
36
|
val content =
|
|
37
37
|
reactContext.currentActivity?.window?.decorView?.rootView?.findViewById<FitWindowsLinearLayout>(
|
|
38
|
-
R.id.action_bar_root,
|
|
38
|
+
androidx.appcompat.R.id.action_bar_root,
|
|
39
39
|
)
|
|
40
40
|
content?.setPadding(
|
|
41
41
|
0,
|
|
@@ -31,6 +31,7 @@ class KeyboardGestureAreaReactViewGroup(private val reactContext: ThemedReactCon
|
|
|
31
31
|
private var lastTouchX = 0f
|
|
32
32
|
private var lastTouchY = 0f
|
|
33
33
|
private var lastWindowY = 0
|
|
34
|
+
private var keyboardHeight = 0
|
|
34
35
|
|
|
35
36
|
// react props
|
|
36
37
|
private var interpolator: Interpolator = LinearInterpolator()
|
|
@@ -87,6 +88,9 @@ class KeyboardGestureAreaReactViewGroup(private val reactContext: ThemedReactCon
|
|
|
87
88
|
|
|
88
89
|
if (isHandling) {
|
|
89
90
|
if (controller.isInsetAnimationInProgress()) {
|
|
91
|
+
if (keyboardHeight == 0) {
|
|
92
|
+
this.keyboardHeight = controller.getCurrentKeyboardHeight()
|
|
93
|
+
}
|
|
90
94
|
// If we currently have control, we can update the IME insets to 'scroll'
|
|
91
95
|
// the IME in
|
|
92
96
|
val moveBy = this.interpolator.interpolate(dy.roundToInt(), this.getWindowHeight() - event.rawY.toInt(), controller.getCurrentKeyboardHeight())
|
|
@@ -122,10 +126,18 @@ class KeyboardGestureAreaReactViewGroup(private val reactContext: ThemedReactCon
|
|
|
122
126
|
// Calculate the current velocityY, over 500 milliseconds
|
|
123
127
|
velocityTracker?.computeCurrentVelocity(500)
|
|
124
128
|
val velocityY = velocityTracker?.yVelocity
|
|
129
|
+
val isKeyboardPositionChanged =
|
|
130
|
+
// check `isInsetAnimationInProgress()` before, since direct usage of `getCurrentKeyboardHeight()`
|
|
131
|
+
// may throw exception
|
|
132
|
+
!controller.isInsetAnimationInProgress() ||
|
|
133
|
+
this.keyboardHeight != controller.getCurrentKeyboardHeight()
|
|
134
|
+
// if keyboard height was changed after finger movement -> we need to calculate final position
|
|
135
|
+
// and make an animated transition
|
|
136
|
+
val passedVelocityY = if (isKeyboardPositionChanged) velocityY else null
|
|
125
137
|
|
|
126
138
|
// If we received a ACTION_UP event, end any current WindowInsetsAnimation passing
|
|
127
139
|
// in the calculated Y velocity
|
|
128
|
-
controller.animateToFinish(
|
|
140
|
+
controller.animateToFinish(passedVelocityY)
|
|
129
141
|
|
|
130
142
|
// Reset our touch handling state
|
|
131
143
|
reset()
|
|
@@ -162,6 +174,7 @@ class KeyboardGestureAreaReactViewGroup(private val reactContext: ThemedReactCon
|
|
|
162
174
|
lastTouchX = 0f
|
|
163
175
|
lastTouchY = 0f
|
|
164
176
|
lastWindowY = 0
|
|
177
|
+
keyboardHeight = 0
|
|
165
178
|
bounds.setEmpty()
|
|
166
179
|
|
|
167
180
|
velocityTracker?.recycle()
|
|
@@ -65,26 +65,6 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
65
65
|
name: UIResponder.keyboardDidHideNotification,
|
|
66
66
|
object: nil
|
|
67
67
|
)
|
|
68
|
-
NotificationCenter.default.addObserver(
|
|
69
|
-
self,
|
|
70
|
-
selector: #selector(windowDidBecomeVisible),
|
|
71
|
-
name: UIWindow.didBecomeVisibleNotification,
|
|
72
|
-
object: nil
|
|
73
|
-
)
|
|
74
|
-
NotificationCenter.default.addObserver(
|
|
75
|
-
self,
|
|
76
|
-
selector: #selector(windowDidBecomeHidden),
|
|
77
|
-
name: UIWindow.didBecomeHiddenNotification,
|
|
78
|
-
object: nil
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@objc func windowDidBecomeHidden(_: Notification) {
|
|
83
|
-
removeKVObserver()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@objc func windowDidBecomeVisible(_: Notification) {
|
|
87
|
-
setupKVObserver()
|
|
88
68
|
}
|
|
89
69
|
|
|
90
70
|
private func setupKVObserver() {
|
|
@@ -116,8 +96,13 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
116
96
|
) {
|
|
117
97
|
// swiftlint:disable:next force_cast
|
|
118
98
|
if keyPath == "center", object as! NSObject == _keyboardView! {
|
|
119
|
-
// if we are currently animating keyboard
|
|
120
|
-
if displayLink != nil
|
|
99
|
+
// if we are currently animating keyboard -> we need to ignore values from KVO
|
|
100
|
+
if displayLink != nil {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
// if keyboard height is not equal to its bounds - we can ignore
|
|
104
|
+
// values, since they'll be invalid and will cause UI jumps
|
|
105
|
+
if keyboardView?.bounds.size.height != keyboardHeight {
|
|
121
106
|
return
|
|
122
107
|
}
|
|
123
108
|
|
|
@@ -170,6 +155,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
170
155
|
onNotify("KeyboardController::keyboardWillHide", data)
|
|
171
156
|
|
|
172
157
|
setupKeyboardWatcher()
|
|
158
|
+
removeKVObserver()
|
|
173
159
|
}
|
|
174
160
|
|
|
175
161
|
@objc func keyboardDidAppear(_ notification: Notification) {
|
|
@@ -184,6 +170,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
184
170
|
onNotify("KeyboardController::keyboardDidShow", data)
|
|
185
171
|
|
|
186
172
|
removeKeyboardWatcher()
|
|
173
|
+
setupKVObserver()
|
|
187
174
|
}
|
|
188
175
|
}
|
|
189
176
|
|
|
@@ -191,8 +178,6 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
191
178
|
var data = [AnyHashable: Any]()
|
|
192
179
|
data["height"] = 0
|
|
193
180
|
|
|
194
|
-
keyboardHeight = 0.0
|
|
195
|
-
|
|
196
181
|
onEvent("onKeyboardMoveEnd", 0 as NSNumber, 0)
|
|
197
182
|
onNotify("KeyboardController::keyboardDidHide", data)
|
|
198
183
|
|
|
@@ -228,7 +213,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
228
213
|
if subview.description.hasPrefix("<UIInputSetContainerView") {
|
|
229
214
|
for hostView in subview.subviews {
|
|
230
215
|
if hostView.description.hasPrefix("<UIInputSetHostView") {
|
|
231
|
-
result = hostView
|
|
216
|
+
result = hostView
|
|
232
217
|
break
|
|
233
218
|
}
|
|
234
219
|
}
|
package/lib/commonjs/animated.js
CHANGED
|
@@ -107,7 +107,9 @@ const KeyboardProvider = _ref => {
|
|
|
107
107
|
onKeyboardMove: _reactNative.Platform.OS === 'android' ? onKeyboardMove : undefined,
|
|
108
108
|
onKeyboardMoveInteractive: onKeyboardMove,
|
|
109
109
|
navigationBarTranslucent: navigationBarTranslucent,
|
|
110
|
-
statusBarTranslucent: statusBarTranslucent
|
|
110
|
+
statusBarTranslucent: statusBarTranslucent
|
|
111
|
+
// @ts-expect-error will be fixed when migrate to REA 3.3.0
|
|
112
|
+
,
|
|
111
113
|
style: styles.container
|
|
112
114
|
}, children), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
|
113
115
|
// we are using this small hack, because if the component (where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","handler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport {\n useAnimatedKeyboardHandler,\n useSharedHandlers,\n useAnimatedValue,\n} from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\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\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n}: KeyboardProviderProps) => {\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 { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const 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 handler = 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\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\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}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AAKA;AAAkD;AAAA;AAQlD,MAAMA,8BAA8B,GAAGC,8BAAU,CAACC,uBAAuB,CACvEC,qBAAQ,CAACD,uBAA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ACC,EAAE,KAAK,KAAK,GAAGR,cAAc,GAAGe,SAAU;IACxE,cAAc,EAAER,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,cAAc,GAAGe,SAAU;IACvE,yBAAyB,EAAEf,cAAe;IAC1C,wBAAwB,EAAEnB,wBAAyB;IACnD,oBAAoB,EAAED
|
|
1
|
+
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","handler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport {\n useAnimatedKeyboardHandler,\n useSharedHandlers,\n useAnimatedValue,\n} from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\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\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n}: KeyboardProviderProps) => {\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 { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const 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 handler = 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\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error will be fixed when migrate to REA 3.3.0\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;AACA;AACA;AAEA;AACA;AAKA;AAAkD;AAAA;AAQlD,MAAMA,8BAA8B,GAAGC,8BAAU,CAACC,uBAAuB,CACvEC,qBAAQ,CAACD,uBAAuB,CAC9BE,8BAAsB,CACvB,CACF;AAOD,MAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAwBK,MAAMC,gBAAgB,GAAG,QAIH;EAAA,IAJI;IAC/BC,QAAQ;IACRC,oBAAoB;IACpBC;EACqB,CAAC;EACtB;EACA,MAAMC,QAAQ,GAAG,IAAAC,0BAAgB,EAAC,CAAC,CAAC;EACpC,MAAMC,MAAM,GAAG,IAAAD,0BAAgB,EAAC,CAAC,CAAC;EAClC;EACA,MAAME,UAAU,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EACpC,MAAMC,QAAQ,GAAG,IAAAD,qCAAc,EAAC,CAA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3BG,kBAAkB,CAACH,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IACDD,cAAc,EAAGC,KAAkB,IAAK;MACtC,SAAS;;MAETZ,SAAS,CAAC,QAAQ,EAAEY,KAAK,CAAC;MAC1BG,kBAAkB,CAACH,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACDY,iBAAiB,EAAGZ,KAAkB,IAAK;MACzC,SAAS;;MAETZ,SAAS,CAAC,OAAO,EAAEY,KAAK,CAAC;IAC3B,CAAC;IACDa,yBAAyB,EAAGb,KAAkB,IAAK;MACjD,SAAS;;MAETG,kBAAkB,CAACH,KAAK,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;MAC7CZ,SAAS,CAAC,eAAe,EAAEY,KAAK,CAAC;IACnC;EACF,CAAC,EACD,EAAE,CACH;EAED,oBACE,6BAAC,wBAAe,CAAC,QAAQ;IAAC,KAAK,EAAEV;EAAQ,gBACvC,6BAAC,8BAA8B;IAC7B,wBAAwB,EAAEmB,OAAQ;IAClC,mBAAmB,EAAEH,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGR,cAAc,GAAGe,SAAU;IACxE,cAAc,EAAER,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,cAAc,GAAGe,SAAU;IACvE,yBAAyB,EAAEf,cAAe;IAC1C,wBAAwB,EAAEnB,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAEV,MAAM,CAACG;EAAU,GAEvBM,QAAQ,CACsB,eACjC,6BAAC,qBAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEiB;EAAM,EACb,CACuB;AAE/B,CAAC;AAAC"}
|
package/lib/module/animated.js
CHANGED
|
@@ -99,7 +99,9 @@ export const KeyboardProvider = _ref => {
|
|
|
99
99
|
onKeyboardMove: Platform.OS === 'android' ? onKeyboardMove : undefined,
|
|
100
100
|
onKeyboardMoveInteractive: onKeyboardMove,
|
|
101
101
|
navigationBarTranslucent: navigationBarTranslucent,
|
|
102
|
-
statusBarTranslucent: statusBarTranslucent
|
|
102
|
+
statusBarTranslucent: statusBarTranslucent
|
|
103
|
+
// @ts-expect-error will be fixed when migrate to REA 3.3.0
|
|
104
|
+
,
|
|
103
105
|
style: styles.container
|
|
104
106
|
}, children), /*#__PURE__*/React.createElement(Animated.View, {
|
|
105
107
|
// we are using this small hack, because if the component (where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardContext","useAnimatedKeyboardHandler","useSharedHandlers","useAnimatedValue","KeyboardControllerView","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","height","progressSV","heightSV","setHandlers","broadcast","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","OS","value","handler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport {\n useAnimatedKeyboardHandler,\n useSharedHandlers,\n useAnimatedValue,\n} from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\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\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n}: KeyboardProviderProps) => {\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 { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const 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 handler = 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\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\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}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAmB,cAAc;AACxE,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,eAAe,QAAQ,WAAW;AAC3C,SACEC,0BAA0B,EAC1BC,iBAAiB,EACjBC,gBAAgB,QACX,YAAY;AACnB,SAASC,sBAAsB,QAAQ,UAAU;AAQjD,MAAMC,8BAA8B,GAAGP,UAAU,CAACQ,uBAAuB,CACvEX,QAAQ,CAACW,uBAAuB,CAC9BF,sBAAsB,CACvB,CACF;AAOD,MAAMG,MAAM,GAAGV,UAAU,CAACW,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAwBF,OAAO,M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eyboardContext","useAnimatedKeyboardHandler","useSharedHandlers","useAnimatedValue","KeyboardControllerView","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","progress","height","progressSV","heightSV","setHandlers","broadcast","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","OS","value","handler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Animated, Platform, StyleSheet, ViewStyle } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardContext } from './context';\nimport {\n useAnimatedKeyboardHandler,\n useSharedHandlers,\n useAnimatedValue,\n} from './internal';\nimport { KeyboardControllerView } from './native';\n\nimport type {\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\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\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n}: KeyboardProviderProps) => {\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 { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo(\n () => ({\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n setHandlers,\n }),\n []\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const 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 handler = 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\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n onKeyboardMoveReanimated={handler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error will be fixed when migrate to REA 3.3.0\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,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAmB,cAAc;AACxE,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,eAAe,QAAQ,WAAW;AAC3C,SACEC,0BAA0B,EAC1BC,iBAAiB,EACjBC,gBAAgB,QACX,YAAY;AACnB,SAASC,sBAAsB,QAAQ,UAAU;AAQjD,MAAMC,8BAA8B,GAAGP,UAAU,CAACQ,uBAAuB,CACvEX,QAAQ,CAACW,uBAAuB,CAC9BF,sBAAsB,CACvB,CACF;AAOD,MAAMG,MAAM,GAAGV,UAAU,CAACW,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAwBF,OAAO,MAAMC,gBAAgB,GAAG,QAIH;EAAA,IAJI;IAC/BC,QAAQ;IACRC,oBAAoB;IACpBC;EACqB,CAAC;EACtB;EACA,MAAMC,QAAQ,GAAGf,gBAAgB,CAAC,CAAC,CAAC;EACpC,MAAMgB,MAAM,GAAGhB,gBAAgB,CAAC,CAAC,CAAC;EAClC;EACA,MAAMiB,UAAU,GAAGrB,cAAc,CAAC,CAAC,CAAC;EACpC,MAAMsB,QAAQ,GAAGtB,cAAc,CAAC,CAAC,CAAC;EAClC,MAAM;IAAEuB,WAAW;IAAEC;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D,cAAc,EAAGC,KAAkB,IAAK;MACtC,SAAS;;MAETV,SAAS,CAAC,QAAQ,EAAEU,KAAK,CAAC;MAC1BG,kBAAkB,CAACH,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACDU,iBAAiB,EAAGV,KAAkB,IAAK;MACzC,SAAS;;MAETV,SAAS,CAAC,OAAO,EAAEU,KAAK,CAAC;IAC3B,CAAC;IACDW,yBAAyB,EAAGX,KAAkB,IAAK;MACjD,SAAS;;MAETG,kBAAkB,CAACH,KAAK,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;MAC7CV,SAAS,CAAC,eAAe,EAAEU,KAAK,CAAC;IACnC;EACF,CAAC,EACD,EAAE,CACH;EAED,oBACE,oBAAC,eAAe,CAAC,QAAQ;IAAC,KAAK,EAAET;EAAQ,gBACvC,oBAAC,8BAA8B;IAC7B,wBAAwB,EAAEiB,OAAQ;IAClC,mBAAmB,EAAE7C,QAAQ,CAAC2C,EAAE,KAAK,KAAK,GAAGP,cAAc,GAAGa,SAAU;IACxE,cAAc,EAAEjD,QAAQ,CAAC2C,EAAE,KAAK,SAAS,GAAGP,cAAc,GAAGa,SAAU;IACvE,yBAAyB,EAAEb,cAAe;IAC1C,wBAAwB,EAAEf,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,EAAEa;EAAM,EACb,CACuB;AAE/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
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",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"pod-install": "^0.1.0",
|
|
71
71
|
"prettier": "^2.4.1",
|
|
72
72
|
"react": "18.2.0",
|
|
73
|
-
"react-native": "0.71.
|
|
73
|
+
"react-native": "0.71.11",
|
|
74
74
|
"react-native-builder-bob": "^0.18.0",
|
|
75
75
|
"react-native-reanimated": "2.14.4",
|
|
76
76
|
"release-it": "^14.2.2",
|
package/src/animated.tsx
CHANGED
|
@@ -149,6 +149,7 @@ export const KeyboardProvider = ({
|
|
|
149
149
|
onKeyboardMoveInteractive={onKeyboardMove}
|
|
150
150
|
navigationBarTranslucent={navigationBarTranslucent}
|
|
151
151
|
statusBarTranslucent={statusBarTranslucent}
|
|
152
|
+
// @ts-expect-error will be fixed when migrate to REA 3.3.0
|
|
152
153
|
style={styles.container}
|
|
153
154
|
>
|
|
154
155
|
{children}
|