@@ -23,6 +23,7 @@ import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
2323import com.reactnativekeyboardcontroller.events.KeyboardTransitionEventData
2424import com.reactnativekeyboardcontroller.extensions.dispatchEvent
2525import com.reactnativekeyboardcontroller.extensions.dp
26+ import com.reactnativekeyboardcontroller.extensions.emitEvent
2627import com.reactnativekeyboardcontroller.extensions.isKeyboardAnimation
2728import 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