-
-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathReactContext.kt
More file actions
40 lines (33 loc) · 1.19 KB
/
ReactContext.kt
File metadata and controls
40 lines (33 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.reactnativekeyboardcontroller.extensions
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import com.facebook.react.bridge.ReactContext
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.common.UIManagerType
import com.facebook.react.uimanager.events.EventDispatcher
import com.reactnativekeyboardcontroller.BuildConfig
private val archType = if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) UIManagerType.FABRIC else UIManagerType.DEFAULT
val ReactContext.uiManager
get() = UIManagerHelper.getUIManager(this, archType)
val ReactContext.eventDispatcher: EventDispatcher?
get() = UIManagerHelper.getEventDispatcher(this, archType)
val ReactContext.rootView: View?
get() =
this.currentActivity
?.window
?.decorView
?.rootView
val ReactContext.content: ViewGroup?
get() =
this.currentActivity?.window?.decorView?.rootView?.findViewById(
androidx.appcompat.R.id.action_bar_root,
)
val ReactContext.windowSoftInputMode: Int
get() =
this
.currentActivity
?.window
?.attributes
?.softInputMode
?: WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED