react-native-nitro-modal 0.3.5-rc → 0.3.6-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,6 +42,7 @@ class NitroModalHostView(context: ThemedReactContext) : ViewGroup(context), Reac
|
|
|
42
42
|
|
|
43
43
|
private val measureAndLayout = Runnable {
|
|
44
44
|
layoutPending = false
|
|
45
|
+
forceLayout()
|
|
45
46
|
measure(
|
|
46
47
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
47
48
|
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
|
|
@@ -78,8 +79,15 @@ class NitroModalHostView(context: ThemedReactContext) : ViewGroup(context), Reac
|
|
|
78
79
|
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
|
79
80
|
// Laid out by Fabric. A modal's children live in the modal window; an
|
|
80
81
|
// inline sheet's layout fills this view.
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
layoutChildren(r - l, b - t)
|
|
83
|
+
if (changed) onLayoutChange?.invoke()
|
|
84
|
+
if (forcePendingLayout()) {
|
|
85
|
+
layoutChildren(r - l, b - t)
|
|
86
|
+
if (forcePendingLayout()) scheduleLayout()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private fun layoutChildren(width: Int, height: Int) {
|
|
83
91
|
for (i in 0 until childCount) {
|
|
84
92
|
val child = getChildAt(i)
|
|
85
93
|
child.measure(
|
|
@@ -88,7 +96,22 @@ class NitroModalHostView(context: ThemedReactContext) : ViewGroup(context), Reac
|
|
|
88
96
|
)
|
|
89
97
|
child.layout(0, 0, width, height)
|
|
90
98
|
}
|
|
91
|
-
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Whether a view in the sheet's layout waits for a layout pass. Marks the
|
|
103
|
+
* views above it so the next pass reaches it. The React content is laid out
|
|
104
|
+
* by Fabric, and gone views take no part in layout.
|
|
105
|
+
*/
|
|
106
|
+
private fun forcePendingLayout(view: ViewGroup = this): Boolean {
|
|
107
|
+
var pending = false
|
|
108
|
+
for (i in 0 until view.childCount) {
|
|
109
|
+
val child = view.getChildAt(i)
|
|
110
|
+
if (child.visibility == GONE || child is ModalContentRoot) continue
|
|
111
|
+
if ((child is ViewGroup && forcePendingLayout(child)) || child.isLayoutRequested) pending = true
|
|
112
|
+
}
|
|
113
|
+
if (pending && view !== this) view.forceLayout()
|
|
114
|
+
return pending
|
|
92
115
|
}
|
|
93
116
|
|
|
94
117
|
override fun onAttachedToWindow() {
|