@@ -23,6 +23,7 @@ import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
23
23
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEventData
24
24
import com.reactnativekeyboardcontroller.extensions.dispatchEvent
25
25
import com.reactnativekeyboardcontroller.extensions.dp
26
+ import com.reactnativekeyboardcontroller.extensions.emitEvent
26
27
import com.reactnativekeyboardcontroller.extensions.isKeyboardAnimation
27
28
import kotlin.math.abs
28
29
@@ -76,8 +77,8 @@ class KeyboardAnimationCallback(
76
77
viewTagFocused,
77
78
),
78
79
)
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))
81
82
}
82
83
}
83
84
}
@@ -154,7 +155,7 @@ class KeyboardAnimationCallback(
154
155
}
155
156
156
157
layoutObserver?.syncUpLayout()
157
- this .emitEvent(
158
+ context .emitEvent(
158
159
" KeyboardController::" + if (! isKeyboardVisible) " keyboardWillHide" else " keyboardWillShow" ,
159
160
getEventParams(keyboardHeight),
160
161
)
@@ -245,7 +246,7 @@ class KeyboardAnimationCallback(
245
246
}
246
247
isKeyboardVisible = isKeyboardVisible || isKeyboardShown
247
248
248
- this .emitEvent(
249
+ context .emitEvent(
249
250
" KeyboardController::" + if (! isKeyboardVisible) " keyboardDidHide" else " keyboardDidShow" ,
250
251
getEventParams(keyboardHeight),
251
252
)
@@ -286,7 +287,7 @@ class KeyboardAnimationCallback(
286
287
this .animation?.cancel()
287
288
}
288
289
289
- this .emitEvent(" KeyboardController::keyboardWillShow" , getEventParams(keyboardHeight))
290
+ context .emitEvent(" KeyboardController::keyboardWillShow" , getEventParams(keyboardHeight))
290
291
this .dispatchEventToJS(
291
292
KeyboardTransitionEventData (
292
293
" topKeyboardMoveStart" ,
@@ -312,7 +313,7 @@ class KeyboardAnimationCallback(
312
313
)
313
314
}
314
315
animation.doOnEnd {
315
- this .emitEvent(" KeyboardController::keyboardDidShow" , getEventParams(keyboardHeight))
316
+ context .emitEvent(" KeyboardController::keyboardDidShow" , getEventParams(keyboardHeight))
316
317
this .dispatchEventToJS(
317
318
KeyboardTransitionEventData (
318
319
" topKeyboardMoveEnd" ,
@@ -346,12 +347,6 @@ class KeyboardAnimationCallback(
346
347
return (keyboardHeight - navigationBar).toFloat().dp.coerceAtLeast(0.0 )
347
348
}
348
349
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
-
355
350
private fun getEventParams (height : Double ): WritableMap {
356
351
val params: WritableMap = Arguments .createMap()
357
352
params.putDouble(" height" , height)
0 commit comments