Skip to content

Commit

Permalink
fix: CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Dec 24, 2023
1 parent 20f45f2 commit d1581c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.reactnativekeyboardcontroller.extensions

import android.util.Log
import android.view.View

import com.facebook.react.bridge.WritableMap
import com.facebook.react.modules.core.DeviceEventManagerModule
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.events.Event
Expand All @@ -14,3 +18,9 @@ fun ThemedReactContext?.dispatchEvent(viewId: Int, event: Event<*>) {
UIManagerHelper.getEventDispatcherForReactTag(this, viewId)
eventDispatcher?.dispatchEvent(event)
}

fun ThemedReactContext?.emitEvent(event: String, params: WritableMap) {
this?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)?.emit(event, params)

Log.i("ThemedReactContext", event)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEventData
import com.reactnativekeyboardcontroller.extensions.dispatchEvent
import com.reactnativekeyboardcontroller.extensions.dp
import com.reactnativekeyboardcontroller.extensions.emitEvent
import com.reactnativekeyboardcontroller.extensions.isKeyboardAnimation
import kotlin.math.abs

Expand Down Expand Up @@ -76,8 +77,8 @@ class KeyboardAnimationCallback(
viewTagFocused,
),
)
this.emitEvent("KeyboardController::keyboardWillShow", getEventParams(this.persistentKeyboardHeight))
this.emitEvent("KeyboardController::keyboardDidShow", getEventParams(this.persistentKeyboardHeight))
context.emitEvent("KeyboardController::keyboardWillShow", getEventParams(this.persistentKeyboardHeight))
context.emitEvent("KeyboardController::keyboardDidShow", getEventParams(this.persistentKeyboardHeight))
}
}
}
Expand Down Expand Up @@ -154,7 +155,7 @@ class KeyboardAnimationCallback(
}

layoutObserver?.syncUpLayout()
this.emitEvent(
context.emitEvent(
"KeyboardController::" + if (!isKeyboardVisible) "keyboardWillHide" else "keyboardWillShow",
getEventParams(keyboardHeight),
)
Expand Down Expand Up @@ -245,7 +246,7 @@ class KeyboardAnimationCallback(
}
isKeyboardVisible = isKeyboardVisible || isKeyboardShown

this.emitEvent(
context.emitEvent(
"KeyboardController::" + if (!isKeyboardVisible) "keyboardDidHide" else "keyboardDidShow",
getEventParams(keyboardHeight),
)
Expand Down Expand Up @@ -286,7 +287,7 @@ class KeyboardAnimationCallback(
this.animation?.cancel()
}

this.emitEvent("KeyboardController::keyboardWillShow", getEventParams(keyboardHeight))
context.emitEvent("KeyboardController::keyboardWillShow", getEventParams(keyboardHeight))
this.dispatchEventToJS(
KeyboardTransitionEventData(
"topKeyboardMoveStart",
Expand All @@ -312,7 +313,7 @@ class KeyboardAnimationCallback(
)
}
animation.doOnEnd {
this.emitEvent("KeyboardController::keyboardDidShow", getEventParams(keyboardHeight))
context.emitEvent("KeyboardController::keyboardDidShow", getEventParams(keyboardHeight))
this.dispatchEventToJS(
KeyboardTransitionEventData(
"topKeyboardMoveEnd",
Expand Down Expand Up @@ -346,12 +347,6 @@ class KeyboardAnimationCallback(
return (keyboardHeight - navigationBar).toFloat().dp.coerceAtLeast(0.0)
}

private fun emitEvent(event: String, params: WritableMap) {
context?.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)?.emit(event, params)

Log.i(TAG, event)
}

private fun getEventParams(height: Double): WritableMap {
val params: WritableMap = Arguments.createMap()
params.putDouble("height", height)
Expand Down

0 comments on commit d1581c1

Please sign in to comment.