react-native-keyboard-controller 1.9.0 → 1.9.1

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.
@@ -110,6 +110,7 @@ class KeyboardAnimationCallback(
110
110
  * - we dispatch `keyboardDidShow` (onEnd).
111
111
  */
112
112
  override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
113
+ val keyboardHeight = getCurrentKeyboardHeight()
113
114
  // when keyboard appears values will be (false && true)
114
115
  // when keyboard disappears values will be (true && false)
115
116
  val isKeyboardShown = isKeyboardVisible && isKeyboardVisible()
@@ -121,10 +122,17 @@ class KeyboardAnimationCallback(
121
122
  // `InteractiveKeyboardProvider.isInteractive` detect case when keyboard moves
122
123
  // because of the gesture
123
124
  val isMoving = isTransitioning || InteractiveKeyboardProvider.isInteractive
124
- if (isKeyboardShown && !isMoving && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
125
- val keyboardHeight = getCurrentKeyboardHeight()
126
- val duration = DEFAULT_ANIMATION_TIME.toInt()
125
+ val isKeyboardFullyVisible = isKeyboardShown && !isMoving
126
+ // when keyboard is opened and we trigger a transition from screen A to screen B,
127
+ // then this method is getting called and we start dispatching events, and later original
128
+ // `onStart`/`onProgress`/`onEnd` emitting their events (since keyboard is closing) and we
129
+ // are getting race conditions.
130
+ //
131
+ // but in general this check is a must because we are detecting keyboard size changes
132
+ // in this method
133
+ val isKeyboardSizeEqual = this.persistentKeyboardHeight == keyboardHeight
127
134
 
135
+ if (isKeyboardFullyVisible && !isKeyboardSizeEqual && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
128
136
  layoutObserver?.syncUpLayout()
129
137
  this.emitEvent("KeyboardController::keyboardWillShow", getEventParams(keyboardHeight))
130
138
  context.dispatchEvent(
@@ -135,7 +143,7 @@ class KeyboardAnimationCallback(
135
143
  "topKeyboardMoveStart",
136
144
  keyboardHeight,
137
145
  1.0,
138
- duration,
146
+ DEFAULT_ANIMATION_TIME,
139
147
  viewTagFocused,
140
148
  ),
141
149
  )
@@ -152,7 +160,7 @@ class KeyboardAnimationCallback(
152
160
  "topKeyboardMove",
153
161
  toValue.toDouble(),
154
162
  toValue.toDouble() / keyboardHeight,
155
- duration,
163
+ DEFAULT_ANIMATION_TIME,
156
164
  viewTagFocused,
157
165
  ),
158
166
  )
@@ -167,12 +175,12 @@ class KeyboardAnimationCallback(
167
175
  "topKeyboardMoveEnd",
168
176
  keyboardHeight,
169
177
  1.0,
170
- duration,
178
+ DEFAULT_ANIMATION_TIME,
171
179
  viewTagFocused,
172
180
  ),
173
181
  )
174
182
  }
175
- animation.setDuration(DEFAULT_ANIMATION_TIME).startDelay = 0
183
+ animation.setDuration(DEFAULT_ANIMATION_TIME.toLong()).startDelay = 0
176
184
  animation.start()
177
185
 
178
186
  this.persistentKeyboardHeight = keyboardHeight
@@ -344,6 +352,6 @@ class KeyboardAnimationCallback(
344
352
  }
345
353
 
346
354
  companion object {
347
- private const val DEFAULT_ANIMATION_TIME = 250L
355
+ private const val DEFAULT_ANIMATION_TIME = 250
348
356
  }
349
357
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
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",