Skip to content

Commit a500bda

Browse files
committed
fix: CI
1 parent 56238f3 commit a500bda

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.reactnativekeyboardcontroller.extensions
22

3+
import android.util.Log
34
import android.view.View
5+
6+
import com.facebook.react.bridge.WritableMap
7+
import com.facebook.react.modules.core.DeviceEventManagerModule
48
import com.facebook.react.uimanager.ThemedReactContext
59
import com.facebook.react.uimanager.UIManagerHelper
610
import com.facebook.react.uimanager.events.Event
@@ -14,3 +18,9 @@ fun ThemedReactContext?.dispatchEvent(viewId: Int, event: Event<*>) {
1418
UIManagerHelper.getEventDispatcherForReactTag(this, viewId)
1519
eventDispatcher?.dispatchEvent(event)
1620
}
21+
22+
fun ThemedReactContext?.emitEvent(event: String, params: WritableMap) {
23+
this?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)?.emit(event, params)
24+
25+
Log.i("ThemedReactContext", event)
26+
}

android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
2323
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEventData
2424
import com.reactnativekeyboardcontroller.extensions.dispatchEvent
2525
import com.reactnativekeyboardcontroller.extensions.dp
26+
import com.reactnativekeyboardcontroller.extensions.emitEvent
2627
import com.reactnativekeyboardcontroller.extensions.isKeyboardAnimation
2728
import kotlin.math.abs
2829

@@ -76,8 +77,8 @@ class KeyboardAnimationCallback(
7677
viewTagFocused,
7778
),
7879
)
79-
this.emitEvent("KeyboardController::keyboardWillShow", getEventParams(this.persistentKeyboardHeight))
80-
this.emitEvent("KeyboardController::keyboardDidShow", getEventParams(this.persistentKeyboardHeight))
80+
context.emitEvent("KeyboardController::keyboardWillShow", getEventParams(this.persistentKeyboardHeight))
81+
context.emitEvent("KeyboardController::keyboardDidShow", getEventParams(this.persistentKeyboardHeight))
8182
}
8283
}
8384
}
@@ -154,7 +155,7 @@ class KeyboardAnimationCallback(
154155
}
155156

156157
layoutObserver?.syncUpLayout()
157-
this.emitEvent(
158+
context.emitEvent(
158159
"KeyboardController::" + if (!isKeyboardVisible) "keyboardWillHide" else "keyboardWillShow",
159160
getEventParams(keyboardHeight),
160161
)
@@ -245,7 +246,7 @@ class KeyboardAnimationCallback(
245246
}
246247
isKeyboardVisible = isKeyboardVisible || isKeyboardShown
247248

248-
this.emitEvent(
249+
context.emitEvent(
249250
"KeyboardController::" + if (!isKeyboardVisible) "keyboardDidHide" else "keyboardDidShow",
250251
getEventParams(keyboardHeight),
251252
)
@@ -286,7 +287,7 @@ class KeyboardAnimationCallback(
286287
this.animation?.cancel()
287288
}
288289

289-
this.emitEvent("KeyboardController::keyboardWillShow", getEventParams(keyboardHeight))
290+
context.emitEvent("KeyboardController::keyboardWillShow", getEventParams(keyboardHeight))
290291
this.dispatchEventToJS(
291292
KeyboardTransitionEventData(
292293
"topKeyboardMoveStart",
@@ -312,7 +313,7 @@ class KeyboardAnimationCallback(
312313
)
313314
}
314315
animation.doOnEnd {
315-
this.emitEvent("KeyboardController::keyboardDidShow", getEventParams(keyboardHeight))
316+
context.emitEvent("KeyboardController::keyboardDidShow", getEventParams(keyboardHeight))
316317
this.dispatchEventToJS(
317318
KeyboardTransitionEventData(
318319
"topKeyboardMoveEnd",
@@ -346,12 +347,6 @@ class KeyboardAnimationCallback(
346347
return (keyboardHeight - navigationBar).toFloat().dp.coerceAtLeast(0.0)
347348
}
348349

349-
private fun emitEvent(event: String, params: WritableMap) {
350-
context?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)?.emit(event, params)
351-
352-
Log.i(TAG, event)
353-
}
354-
355350
private fun getEventParams(height: Double): WritableMap {
356351
val params: WritableMap = Arguments.createMap()
357352
params.putDouble("height", height)

0 commit comments

Comments
 (0)