@@ -30,7 +30,11 @@ class OverKeyboardHostView(
30
30
private var windowManager: WindowManager = reactContext.getSystemService(Context .WINDOW_SERVICE ) as WindowManager
31
31
private var hostView: OverKeyboardRootViewGroup = OverKeyboardRootViewGroup (reactContext)
32
32
33
- internal var stateWrapper: StateWrapper ? = null
33
+ var stateWrapper: StateWrapper ?
34
+ get() = hostView.stateWrapper
35
+ set(stateWrapper) {
36
+ hostView.stateWrapper = stateWrapper
37
+ }
34
38
35
39
init {
36
40
hostView.eventDispatcher = dispatcher
@@ -92,24 +96,14 @@ class OverKeyboardHostView(
92
96
PixelFormat .TRANSLUCENT ,
93
97
)
94
98
95
- stretchTo(fullScreen = true )
96
99
windowManager.addView(hostView, layoutParams)
97
100
}
98
101
99
102
fun hide () {
100
103
if (hostView.isAttached) {
101
104
windowManager.removeView(hostView)
102
- stretchTo(fullScreen = false )
103
105
}
104
106
}
105
-
106
- private fun stretchTo (fullScreen : Boolean ) {
107
- val displaySize = reactContext.getDisplaySize()
108
- val newStateData: WritableMap = WritableNativeMap ()
109
- newStateData.putDouble(" screenWidth" , if (fullScreen) displaySize.x.toFloat().dp else 0.0 )
110
- newStateData.putDouble(" screenHeight" , if (fullScreen) displaySize.y.toFloat().dp else 0.0 )
111
- stateWrapper?.updateState(newStateData)
112
- }
113
107
}
114
108
115
109
@SuppressLint(" ViewConstructor" )
@@ -120,6 +114,7 @@ class OverKeyboardRootViewGroup(
120
114
private val jsTouchDispatcher: JSTouchDispatcher = JSTouchDispatcher (this )
121
115
private var jsPointerDispatcher: JSPointerDispatcherCompat ? = null
122
116
internal var eventDispatcher: EventDispatcher ? = null
117
+ internal var stateWrapper: StateWrapper ? = null
123
118
internal var isAttached = false
124
119
125
120
init {
@@ -131,13 +126,27 @@ class OverKeyboardRootViewGroup(
131
126
// region life cycles
132
127
override fun onAttachedToWindow () {
133
128
super .onAttachedToWindow()
129
+ val displaySize = reactContext.getDisplaySize()
130
+ stretchTo(width = displaySize.x, height = displaySize.y)
134
131
isAttached = true
135
132
}
136
133
137
134
override fun onDetachedFromWindow () {
138
135
super .onDetachedFromWindow()
136
+ stretchTo(width = 0 , height = 0 )
139
137
isAttached = false
140
138
}
139
+
140
+ override fun onSizeChanged (
141
+ w : Int ,
142
+ h : Int ,
143
+ oldw : Int ,
144
+ oldh : Int ,
145
+ ) {
146
+ super .onSizeChanged(w, h, oldw, oldh)
147
+ stretchTo(width = w, height = h)
148
+ }
149
+
141
150
// endregion
142
151
143
152
// region Touch events handling
@@ -216,4 +225,14 @@ class OverKeyboardRootViewGroup(
216
225
reactContext.reactApplicationContext.handleException(RuntimeException (t))
217
226
}
218
227
// endregion
228
+
229
+ private fun stretchTo (
230
+ width : Int ,
231
+ height : Int ,
232
+ ) {
233
+ val newStateData: WritableMap = WritableNativeMap ()
234
+ newStateData.putDouble(" screenWidth" , width.toFloat().dp)
235
+ newStateData.putDouble(" screenHeight" , height.toFloat().dp)
236
+ stateWrapper?.updateState(newStateData)
237
+ }
219
238
}
0 commit comments