-
-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathKeyboardControllerViewManagerImpl.kt
More file actions
94 lines (80 loc) · 3.02 KB
/
KeyboardControllerViewManagerImpl.kt
File metadata and controls
94 lines (80 loc) · 3.02 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.reactnativekeyboardcontroller.managers
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.common.MapBuilder
import com.facebook.react.uimanager.ThemedReactContext
import com.reactnativekeyboardcontroller.events.FocusedInputLayoutChangedEvent
import com.reactnativekeyboardcontroller.events.FocusedInputSelectionChangedEvent
import com.reactnativekeyboardcontroller.events.FocusedInputTextChangedEvent
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
import com.reactnativekeyboardcontroller.listeners.WindowDimensionListener
import com.reactnativekeyboardcontroller.views.EdgeToEdgeReactViewGroup
@Suppress("detekt:UnusedPrivateProperty")
class KeyboardControllerViewManagerImpl(
mReactContext: ReactApplicationContext,
) {
private var listener : WindowDimensionListener? = null
fun createViewInstance(reactContext: ThemedReactContext): EdgeToEdgeReactViewGroup {
if (listener == null) {
listener = WindowDimensionListener(reactContext)
listener?.attachListener()
}
return EdgeToEdgeReactViewGroup(reactContext)
}
fun invalidate() {
listener?.detachListener()
}
fun setEnabled(
view: EdgeToEdgeReactViewGroup,
enabled: Boolean,
) {
view.setActive(enabled)
}
fun setStatusBarTranslucent(
view: EdgeToEdgeReactViewGroup,
isStatusBarTranslucent: Boolean,
) {
view.setStatusBarTranslucent(isStatusBarTranslucent)
}
fun setNavigationBarTranslucent(
view: EdgeToEdgeReactViewGroup,
isNavigationBarTranslucent: Boolean,
) {
view.setNavigationBarTranslucent(isNavigationBarTranslucent)
}
fun setPreserveEdgeToEdge(
view: EdgeToEdgeReactViewGroup,
isPreservingEdgeToEdge: Boolean,
) {
view.setPreserveEdgeToEdge(isPreservingEdgeToEdge)
}
fun setEdgeToEdge(view: EdgeToEdgeReactViewGroup) {
view.setEdgeToEdge()
}
fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
val map: MutableMap<String, Any> =
MapBuilder.of(
KeyboardTransitionEvent.Move.value,
MapBuilder.of("registrationName", "onKeyboardMove"),
KeyboardTransitionEvent.Start.value,
MapBuilder.of("registrationName", "onKeyboardMoveStart"),
KeyboardTransitionEvent.End.value,
MapBuilder.of("registrationName", "onKeyboardMoveEnd"),
KeyboardTransitionEvent.Interactive.value,
MapBuilder.of("registrationName", "onKeyboardMoveInteractive"),
FocusedInputLayoutChangedEvent.EVENT_NAME,
MapBuilder.of("registrationName", "onFocusedInputLayoutChanged"),
FocusedInputTextChangedEvent.EVENT_NAME,
MapBuilder.of("registrationName", "onFocusedInputTextChanged"),
FocusedInputSelectionChangedEvent.EVENT_NAME,
MapBuilder.of("registrationName", "onFocusedInputSelectionChanged"),
)
return map
}
fun onDropViewInstance(view: EdgeToEdgeReactViewGroup) {
view.setActive(false)
view.removeWindowInsetsListener()
}
companion object {
const val NAME = "KeyboardControllerView"
}
}