Skip to content

Commit c037b82

Browse files
authored
Android: Old arch resize on rotation (#33)
1 parent 961af95 commit c037b82

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

android/src/main/java/com/multiplemodals/RNTModalShadowView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal class RNTModalShadowView : LayoutShadowNode() {
1919
override fun addChildAt(child: ReactShadowNodeImpl, i: Int) {
2020
super.addChildAt(child, i)
2121
val modalSize = ModalHostHelper.getModalHostSize(themedContext, statusBarTranslucent)
22-
child.setStyleWidth(modalSize.x.toFloat())
23-
child.setStyleHeight(modalSize.y.toFloat())
22+
setStyleWidth(modalSize.x.toFloat())
23+
setStyleHeight(modalSize.y.toFloat())
2424
}
2525
}

android/src/main/java/com/multiplemodals/library/ModalView.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fun interface OnSizeComputedListener {
1616
}
1717

1818
@SuppressLint("ViewConstructor")
19-
class ModalView(reactContext: ThemedReactContext,
19+
class ModalView(private val reactContext: ThemedReactContext,
2020
private val eventDispatcher: EventDispatcher): ReactViewGroup(reactContext), RootView {
2121

2222
private val jSTouchDispatcher = JSTouchDispatcher(this)
@@ -35,7 +35,6 @@ class ModalView(reactContext: ThemedReactContext,
3535
}
3636

3737
override fun handleException(t: Throwable) {
38-
val reactContext = context as ThemedReactContext
3938
reactContext.reactApplicationContext.handleException(RuntimeException(t))
4039
}
4140

android/src/oldarch/RNTModalViewManagerSpec.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package com.multiplemodals
22

33
import android.view.ViewGroup
4+
import com.facebook.react.uimanager.ThemedReactContext
45
import com.facebook.react.uimanager.UIManagerModule
56
import com.facebook.react.uimanager.ViewGroupManager
67
import com.multiplemodals.library.OnSizeComputedListener
78

89
abstract class RNTModalViewManagerSpec<T : ViewGroup> : ViewGroupManager<T>() {
9-
private fun setViewSize(view: RNTModalView, widthPx: Int, heightPx: Int) {
10-
val reactContext = view.reactContext
11-
10+
private fun setViewSize(reactContext: ThemedReactContext, viewId: Int, widthPx: Int, heightPx: Int) {
1211
reactContext.runOnNativeModulesQueueThread {
1312
reactContext.reactApplicationContext
1413
.getNativeModule(UIManagerModule::class.java).let { uiManager ->
15-
uiManager?.updateNodeSize(view.id, widthPx, heightPx)
14+
uiManager?.updateNodeSize(viewId, widthPx, heightPx)
1615
}
1716
}
1817
}
@@ -45,7 +44,7 @@ abstract class RNTModalViewManagerSpec<T : ViewGroup> : ViewGroupManager<T>() {
4544
view.isShadowViewSizeSet = true
4645

4746
view.onSizeComputedListener = OnSizeComputedListener { widthPx, heightPx ->
48-
setViewSize(view, widthPx, heightPx)
47+
setViewSize(view.reactContext, view.id, widthPx, heightPx)
4948
}
5049

5150
view.show()

0 commit comments

Comments
 (0)