react-native-keyboard-controller 1.16.2 → 1.16.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.
@@ -70,6 +70,12 @@ android {
70
70
  } else {
71
71
  java.srcDirs += ['src/paper']
72
72
  }
73
+
74
+ if (project.ext.shouldUseBaseReactPackage()) {
75
+ java.srcDirs += ['src/base']
76
+ } else {
77
+ java.srcDirs += ['src/turbo']
78
+ }
73
79
  }
74
80
  }
75
81
 
@@ -39,4 +39,8 @@ project.ext.resolveReactNativeDirectory = { ->
39
39
 
40
40
  project.ext.shouldConsumeReactNativeFromMavenCentral = { ->
41
41
  return REACT_NATIVE_MINOR_VERSION >= 71
42
- }
42
+ }
43
+
44
+ project.ext.shouldUseBaseReactPackage = { ->
45
+ return REACT_NATIVE_MINOR_VERSION >= 74
46
+ }
@@ -0,0 +1,61 @@
1
+ package com.reactnativekeyboardcontroller
2
+
3
+ import com.facebook.react.BaseReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import com.facebook.react.uimanager.ViewManager
9
+ import com.reactnativekeyboardcontroller.modules.KeyboardControllerModuleImpl
10
+ import com.reactnativekeyboardcontroller.modules.StatusBarManagerCompatModuleImpl
11
+
12
+ class KeyboardControllerPackage : BaseReactPackage() {
13
+ override fun getModule(
14
+ name: String,
15
+ reactContext: ReactApplicationContext,
16
+ ): NativeModule? =
17
+ when (name) {
18
+ KeyboardControllerModuleImpl.NAME -> {
19
+ KeyboardControllerModule(reactContext)
20
+ }
21
+ StatusBarManagerCompatModuleImpl.NAME -> {
22
+ StatusBarManagerCompatModule(reactContext)
23
+ }
24
+ else -> {
25
+ null
26
+ }
27
+ }
28
+
29
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
30
+ ReactModuleInfoProvider {
31
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
32
+ val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
33
+
34
+ moduleInfos[KeyboardControllerModuleImpl.NAME] =
35
+ ReactModuleInfo(
36
+ KeyboardControllerModuleImpl.NAME,
37
+ KeyboardControllerModuleImpl.NAME,
38
+ false, // canOverrideExistingModule
39
+ false, // needsEagerInit
40
+ false, // isCxxModule
41
+ isTurboModule, // isTurboModule
42
+ )
43
+ moduleInfos[StatusBarManagerCompatModuleImpl.NAME] =
44
+ ReactModuleInfo(
45
+ StatusBarManagerCompatModuleImpl.NAME,
46
+ StatusBarManagerCompatModuleImpl.NAME,
47
+ false, // canOverrideExistingModule
48
+ false, // needsEagerInit
49
+ false, // isCxxModule
50
+ isTurboModule, // isTurboModule
51
+ )
52
+ moduleInfos
53
+ }
54
+
55
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
56
+ listOf(
57
+ KeyboardControllerViewManager(reactContext),
58
+ KeyboardGestureAreaViewManager(reactContext),
59
+ OverKeyboardViewManager(reactContext),
60
+ )
61
+ }
@@ -80,12 +80,6 @@ public class FocusedInputObserver: NSObject {
80
80
  name: UIResponder.keyboardWillShowNotification,
81
81
  object: nil
82
82
  )
83
- NotificationCenter.default.addObserver(
84
- self,
85
- selector: #selector(keyboardWillHide),
86
- name: UIResponder.keyboardWillHideNotification,
87
- object: nil
88
- )
89
83
  NotificationCenter.default.addObserver(
90
84
  self,
91
85
  selector: #selector(didReceiveFocus),
@@ -118,10 +112,6 @@ public class FocusedInputObserver: NSObject {
118
112
  NotificationCenter.default.removeObserver(self)
119
113
  }
120
114
 
121
- @objc func keyboardWillHide(_: Notification) {
122
- onBlur()
123
- }
124
-
125
115
  @objc func didReceiveFocus(_: Notification) {
126
116
  if UIResponder.current == currentResponder {
127
117
  // focus was already handled by keyboard event
@@ -131,22 +121,13 @@ public class FocusedInputObserver: NSObject {
131
121
  onFocus()
132
122
  }
133
123
 
134
- /**
135
- * We handle blur events in `keyboardWillHide` handler
136
- * And this additional handler is needed only to have
137
- * a consistent state when keyboard is not shown
138
- */
139
124
  @objc func didReceiveBlur(_: Notification) {
140
- if currentResponder == nil {
141
- // blur was already handled by keyboard event
142
- return
143
- }
144
125
  // blur gets triggered on endEditing, so we check if no upcoming
145
126
  // didReceiveFocus events are coming to exclude `noFocusedInput`
146
127
  // event when user switches between inputs
147
128
  DispatchQueue.main.async {
148
129
  // check that it wasn't a switch between inputs
149
- if self.currentResponder == nil {
130
+ if !(UIResponder.current is TextInput) {
150
131
  self.onBlur()
151
132
  }
152
133
  }
@@ -173,10 +154,6 @@ public class FocusedInputObserver: NSObject {
173
154
  }
174
155
 
175
156
  func onBlur() {
176
- // when we switch to next input, but `showSoftInput={false}`
177
- if UIResponder.current is TextInput {
178
- return
179
- }
180
157
  removeObservers(newResponder: nil)
181
158
  currentInput = nil
182
159
  currentResponder = nil
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.16.2",
3
+ "version": "1.16.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",
@@ -80,11 +80,11 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@commitlint/config-conventional": "^11.0.0",
83
- "@react-native/babel-preset": "0.76.2",
84
- "@react-native/eslint-config": "0.76.2",
83
+ "@react-native/babel-preset": "0.77.0",
84
+ "@react-native/eslint-config": "0.77.0",
85
85
  "@release-it/conventional-changelog": "^2.0.0",
86
86
  "@testing-library/react-hooks": "^8.0.1",
87
- "@types/jest": "^29.2.1",
87
+ "@types/jest": "^29.5.13",
88
88
  "@types/react": "^18.2.6",
89
89
  "@typescript-eslint/eslint-plugin": "^6.7.4",
90
90
  "@typescript-eslint/parser": "^6.7.4",
@@ -105,9 +105,9 @@
105
105
  "pod-install": "^0.1.0",
106
106
  "prettier": "^2.8.8",
107
107
  "react": "18.3.1",
108
- "react-native": "0.76.2",
108
+ "react-native": "0.77.0",
109
109
  "react-native-builder-bob": "^0.18.0",
110
- "react-native-reanimated": "3.16.1",
110
+ "react-native-reanimated": "3.16.7",
111
111
  "react-test-renderer": "18.2.0",
112
112
  "release-it": "^14.2.2",
113
113
  "typescript": "5.6.3"
@@ -170,6 +170,13 @@
170
170
  "jsSrcsDir": "./src/specs",
171
171
  "android": {
172
172
  "javaPackageName": "com.reactnativekeyboardcontroller"
173
+ },
174
+ "ios": {
175
+ "componentProvider": {
176
+ "KeyboardControllerView": "KeyboardControllerView",
177
+ "KeyboardGestureArea": "KeyboardGestureArea",
178
+ "OverKeyboardView": "OverKeyboardView"
179
+ }
173
180
  }
174
181
  }
175
182
  }