react-native-keyboard-controller 1.14.1 → 1.14.3

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 (29) hide show
  1. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +5 -1
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputSelectionChangedEvent.kt +5 -1
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +5 -1
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/events/KeyboardTransitionEvent.kt +18 -2
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +16 -7
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +11 -7
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +1 -2
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/RootViewCompat.kt +18 -0
  9. package/ios/extensions/UIApplication.swift +1 -1
  10. package/ios/extensions/UIView.swift +28 -1
  11. package/ios/extensions/UIWindow.swift +5 -2
  12. package/ios/observers/FocusedInputObserver.swift +4 -4
  13. package/ios/views/OverKeyboardViewManager.mm +17 -0
  14. package/lib/commonjs/animated.js +10 -2
  15. package/lib/commonjs/animated.js.map +1 -1
  16. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +9 -4
  17. package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
  18. package/lib/commonjs/context.js +3 -1
  19. package/lib/commonjs/context.js.map +1 -1
  20. package/lib/module/animated.js +10 -2
  21. package/lib/module/animated.js.map +1 -1
  22. package/lib/module/components/KeyboardAvoidingView/hooks.js +9 -4
  23. package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
  24. package/lib/module/context.js +3 -1
  25. package/lib/module/context.js.map +1 -1
  26. package/package.json +5 -2
  27. package/src/animated.tsx +12 -2
  28. package/src/components/KeyboardAvoidingView/hooks.ts +10 -4
  29. package/src/context.ts +2 -0
@@ -20,7 +20,7 @@ class FocusedInputLayoutChangedEvent(
20
20
  viewId: Int,
21
21
  private val event: FocusedInputLayoutChangedEventData,
22
22
  ) : Event<FocusedInputLayoutChangedEvent>(surfaceId, viewId) {
23
- override fun getEventName() = "topFocusedInputLayoutChanged"
23
+ override fun getEventName() = EVENT_NAME
24
24
 
25
25
  // All events for a given view can be coalesced
26
26
  override fun getCoalescingKey(): Short = 0
@@ -41,4 +41,8 @@ class FocusedInputLayoutChangedEvent(
41
41
  },
42
42
  )
43
43
  }
44
+
45
+ companion object {
46
+ const val EVENT_NAME = "topFocusedInputLayoutChanged"
47
+ }
44
48
  }
@@ -19,7 +19,7 @@ class FocusedInputSelectionChangedEvent(
19
19
  viewId: Int,
20
20
  private val event: FocusedInputSelectionChangedEventData,
21
21
  ) : Event<FocusedInputSelectionChangedEvent>(surfaceId, viewId) {
22
- override fun getEventName() = "topFocusedInputSelectionChanged"
22
+ override fun getEventName() = EVENT_NAME
23
23
 
24
24
  // All events for a given view can be coalesced
25
25
  override fun getCoalescingKey(): Short = 0
@@ -49,4 +49,8 @@ class FocusedInputSelectionChangedEvent(
49
49
  },
50
50
  )
51
51
  }
52
+
53
+ companion object {
54
+ const val EVENT_NAME = "topFocusedInputSelectionChanged"
55
+ }
52
56
  }
