react-native-keyboard-controller 1.19.4 → 1.19.5

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.
@@ -11,7 +11,7 @@ import UIKit
11
11
  * A compatibility view that resolves to `KeyboardView` on iOS < 26
12
12
  * and uses `keyboardLayoutGuide` on iOS 26+.
13
13
  */
14
- final class KeyboardTrackingView: UIView {
14
+ public final class KeyboardTrackingView: UIView {
15
15
  private var keyboardView: UIView? { KeyboardViewLocator.shared.resolve() }
16
16
  private var keyboardHeight = 0.0
17
17
  private weak var currentAttachedView: UIView?
@@ -56,23 +56,17 @@ final class KeyboardTrackingView: UIView {
56
56
  name: UIResponder.keyboardDidShowNotification,
57
57
  object: nil
58
58
  )
59
- NotificationCenter.default.addObserver(
60
- self,
61
- selector: #selector(attachToTopmostView),
62
- name: UIApplication.didBecomeActiveNotification,
63
- object: nil
64
- )
65
59
  }
66
60
 
67
- override func willMove(toWindow newWindow: UIWindow?) {
61
+ override public func willMove(toWindow newWindow: UIWindow?) {
68
62
  // When the view is being removed from the window, we need to re-attach it
69
63
  if newWindow == nil, !isAttaching {
70
64
  attachToTopmostView()
71
65
  }
72
66
  }
73
67
 
74
- @objc private func attachToTopmostView() {
75
- guard let topView = UIApplication.topViewController()?.view else { return }
68
+ @objc public func attachToTopmostView(toWindow window: UIWindow? = nil) {
69
+ guard let topView = (window?.rootViewController ?? UIApplication.topViewController())?.view else { return }
76
70
 
77
71
  if currentAttachedView === topView { return }
78
72
 
@@ -18,7 +18,7 @@ public class KeyboardMovementObserver: NSObject {
18
18
  var onRequestAnimation: () -> Void
19
19
  var onCancelAnimation: () -> Void
20
20
  // progress tracker
21
- var keyboardTrackingView = KeyboardTrackingView()
21
+ @objc public var keyboardTrackingView = KeyboardTrackingView()
22
22
  var animation: KeyboardAnimation?
23
23
 
24
24
  var prevKeyboardPosition = 0.0
@@ -259,6 +259,14 @@ using namespace facebook::react;
259
259
  }
260
260
  }
261
261
 
262
+ - (void)didMoveToWindow
263
+ {
264
+ [super didMoveToWindow];
265
+ if (self.window) {
266
+ [keyboardObserver.keyboardTrackingView attachToTopmostViewToWindow:self.window];
267
+ }
268
+ }
269
+
262
270
  - (void)mount
263
271
  {
264
272
  [inputObserver mount];
@@ -85,6 +85,13 @@ class KeyboardControllerView: UIView {
85
85
  }
86
86
  }
87
87
 
88
+ override func didMoveToWindow() {
89
+ super.didMoveToWindow()
90
+ if window != nil {
91
+ keyboardObserver?.keyboardTrackingView.attachToTopmostView(toWindow: window)
92
+ }
93
+ }
94
+
88
95
  override func layoutSubviews() {
89
96
  super.layoutSubviews()
90
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.19.4",
3
+ "version": "1.19.5",
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",