react-native-keyboard-controller 1.0.0-alpha.2 → 1.0.0-alpha.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.
@@ -23,11 +23,20 @@ class KeyboardControllerView : UIView {
23
23
  }
24
24
 
25
25
  override func willMove(toWindow newWindow: UIWindow?) {
26
- super.willMove(toWindow: newWindow)
27
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear), name: UIResponder.keyboardWillHideNotification, object: nil)
28
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear), name: UIResponder.keyboardWillShowNotification, object: nil)
29
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidAppear), name: UIResponder.keyboardDidShowNotification, object: nil)
30
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidDisappear), name: UIResponder.keyboardDidHideNotification, object: nil)
26
+ if (newWindow == nil) {
27
+ // Will be removed from a window
28
+ NotificationCenter.default.removeObserver(self)
29
+ }
30
+ }
31
+
32
+ override func didMoveToWindow() {
33
+ if (self.window != nil) {
34
+ // Added to a window
35
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear), name: UIResponder.keyboardWillHideNotification, object: nil)
36
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear), name: UIResponder.keyboardWillShowNotification, object: nil)
37
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidAppear), name: UIResponder.keyboardDidShowNotification, object: nil)
38
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidDisappear), name: UIResponder.keyboardDidHideNotification, object: nil)
39
+ }
31
40
  }
32
41
 
33
42
  @objc func keyboardWillAppear(_ notification: Notification) {
@@ -66,9 +75,4 @@ class KeyboardControllerView : UIView {
66
75
  data["height"] = 0
67
76
  KeyboardController.shared?.sendEvent(withName: "KeyboardController::keyboardDidHide", body: data)
68
77
  }
69
-
70
- override func willRemoveSubview(_ subview: UIView) {
71
- super.willRemoveSubview(subview)
72
- NotificationCenter.default.removeObserver(self) // TODO: correct place?
73
- }
74
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Platform agnostic keyboard manager",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",