@@ -9,7 +9,7 @@ class FocusedInputTextChangedEvent(
9
9
  viewId: Int,
10
10
  private val text: String,
11
11
  ) : Event<FocusedInputTextChangedEvent>(surfaceId, viewId) {
12
- override fun getEventName() = "topFocusedInputTextChanged"
12
+ override fun getEventName() = EVENT_NAME
13
13
 
14
14
  // All events for a given view can be coalesced
15
15
  override fun getCoalescingKey(): Short = 0
@@ -18,4 +18,8 @@ class FocusedInputTextChangedEvent(
18
18
  Arguments.createMap().apply {
19
19
  putString("text", text)
20
20
  }
21
+
22
+ companion object {
23
+ const val EVENT_NAME = "topFocusedInputTextChanged"
24
+ }
21
25
  }
@@ -8,13 +8,13 @@ import com.facebook.react.uimanager.events.Event
8
8
  class KeyboardTransitionEvent(
9
9
  surfaceId: Int,
10
10
  viewId: Int,
11
- private val event: String,
11
+ private val event: EventName,
12
12
  private val height: Double,
13
13
  private val progress: Double,
14
14
  private val duration: Int,
15
15
  private val target: Int,
16
16
  ) : Event<KeyboardTransitionEvent>(surfaceId, viewId) {
17
- override fun getEventName() = event
17
+ override fun getEventName() = event.value
18
18
 
19
19
  // All events for a given view can be coalesced?
20
20
  override fun getCoalescingKey(): Short = 0
@@ -26,4 +26,20 @@ class KeyboardTransitionEvent(
26
26
  putInt("duration", duration)
27
27
  putInt("target", target)
28
28
  }
29
+
30
+ companion object {
31
+ enum class EventName(
32
+ val value: String,
33
+ ) {
34
+ Move("topKeyboardMove"),
35
+ Start("topKeyboardMoveStart"),
36
+ End("topKeyboardMoveEnd"),
37
+ Interactive("topKeyboardMoveInteractive"),
38
+ }
39
+
40
+ val Move = EventName.Move
41
+ val Start = EventName.Start
42
+ val End = EventName.End
43
+ val Interactive = EventName.Interactive
44
+ }
29
45
  }
@@ -79,7 +79,7 @@ class KeyboardAnimationCallback(
79
79
  KeyboardTransitionEvent(
80
80
  surfaceId,
81
81
  eventPropagationView.id,
82
- "topKeyboardMoveStart",
82
+ KeyboardTransitionEvent.Start,
83
83
  this.persistentKeyboardHeight,
84
84
  1.0,
85
85
  0,
@@ -91,7 +91,7 @@ class KeyboardAnimationCallback(
91
91
  KeyboardTransitionEvent(
92
92
  surfaceId,
93
93
  eventPropagationView.id,
94
- "topKeyboardMoveEnd",
94
+ KeyboardTransitionEvent.End,
95
95
  this.persistentKeyboardHeight,
96
96
  1.0,
97
97
  0,
@@ -203,7 +203,7 @@ class KeyboardAnimationCallback(
203
203
  KeyboardTransitionEvent(
204
204
  surfaceId,
205
205
  eventPropagationView.id,
206
- "topKeyboardMoveStart",
206
+ KeyboardTransitionEvent.Start,
207
207
  keyboardHeight,
208
208
  if (!isKeyboardVisible) 0.0 else 1.0,
209
209
  duration,
@@ -258,7 +258,12 @@ class KeyboardAnimationCallback(
258
258
  "DiffY: $diffY $height $progress ${InteractiveKeyboardProvider.isInteractive} $viewTagFocused",
259
259
  )
260
260
 
261
- val event = if (InteractiveKeyboardProvider.isInteractive) "topKeyboardMoveInteractive" else "topKeyboardMove"
261
+ val event =
262
+ if (InteractiveKeyboardProvider.isInteractive) {
263
+ KeyboardTransitionEvent.Interactive
264
+ } else {
265
+ KeyboardTransitionEvent.Move
266
+ }
262
267
  context.dispatchEvent(
263
268
  eventPropagationView.id,
264
269
  KeyboardTransitionEvent(
@@ -315,7 +320,7 @@ class KeyboardAnimationCallback(
315
320
  KeyboardTransitionEvent(
316
321
  surfaceId,
317
322
  eventPropagationView.id,
318
- "topKeyboardMoveEnd",
323
+ KeyboardTransitionEvent.End,
319
324
  keyboardHeight,
320
325
  if (!isKeyboardVisible) 0.0 else 1.0,
321
326
  duration,
@@ -343,7 +348,7 @@ class KeyboardAnimationCallback(
343
348
  getEventParams(keyboardHeight),
344
349
  )
345
350
  // dispatch `onMove` to update RN animated value and `onEnd` to indicate that transition finished
346
- listOf("topKeyboardMove", "topKeyboardMoveEnd").forEach { eventName ->
351
+ listOf(KeyboardTransitionEvent.Move, KeyboardTransitionEvent.End).forEach { eventName ->
347
352
  context.dispatchEvent(
348
353
  eventPropagationView.id,
349
354
  KeyboardTransitionEvent(
@@ -371,7 +376,11 @@ class KeyboardAnimationCallback(
371
376
  duration = 0
372
377
 
373
378
  context.emitEvent("KeyboardController::keyboardWillShow", getEventParams(keyboardHeight))
374
- listOf("topKeyboardMoveStart", "topKeyboardMove", "topKeyboardMoveEnd").forEach { eventName ->
379
+ listOf(
380
+ KeyboardTransitionEvent.Start,
381
+ KeyboardTransitionEvent.Move,
382
+ KeyboardTransitionEvent.End,
383
+ ).forEach { eventName ->
375
384
  context.dispatchEvent(
376
385
  eventPropagationView.id,
377
386
  KeyboardTransitionEvent(
@@ -3,6 +3,10 @@ package com.reactnativekeyboardcontroller.managers
3
3
  import com.facebook.react.bridge.ReactApplicationContext
4
4
  import com.facebook.react.common.MapBuilder
5
5
  import com.facebook.react.uimanager.ThemedReactContext
6
+ import com.reactnativekeyboardcontroller.events.FocusedInputLayoutChangedEvent
7
+ import com.reactnativekeyboardcontroller.events.FocusedInputSelectionChangedEvent
8
+ import com.reactnativekeyboardcontroller.events.FocusedInputTextChangedEvent
9
+ import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
6
10
  import com.reactnativekeyboardcontroller.views.EdgeToEdgeReactViewGroup
7
11
 
8
12
  @Suppress("detekt:UnusedPrivateProperty")
@@ -36,19 +40,19 @@ class KeyboardControllerViewManagerImpl(
36
40
  fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
37
41
  val map: MutableMap<String, Any> =
38
42
  MapBuilder.of(
39
- "topKeyboardMove",
43
+ KeyboardTransitionEvent.Move.value,
40
44
  MapBuilder.of("registrationName", "onKeyboardMove"),
41
- "topKeyboardMoveStart",
45
+ KeyboardTransitionEvent.Start.value,
42
46
  MapBuilder.of("registrationName", "onKeyboardMoveStart"),
43
- "topKeyboardMoveEnd",
47
+ KeyboardTransitionEvent.End.value,
44
48
  MapBuilder.of("registrationName", "onKeyboardMoveEnd"),
45
- "topKeyboardMoveInteractive",
49
+ KeyboardTransitionEvent.Interactive.value,
46
50
  MapBuilder.of("registrationName", "onKeyboardMoveInteractive"),
47
- "topFocusedInputLayoutChanged",
51
+ FocusedInputLayoutChangedEvent.EVENT_NAME,
48
52
  MapBuilder.of("registrationName", "onFocusedInputLayoutChanged"),
49
- "topFocusedInputTextChanged",
53
+ FocusedInputTextChangedEvent.EVENT_NAME,
50
54
  MapBuilder.of("registrationName", "onFocusedInputTextChanged"),
51
- "topFocusedInputSelectionChanged",
55
+ FocusedInputSelectionChangedEvent.EVENT_NAME,
52
56
  MapBuilder.of("registrationName", "onFocusedInputSelectionChanged"),
53
57
  )
54
58
 
@@ -10,7 +10,6 @@ import com.facebook.react.bridge.UiThreadUtil
10
10
  import com.facebook.react.config.ReactFeatureFlags
11
11
  import com.facebook.react.uimanager.JSPointerDispatcher
12
12
  import com.facebook.react.uimanager.JSTouchDispatcher
13
- import com.facebook.react.uimanager.RootView
14
13
  import com.facebook.react.uimanager.ThemedReactContext
15
14
  import com.facebook.react.uimanager.UIManagerHelper
16
15
  import com.facebook.react.uimanager.events.EventDispatcher
@@ -98,7 +97,7 @@ class OverKeyboardHostView(
98
97
  class OverKeyboardRootViewGroup(
99
98
  private val reactContext: ThemedReactContext,
100
99
  ) : ReactViewGroup(reactContext),
101
- RootView {
100
+ RootViewCompat {
102
101
  private val jsTouchDispatcher: JSTouchDispatcher = JSTouchDispatcher(this)
103
102
  private var jsPointerDispatcher: JSPointerDispatcher? = null
104
103
  internal var eventDispatcher: EventDispatcher? = null
@@ -0,0 +1,18 @@
1
+ package com.reactnativekeyboardcontroller.views.overlay
2
+
3
+ import android.view.MotionEvent
4
+ import com.facebook.react.uimanager.RootView
5
+
6
+ /**
7
+ * Compat layer for `RootView` interface for RN < 0.73
8
+ * which has a default implementation of deprecated method.
9
+ */
10
+ interface RootViewCompat : RootView {
11
+ @Deprecated(
12
+ "This method shouldn't be used anymore.",
13
+ ReplaceWith("onChildStartedNativeGesture(View childView, MotionEvent ev)"),
14
+ )
15
+ override fun onChildStartedNativeGesture(ev: MotionEvent?) {
16
+ onChildStartedNativeGesture(null, ev)
17
+ }
18
+ }
@@ -26,7 +26,7 @@ public extension UIApplication {
26
26
  }
27
27
 
28
28
  static func topViewController(
29
- base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
29
+ base: UIViewController? = UIApplication.shared.activeWindow?.rootViewController
30
30
  ) -> UIViewController? {
31
31
  if let nav = base as? UINavigationController {
32
32
  return topViewController(base: nav.visibleViewController)
@@ -11,9 +11,29 @@ import UIKit
11
11
 
12
12
  public extension UIView {
13
13
  var globalFrame: CGRect? {
14
- let rootView = UIApplication.shared.keyWindow?.rootViewController?.view
14
+ let rootView = UIApplication.shared.activeWindow?.rootViewController?.view
15
15
  return superview?.convert(frame, to: rootView)
16
16
  }
17
+
18
+ func isVisibleInHierarchy(initial: Bool = true) -> Bool {
19
+ guard let window = window else {
20
+ return false
21
+ }
22
+ if isHidden || alpha == 0.0 {
23
+ return false
24
+ }
25
+ if superview === window {
26
+ return true
27
+ } else if let superview = superview {
28
+ if initial, frame.minY >= superview.frame.height {
29
+ return false
30
+ } else {
31
+ return superview.isVisibleInHierarchy(initial: false)
32
+ }
33
+ } else {
34
+ return false
35
+ }
36
+ }
17
37
  }
18
38
 
19
39
  public extension Optional where Wrapped == UIView {
@@ -32,4 +52,11 @@ public extension Optional where Wrapped == UIView {
32
52
 
33
53
  return (position, frameY)
34
54
  }
55
+
56
+ func isVisibleInHierarchy(initial: Bool = true) -> Bool {
57
+ guard let view = self else {
58
+ return false
59
+ }
60
+ return view.isVisibleInHierarchy(initial: initial)
61
+ }
35
62
  }
@@ -37,8 +37,11 @@ public extension UIWindow {
37
37
  }
38
38
 
39
39
  func getTopWindow() -> UIWindow? {
40
- // Return the keyboard window if it's available, otherwise return the last window
41
- return keyboardWindow ?? UIApplication.shared.activeWindow
40
+ let keyboardView = KeyboardView.find()
41
+ // return the keyboard window if it's available and keyboard is visible, otherwise return the last window
42
+ return (keyboardWindow != nil && keyboardView.isVisibleInHierarchy())
43
+ ? keyboardWindow
44
+ : UIApplication.shared.activeWindow
42
45
  }
43
46
  }
44
47
 
@@ -204,10 +204,10 @@ public class FocusedInputObserver: NSObject {
204
204
  }
205
205
 
206
206
  private func substituteDelegateBack(_ input: UIResponder?) {
207
- if let textField = input as? UITextField {
208
- textField.delegate = delegate.activeDelegate as? UITextFieldDelegate
209
- } else if let textView = input as? UITextView {
210
- (textView as? RCTUITextView)?.setForceDelegate(delegate.activeDelegate as? UITextViewDelegate)
207
+ if let textField = input as? UITextField, let oldDelegate = delegate.activeDelegate as? UITextFieldDelegate {
208
+ textField.delegate = oldDelegate
209
+ } else if let textView = input as? UITextView, let oldDelegate = delegate.activeDelegate as? UITextViewDelegate {
210
+ (textView as? RCTUITextView)?.setForceDelegate(oldDelegate)
211
211
  }
212
212
  }
213
213
 
@@ -102,10 +102,27 @@ RCT_EXPORT_VIEW_PROPERTY(visible, BOOL)
102
102
  _touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge];
103
103
  _contentView = [[UIView alloc] initWithFrame:CGRectZero];
104
104
  }
105
+ [[NSNotificationCenter defaultCenter] addObserver:self
106
+ selector:@selector(hide)
107
+ name:RCTJavaScriptWillStartLoadingNotification
108
+ object:nil];
105
109
  return self;
106
110
  }
107
111
  #endif
108
112
 
113
+ - (void)dealloc
114
+ {
115
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
116
+ }
117
+
118
+ // MARK: lifecycle methods
119
+ - (void)didMoveToSuperview
120
+ {
121
+ if (self.superview == nil) {
122
+ [self hide];
123
+ }
124
+ }
125
+
109
126
  // MARK: touch handling
110
127
  - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
111
128
  {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.KeyboardProvider = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
+ var _reactNativeIsEdgeToEdge = require("react-native-is-edge-to-edge");
9
10
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
11
  var _bindings = require("./bindings");
11
12
  var _context = require("./context");
@@ -17,6 +18,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
17
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
19
  /* eslint react/jsx-sort-props: off */
19
20
 
21
+ const IS_EDGE_TO_EDGE = (0, _reactNativeIsEdgeToEdge.isEdgeToEdge)();
20
22
  const KeyboardControllerViewAnimated = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.Animated.createAnimatedComponent(_bindings.KeyboardControllerView));
21
23
  const styles = _reactNative.StyleSheet.create({
22
24
  container: {
@@ -127,13 +129,19 @@ const KeyboardProvider = ({
127
129
  (0, _monkeyPatch.revertMonkeyPatch)();
128
130
  }
129
131
  }, [enabled]);
132
+ if (__DEV__) {
133
+ (0, _reactNativeIsEdgeToEdge.controlEdgeToEdgeValues)({
134
+ statusBarTranslucent,
135
+ navigationBarTranslucent
136
+ });
137
+ }
130
138
  return /*#__PURE__*/_react.default.createElement(_context.KeyboardContext.Provider, {
131
139
  value: context
132
140
  }, /*#__PURE__*/_react.default.createElement(KeyboardControllerViewAnimated, {
133
141
  ref: viewTagRef,
134
142
  enabled: enabled,
135
- navigationBarTranslucent: navigationBarTranslucent,
136
- statusBarTranslucent: statusBarTranslucent,
143
+ navigationBarTranslucent: IS_EDGE_TO_EDGE || navigationBarTranslucent,
144
+ statusBarTranslucent: IS_EDGE_TO_EDGE || statusBarTranslucent,
137
145
  style: styles.container
138
146
  // on*Reanimated prop must precede animated handlers to work correctly
139
147
  ,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_bindings","_context","_eventMappings","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","applyMonkeyPatch","revertMonkeyPatch","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, 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 { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\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(KeyboardControllerView),\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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\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 = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\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(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\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 updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\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\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 ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\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":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAGsB,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,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,EAAE/C,UAAW;IAChBF,OAAO,EAAEA,OAAQ;IACjBD,wBAAwB,EAAEA,wBAAyB;IACnDD,oBAAoB,EAAEA,oBAAqB;IAC3CyB,KAAK,EAAErC,MAAM,CAACG;IACd;IAAA;IACA6D,wBAAwB,EAAEf,eAAgB;IAC1CE,mBAAmB,EAAE3C,EAAE,KAAK,KAAK,GAAGiC,cAAc,GAAGwB,SAAU;IAC/DxB,cAAc,EAAEjC,EAAE,KAAK,SAAS,GAAGiC,cAAc,GAAGwB,SAAU;IAC9Db,yBAAyB,EAAEX,cAAe;IAC1CyB,qCAAqC,EAAEb;EAAmB,GAEzD1C,QAC6B,CAAC,eACjC/C,MAAA,CAAAiB,OAAA,CAAA+E,aAAA,CAAC7F,YAAA,CAAA+B,QAAQ,CAACqE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA9B,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAAC+B,OAAA,CAAA1D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeIsEdgeToEdge","_reactNativeReanimated","_bindings","_context","_eventMappings","_internal","_monkeyPatch","_reanimated","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","IS_EDGE_TO_EDGE","isEdgeToEdge","KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","OS","Platform","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","viewTagRef","useRef","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","useEventHandlerRegistration","keyboardEventsMap","setInputHandlers","focusedInputEventsMap","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","target","useEffect","applyMonkeyPatch","revertMonkeyPatch","__DEV__","controlEdgeToEdgeValues","createElement","KeyboardContext","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View","exports"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\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 IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\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 = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\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(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\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 updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\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\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({ statusBarTranslucent, navigationBarTranslucent });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\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":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAGsB,SAAAU,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAA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C;IAAyB,CAAC,CAAC;EAC7E;EAEA,oBACEpD,MAAA,CAAAkB,OAAA,CAAAmF,aAAA,CAAC9F,QAAA,CAAA+F,eAAe,CAACC,QAAQ;IAAChB,KAAK,EAAEhB;EAAQ,gBACvCvE,MAAA,CAAAkB,OAAA,CAAAmF,aAAA,CAACnE,8BAA8B;IAC7BsE,GAAG,EAAEjD,UAAW;IAChBF,OAAO,EAAEA,OAAQ;IACjBD,wBAAwB,EAAEpB,eAAe,IAAIoB,wBAAyB;IACtED,oBAAoB,EAAEnB,eAAe,IAAImB,oBAAqB;IAC9DyB,KAAK,EAAErC,MAAM,CAACG;IACd;IAAA;IACA+D,wBAAwB,EAAEjB,eAAgB;IAC1CE,mBAAmB,EAAE3C,EAAE,KAAK,KAAK,GAAGiC,cAAc,GAAG0B,SAAU;IAC/D1B,cAAc,EAAEjC,EAAE,KAAK,SAAS,GAAGiC,cAAc,GAAG0B,SAAU;IAC9Df,yBAAyB,EAAEX,cAAe;IAC1C2B,qCAAqC,EAAEf;EAAmB,GAEzD1C,QAC6B,CAAC,eACjClD,MAAA,CAAAkB,OAAA,CAAAmF,aAAA,CAAClG,YAAA,CAAAkC,QAAQ,CAACuE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAhC,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC;AAACiC,OAAA,CAAA5D,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useKeyboardAnimation = void 0;
7
+ var _react = require("react");
7
8
  var _reactNativeReanimated = require("react-native-reanimated");
8
9
  var _context = require("../../context");
9
10
  var _hooks = require("../../hooks");
@@ -11,10 +12,14 @@ const useKeyboardAnimation = () => {
11
12
  const {
12
13
  reanimated
13
14
  } = (0, _context.useKeyboardContext)();
14
- const heightWhenOpened = (0, _reactNativeReanimated.useSharedValue)(-reanimated.height.value);
15
- const height = (0, _reactNativeReanimated.useSharedValue)(-reanimated.height.value);
16
- const progress = (0, _reactNativeReanimated.useSharedValue)(reanimated.progress.value);
17
- const isClosed = (0, _reactNativeReanimated.useSharedValue)(reanimated.progress.value === 0);
15
+
16
+ // calculate it only once on mount, to avoid `SharedValue` reads during a render
17
+ const [initialHeight] = (0, _react.useState)(() => -reanimated.height.value);
18
+ const [initialProgress] = (0, _react.useState)(() => reanimated.progress.value);
19
+ const heightWhenOpened = (0, _reactNativeReanimated.useSharedValue)(initialHeight);
20
+ const height = (0, _reactNativeReanimated.useSharedValue)(initialHeight);
21
+ const progress = (0, _reactNativeReanimated.useSharedValue)(initialProgress);
22
+ const isClosed = (0, _reactNativeReanimated.useSharedValue)(initialProgress === 0);
18
23
  (0, _hooks.useKeyboardHandler)({
19
24
  onStart: e => {
20
25
  "worklet";
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeReanimated","require","_context","_hooks","useKeyboardAnimation","reanimated","useKeyboardContext","heightWhenOpened","useSharedValue","height","value","progress","isClosed","useKeyboardHandler","onStart","e","onMove","onInteractive","onEnd","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardContext } from \"../../context\";\nimport { useKeyboardHandler } from \"../../hooks\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\n const height = useSharedValue(-reanimated.height.value);\n const progress = useSharedValue(reanimated.progress.value);\n const isClosed = useSharedValue(reanimated.progress.value === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n height.value = e.height;\n progress.value = e.progress;\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAC3C,MAAMC,gBAAgB,GAAG,IAAAC,qCAAc,EAAC,CAACH,UAAU,CAACI,MAAM,CAACC,KAAK,CAAC;EACjE,MAAMD,MAAM,GAAG,IAAAD,qCAAc,EAAC,CAACH,UAAU,CAACI,MAAM,CAACC,KAAK,CAAC;EACvD,MAAMC,QAAQ,GAAG,IAAAH,qCAAc,EAACH,UAAU,CAACM,QAAQ,CAACD,KAAK,CAAC;EAC1D,MAAME,QAAQ,GAAG,IAAAJ,qCAAc,EAACH,UAAU,CAACM,QAAQ,CAACD,KAAK,KAAK,CAAC,CAAC;EAEhE,IAAAG,yBAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACN,MAAM,GAAG,CAAC,EAAE;QAChB;QACAG,QAAQ,CAACF,KAAK,GAAG,KAAK;QACtBH,gBAAgB,CAACG,KAAK,GAAGK,CAAC,CAACN,MAAM;MACnC;IACF,CAAC;IACDO,MAAM,EAAGD,CAAC,IAAK;MACb,SAAS;;MAETJ,QAAQ,CAACD,KAAK,GAAGK,CAAC,CAACJ,QAAQ;MAC3BF,MAAM,CAACC,KAAK,GAAGK,CAAC,CAACN,MAAM;IACzB,CAAC;IACDQ,aAAa,EAAGF,CAAC,IAAK;MACpB,SAAS;;MAETJ,QAAQ,CAACD,KAAK,GAAGK,CAAC,CAACJ,QAAQ;MAC3BF,MAAM,CAACC,KAAK,GAAGK,CAAC,CAACN,MAAM;IACzB,CAAC;IACDS,KAAK,EAAGH,CAAC,IAAK;MACZ,SAAS;;MAETH,QAAQ,CAACF,KAAK,GAAGK,CAAC,CAACN,MAAM,KAAK,CAAC;MAE/BA,MAAM,CAACC,KAAK,GAAGK,CAAC,CAACN,MAAM;MACvBE,QAAQ,CAACD,KAAK,GAAGK,CAAC,CAACJ,QAAQ;IAC7B;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEF,MAAM;IAAEE,QAAQ;IAAEJ,gBAAgB;IAAEK;EAAS,CAAC;AACzD,CAAC;AAACO,OAAA,CAAAf,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNativeReanimated","_context","_hooks","useKeyboardAnimation","reanimated","useKeyboardContext","initialHeight","useState","height","value","initialProgress","progress","heightWhenOpened","useSharedValue","isClosed","useKeyboardHandler","onStart","e","onMove","onInteractive","onEnd","exports"],"sources":["hooks.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardContext } from \"../../context\";\nimport { useKeyboardHandler } from \"../../hooks\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n\n // calculate it only once on mount, to avoid `SharedValue` reads during a render\n const [initialHeight] = useState(() => -reanimated.height.value);\n const [initialProgress] = useState(() => reanimated.progress.value);\n\n const heightWhenOpened = useSharedValue(initialHeight);\n const height = useSharedValue(initialHeight);\n const progress = useSharedValue(initialProgress);\n const isClosed = useSharedValue(initialProgress === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n height.value = e.height;\n progress.value = e.progress;\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,MAAMI,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAG,IAAAC,2BAAkB,EAAC,CAAC;;EAE3C;EACA,MAAM,CAACC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM,CAACH,UAAU,CAACI,MAAM,CAACC,KAAK,CAAC;EAChE,MAAM,CAACC,eAAe,CAAC,GAAG,IAAAH,eAAQ,EAAC,MAAMH,UAAU,CAACO,QAAQ,CAACF,KAAK,CAAC;EAEnE,MAAMG,gBAAgB,GAAG,IAAAC,qCAAc,EAACP,aAAa,CAAC;EACtD,MAAME,MAAM,GAAG,IAAAK,qCAAc,EAACP,aAAa,CAAC;EAC5C,MAAMK,QAAQ,GAAG,IAAAE,qCAAc,EAACH,eAAe,CAAC;EAChD,MAAMI,QAAQ,GAAG,IAAAD,qCAAc,EAACH,eAAe,KAAK,CAAC,CAAC;EAEtD,IAAAK,yBAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACT,MAAM,GAAG,CAAC,EAAE;QAChB;QACAM,QAAQ,CAACL,KAAK,GAAG,KAAK;QACtBG,gBAAgB,CAACH,KAAK,GAAGQ,CAAC,CAACT,MAAM;MACnC;IACF,CAAC;IACDU,MAAM,EAAGD,CAAC,IAAK;MACb,SAAS;;MAETN,QAAQ,CAACF,KAAK,GAAGQ,CAAC,CAACN,QAAQ;MAC3BH,MAAM,CAACC,KAAK,GAAGQ,CAAC,CAACT,MAAM;IACzB,CAAC;IACDW,aAAa,EAAGF,CAAC,IAAK;MACpB,SAAS;;MAETN,QAAQ,CAACF,KAAK,GAAGQ,CAAC,CAACN,QAAQ;MAC3BH,MAAM,CAACC,KAAK,GAAGQ,CAAC,CAACT,MAAM;IACzB,CAAC;IACDY,KAAK,EAAGH,CAAC,IAAK;MACZ,SAAS;;MAETH,QAAQ,CAACL,KAAK,GAAGQ,CAAC,CAACT,MAAM,KAAK,CAAC;MAE/BA,MAAM,CAACC,KAAK,GAAGQ,CAAC,CAACT,MAAM;MACvBG,QAAQ,CAACF,KAAK,GAAGQ,CAAC,CAACN,QAAQ;IAC7B;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEH,MAAM;IAAEG,QAAQ;IAAEC,gBAAgB;IAAEE;EAAS,CAAC;AACzD,CAAC;AAACO,OAAA,CAAAlB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -12,7 +12,9 @@ const withSharedValue = value => ({
12
12
  value,
13
13
  addListener: NOOP,
14
14
  removeListener: NOOP,
15
- modify: NOOP
15
+ modify: NOOP,
16
+ get: () => value,
17
+ set: NOOP
16
18
  });
17
19
  const DEFAULT_SHARED_VALUE = withSharedValue(0);
18
20
  const DEFAULT_LAYOUT = withSharedValue(null);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","exports","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;\n setInputHandlers: (handlers: FocusedInputHandler) => () => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA2BA,MAAME,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN;AACV,CAAC,CAAC;AACF,MAAMO,oBAAoB,GAAGL,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMM,cAAc,GAAGN,eAAe,CACpC,IACF,CAAC;AACD,MAAMO,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAEL,oBAAoB;IAC9BQ,MAAM,EAAER;EACV,CAAC;EACDU,MAAM,EAAET,cAAc;EACtBU,mBAAmB,EAAEjB,WAAW;EAChCkB,gBAAgB,EAAElB,WAAW;EAC7BmB,UAAU,EAAEpB;AACd,CAAC;AAEM,MAAMqB,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,oBAAa,EAACd,cAAc,CAAC;AACrD,MAAMe,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,eAAe,CAAC;EAE3C,IAAIM,OAAO,IAAIF,OAAO,KAAKhB,cAAc,EAAE;IACzCmB,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOJ,OAAO;AAChB,CAAC;AAACH,OAAA,CAAAE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","exports","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;\n setInputHandlers: (handlers: FocusedInputHandler) => () => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n get: () => value,\n set: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;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ort-props: off */
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Animated, Platform, StyleSheet } from "react-native";
4
+ import { controlEdgeToEdgeValues, isEdgeToEdge } from "react-native-is-edge-to-edge";
4
5
  import Reanimated, { useSharedValue } from "react-native-reanimated";
5
6
  import { KeyboardControllerView } from "./bindings";
6
7
  import { KeyboardContext } from "./context";
@@ -8,6 +9,7 @@ import { focusedInputEventsMap, keyboardEventsMap } from "./event-mappings";
8
9
  import { useAnimatedValue, useEventHandlerRegistration } from "./internal";
9
10
  import { applyMonkeyPatch, revertMonkeyPatch } from "./monkey-patch";
10
11
  import { useAnimatedKeyboardHandler, useFocusedInputLayoutHandler } from "./reanimated";
12
+ const IS_EDGE_TO_EDGE = isEdgeToEdge();
11
13
  const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(Animated.createAnimatedComponent(KeyboardControllerView));
12
14
  const styles = StyleSheet.create({
13
15
  container: {
@@ -118,13 +120,19 @@ export const KeyboardProvider = ({
118
120
  revertMonkeyPatch();
119
121
  }
120
122
  }, [enabled]);
123
+ if (__DEV__) {
124
+ controlEdgeToEdgeValues({
125
+ statusBarTranslucent,
126
+ navigationBarTranslucent
127
+ });
128
+ }
121
129
  return /*#__PURE__*/React.createElement(KeyboardContext.Provider, {
122
130
  value: context
123
131
  }, /*#__PURE__*/React.createElement(KeyboardControllerViewAnimated, {
124
132
  ref: viewTagRef,
125
133
  enabled: enabled,
126
- navigationBarTranslucent: navigationBarTranslucent,
127
- statusBarTranslucent: statusBarTranslucent,
134
+ navigationBarTranslucent: IS_EDGE_TO_EDGE || navigationBarTranslucent,
135
+ statusBarTranslucent: IS_EDGE_TO_EDGE || statusBarTranslucent,
128
136
  style: styles.container
129
137
  // on*Reanimated prop must precede animated handlers to work correctly
130
138
  ,
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useMemo","useRef","useState","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","focusedInputEventsMap","keyboardEventsMap","useAnimatedValue","useEventHandlerRegistration","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","viewTagRef","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","setInputHandlers","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","createElement","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, 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 { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\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(KeyboardControllerView),\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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\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 = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\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(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\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 updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\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\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 ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\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,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnE,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,qBAAqB,EAAEC,iBAAiB,QAAQ,kBAAkB;AAC3E,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,YAAY;AAC1E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpE,SACEC,0BAA0B,EAC1BC,4BAA4B,QACvB,cAAc;AAYrB,MAAMC,8BAA8B,GAAGZ,UAAU,CAACa,uBAAuB,CACvEhB,QAAQ,CAACgB,uBAAuB,CAACX,sBAAsB,CACzD,CAAC;AAOD,MAAMY,MAAM,GAAGf,UAAU,CAACgB,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AA+BF;AACA;AACA,MAAMC,EAAE,GAAGvB,QAAQ,CAACuB,EAAE;AAEtB,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,QAAQ;EACRC,oBAAoB;EACpBC,wBAAwB;EACxBC,OAAO,EAAEC,gBAAg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AiB,CAAC,CAAC;IACrB;EACF,CAAC,EAAE,CAACiB,OAAO,CAAC,CAAC;EAEb,oBACElC,KAAA,CAAAoE,aAAA,CAACzD,eAAe,CAAC0D,QAAQ;IAACT,KAAK,EAAEf;EAAQ,gBACvC7C,KAAA,CAAAoE,aAAA,CAAChD,8BAA8B;IAC7BkD,GAAG,EAAElC,UAAW;IAChBF,OAAO,EAAEA,OAAQ;IACjBD,wBAAwB,EAAEA,wBAAyB;IACnDD,oBAAoB,EAAEA,oBAAqB;IAC3CiB,KAAK,EAAE3B,MAAM,CAACE;IACd;IAAA;IACA+C,wBAAwB,EAAEV,eAAgB;IAC1CC,mBAAmB,EAAEjC,EAAE,KAAK,KAAK,GAAGwB,cAAc,GAAGmB,SAAU;IAC/DnB,cAAc,EAAExB,EAAE,KAAK,SAAS,GAAGwB,cAAc,GAAGmB,SAAU;IAC9DT,yBAAyB,EAAEV,cAAe;IAC1CoB,qCAAqC,EAAET;EAAmB,GAEzDjC,QAC6B,CAAC,eACjC/B,KAAA,CAAAoE,aAAA,CAAC/D,QAAQ,CAACqE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAzB,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","useMemo","useRef","useState","Animated","Platform","StyleSheet","controlEdgeToEdgeValues","isEdgeToEdge","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","focusedInputEventsMap","keyboardEventsMap","useAnimatedValue","useEventHandlerRegistration","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","IS_EDGE_TO_EDGE","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","viewTagRef","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","setInputHandlers","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","__DEV__","createElement","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\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 IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\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 = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\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(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\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 updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\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\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({ statusBarTranslucent, navigationBarTranslucent });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\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,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAC7D,SACEC,uBAAuB,EACvBC,YAAY,QACP,8BAA8B;AACrC,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,kBAAkB;AAC3E,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,YAAY;AAC1E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpE,SACEC,0BAA0B,EAC1BC,4BAA4B,QACvB,cAAc;AAYrB,MAAMC,eAAe,GAAGb,YAAY,CAAC,CAAC;AAEtC,MAAMc,8BAA8B,GAAGb,UAAU,CAACc,uBAAuB,CACvEnB,QAAQ,CAACmB,uBAAuB,CAACZ,sBAAsB,CACzD,CAAC;AAOD,MAAMa,MAAM,GAAGlB,UAAU,CAACmB,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AA+BF;AACA;AACA,MAAMC,EAAE,GAAG1B,QAAQ,CAAC0B,EAAE;AAEtB,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,QAAQ;EACRC,oBAAoB;EACpBC,wBAAwB;EACxBC,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MAAM;MACLC,iBAAiB,CAAC,CAAC;IACrB;EACF,CAAC,EAAE,CAACkB,OAAO,CAAC,CAAC;EAEb,IAAIkC,OAAO,EAAE;IACX/D,uBAAuB,CAAC;MAAE2B,oBAAoB;MAAEC;IAAyB,CAAC,CAAC;EAC7E;EAEA,oBACEpC,KAAA,CAAAwE,aAAA,CAAC3D,eAAe,CAAC4D,QAAQ;IAACV,KAAK,EAAEf;EAAQ,gBACvChD,KAAA,CAAAwE,aAAA,CAACjD,8BAA8B;IAC7BmD,GAAG,EAAEnC,UAAW;IAChBF,OAAO,EAAEA,OAAQ;IACjBD,wBAAwB,EAAEd,eAAe,IAAIc,wBAAyB;IACtED,oBAAoB,EAAEb,eAAe,IAAIa,oBAAqB;IAC9DiB,KAAK,EAAE3B,MAAM,CAACE;IACd;IAAA;IACAgD,wBAAwB,EAAEX,eAAgB;IAC1CC,mBAAmB,EAAEjC,EAAE,KAAK,KAAK,GAAGwB,cAAc,GAAGoB,SAAU;IAC/DpB,cAAc,EAAExB,EAAE,KAAK,SAAS,GAAGwB,cAAc,GAAGoB,SAAU;IAC9DV,yBAAyB,EAAEV,cAAe;IAC1CqB,qCAAqC,EAAEV;EAAmB,GAEzDjC,QAC6B,CAAC,eACjClC,KAAA,CAAAwE,aAAA,CAACnE,QAAQ,CAACyE,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA1B,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ import { useState } from "react";
1
2
  import { useSharedValue } from "react-native-reanimated";
2
3
  import { useKeyboardContext } from "../../context";
3
4
  import { useKeyboardHandler } from "../../hooks";
@@ -5,10 +6,14 @@ export const useKeyboardAnimation = () => {
5
6
  const {
6
7
  reanimated
7
8
  } = useKeyboardContext();
8
- const heightWhenOpened = useSharedValue(-reanimated.height.value);
9
- const height = useSharedValue(-reanimated.height.value);
10
- const progress = useSharedValue(reanimated.progress.value);
11
- const isClosed = useSharedValue(reanimated.progress.value === 0);
9
+
10
+ // calculate it only once on mount, to avoid `SharedValue` reads during a render
11
+ const [initialHeight] = useState(() => -reanimated.height.value);
12
+ const [initialProgress] = useState(() => reanimated.progress.value);
13
+ const heightWhenOpened = useSharedValue(initialHeight);
14
+ const height = useSharedValue(initialHeight);
15
+ const progress = useSharedValue(initialProgress);
16
+ const isClosed = useSharedValue(initialProgress === 0);
12
17
  useKeyboardHandler({
13
18
  onStart: e => {
14
19
  "worklet";
@@ -1 +1 @@
1
- {"version":3,"names":["useSharedValue","useKeyboardContext","useKeyboardHandler","useKeyboardAnimation","reanimated","heightWhenOpened","height","value","progress","isClosed","onStart","e","onMove","onInteractive","onEnd"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardContext } from \"../../context\";\nimport { useKeyboardHandler } from \"../../hooks\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n const heightWhenOpened = useSharedValue(-reanimated.height.value);\n const height = useSharedValue(-reanimated.height.value);\n const progress = useSharedValue(reanimated.progress.value);\n const isClosed = useSharedValue(reanimated.progress.value === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n height.value = e.height;\n progress.value = e.progress;\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SAASC,kBAAkB,QAAQ,eAAe;AAClD,SAASC,kBAAkB,QAAQ,aAAa;AAEhD,OAAO,MA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F,MAAM;IAAEE,QAAQ;IAAEH,gBAAgB;IAAEI;EAAS,CAAC;AACzD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useState","useSharedValue","useKeyboardContext","useKeyboardHandler","useKeyboardAnimation","reanimated","initialHeight","height","value","initialProgress","progress","heightWhenOpened","isClosed","onStart","e","onMove","onInteractive","onEnd"],"sources":["hooks.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { useSharedValue } from \"react-native-reanimated\";\n\nimport { useKeyboardContext } from \"../../context\";\nimport { useKeyboardHandler } from \"../../hooks\";\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n\n // calculate it only once on mount, to avoid `SharedValue` reads during a render\n const [initialHeight] = useState(() => -reanimated.height.value);\n const [initialProgress] = useState(() => reanimated.progress.value);\n\n const heightWhenOpened = useSharedValue(initialHeight);\n const height = useSharedValue(initialHeight);\n const progress = useSharedValue(initialProgress);\n const isClosed = useSharedValue(initialProgress === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n\n isClosed.value = e.height === 0;\n\n height.value = e.height;\n progress.value = e.progress;\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,cAAc,QAAQ,yBAAyB;AAExD,SAASC,kBAAkB,QAAQ,eAAe;AAClD,SAASC,kBAAkB,QAAQ,aAAa;AAEhD,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAGH,kBAAkB,CAAC,CAAC;;EAE3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AAEH,MAAM;IAAEG,QAAQ;IAAEC,gBAAgB;IAAEC;EAAS,CAAC;AACzD,CAAC","ignoreList":[]}
@@ -6,7 +6,9 @@ const withSharedValue = value => ({
6
6
  value,
7
7
  addListener: NOOP,
8
8
  removeListener: NOOP,
9
- modify: NOOP
9
+ modify: NOOP,
10
+ get: () => value,
11
+ set: NOOP
10
12
  });
11
13
  const DEFAULT_SHARED_VALUE = withSharedValue(0);
12
14
  const DEFAULT_LAYOUT = withSharedValue(null);
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","Animated","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","useKeyboardContext","context","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;\n setInputHandlers: (handlers: FocusedInputHandler) => () => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,QAAQ,QAAQ,cAAc;AA2BvC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN;AACV,CAAC,CAAC;AACF,MAAMO,oBAAoB,GAAGL,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMM,cAAc,GAAGN,eAAe,CACpC,IACF,CAAC;AACD,MAAMO,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIb,QAAQ,CAACc,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIf,QAAQ,CAACc,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAEL,oBAAoB;IAC9BO,MAAM,EAAEP;EACV,CAAC;EACDS,MAAM,EAAER,cAAc;EACtBS,mBAAmB,EAAEhB,WAAW;EAChCiB,gBAAgB,EAAEjB,WAAW;EAC7BkB,UAAU,EAAEnB;AACd,CAAC;AAED,OAAO,MAAMoB,eAAe,gBAAGvB,aAAa,CAACY,cAAc,CAAC;AAC5D,OAAO,MAAMY,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAGxB,UAAU,CAACsB,eAAe,CAAC;EAE3C,IAAIG,OAAO,IAAID,OAAO,KAAKb,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createContext","useContext","Animated","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","get","set","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","useKeyboardContext","context","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;\n setInputHandlers: (handlers: FocusedInputHandler) => () => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n get: () => value,\n set: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,QAAQ,QAAQ,cAAc;AA2BvC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN,IAAI;EACZO,GAAG,EAAEA,CAAA,KAAMJ,KAAK;EAChBK,GAAG,EAAER;AACP,CAAC,CAAC;AACF,MAAMS,oBAAoB,GAAGP,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMQ,cAAc,GAAGR,eAAe,CACpC,IACF,CAAC;AACD,MAAMS,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIf,QAAQ,CAACgB,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIjB,QAAQ,CAACgB,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVH,QAAQ,EAAEL,oBAAoB;IAC9BO,MAAM,EAAEP;EACV,CAAC;EACDS,MAAM,EAAER,cAAc;EACtBS,mBAAmB,EAAElB,WAAW;EAChCmB,gBAAgB,EAAEnB,WAAW;EAC7BoB,UAAU,EAAErB;AACd,CAAC;AAED,OAAO,MAAMsB,eAAe,gBAAGzB,aAAa,CAACc,cAAc,CAAC;AAC5D,OAAO,MAAMY,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG1B,UAAU,CAACwB,eAAe,CAAC;EAE3C,IAAIG,OAAO,IAAID,OAAO,KAAKb,cAAc,EAAE;IACzCe,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.14.1",
3
+ "version": "1.14.3",
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",
@@ -74,6 +74,9 @@
74
74
  "publishConfig": {
75
75
  "registry": "https://registry.npmjs.org/"
76
76
  },
77
+ "dependencies": {
78
+ "react-native-is-edge-to-edge": "^1.1.6"
79
+ },
77
80
  "devDependencies": {
78
81
  "@commitlint/config-conventional": "^11.0.0",
79
82
  "@react-native/eslint-config": "^0.75.3",
@@ -101,7 +104,7 @@
101
104
  "react": "18.3.1",
102
105
  "react-native": "0.75.3",
103
106
  "react-native-builder-bob": "^0.18.0",
104
- "react-native-reanimated": "3.15.0",
107
+ "react-native-reanimated": "3.16.1",
105
108
  "react-test-renderer": "18.2.0",
106
109
  "release-it": "^14.2.2",
107
110
  "typescript": "5.0.4"
package/src/animated.tsx CHANGED
@@ -1,6 +1,10 @@
1
1
  /* eslint react/jsx-sort-props: off */
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Animated, Platform, StyleSheet } from "react-native";
4
+ import {
5
+ controlEdgeToEdgeValues,
6
+ isEdgeToEdge,
7
+ } from "react-native-is-edge-to-edge";
4
8
  import Reanimated, { useSharedValue } from "react-native-reanimated";
5
9
 
6
10
  import { KeyboardControllerView } from "./bindings";
@@ -23,6 +27,8 @@ import type {
23
27
  } from "./types";
24
28
  import type { ViewStyle } from "react-native";
25
29
 
30
+ const IS_EDGE_TO_EDGE = isEdgeToEdge();
31
+
26
32
  const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(
27
33
  Animated.createAnimatedComponent(KeyboardControllerView),
28
34
  );
@@ -189,13 +195,17 @@ export const KeyboardProvider = ({
189
195
  }
190
196
  }, [enabled]);
191
197
 
198
+ if (__DEV__) {
199
+ controlEdgeToEdgeValues({ statusBarTranslucent, navigationBarTranslucent });
200
+ }
201
+
192
202
  return (
193
203
  <KeyboardContext.Provider value={context}>
194
204
  <KeyboardControllerViewAnimated
195
205
  ref={viewTagRef}
196
206
  enabled={enabled}
197
- navigationBarTranslucent={navigationBarTranslucent}
198
- statusBarTranslucent={statusBarTranslucent}
207
+ navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}
208
+ statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}
199
209
  style={styles.container}
200
210
  // on*Reanimated prop must precede animated handlers to work correctly
201
211
  onKeyboardMoveReanimated={keyboardHandler}
@@ -1,3 +1,4 @@
1
+ import { useState } from "react";
1
2
  import { useSharedValue } from "react-native-reanimated";
2
3
 
3
4
  import { useKeyboardContext } from "../../context";
@@ -5,10 +6,15 @@ import { useKeyboardHandler } from "../../hooks";
5
6
 
6
7
  export const useKeyboardAnimation = () => {
7
8
  const { reanimated } = useKeyboardContext();
8
- const heightWhenOpened = useSharedValue(-reanimated.height.value);
9
- const height = useSharedValue(-reanimated.height.value);
10
- const progress = useSharedValue(reanimated.progress.value);
11
- const isClosed = useSharedValue(reanimated.progress.value === 0);
9
+
10
+ // calculate it only once on mount, to avoid `SharedValue` reads during a render
11
+ const [initialHeight] = useState(() => -reanimated.height.value);
12
+ const [initialProgress] = useState(() => reanimated.progress.value);
13
+
14
+ const heightWhenOpened = useSharedValue(initialHeight);
15
+ const height = useSharedValue(initialHeight);
16
+ const progress = useSharedValue(initialProgress);
17
+ const isClosed = useSharedValue(initialProgress === 0);
12
18
 
13
19
  useKeyboardHandler(
14
20
  {
package/src/context.ts CHANGED
@@ -33,6 +33,8 @@ const withSharedValue = <T>(value: T): SharedValue<T> => ({
33
33
  addListener: NOOP,
34
34
  removeListener: NOOP,
35
35
  modify: NOOP,
36
+ get: () => value,
37
+ set: NOOP,
36
38
  });
37
39
  const DEFAULT_SHARED_VALUE = withSharedValue(0);
38
40
  const DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(