craft-native 0.0.351 → 0.0.352
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.
|
@@ -212,6 +212,24 @@ private data class CraftNativeLength(
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
/** A screen root owns its viewport unless the document explicitly sizes it.
|
|
216
|
+
* Keep this parent constraint out of the protocol document, and apply it to
|
|
217
|
+
* targeted style updates too. An unstyled fragment with flex children would
|
|
218
|
+
* otherwise measure at their zero flex bases and collapse the entire screen. */
|
|
219
|
+
internal fun craftNativeScreenRootStyle(style: JSONObject): JSONObject {
|
|
220
|
+
val rootStyle = JSONObject()
|
|
221
|
+
val keys = style.keys()
|
|
222
|
+
while (keys.hasNext()) {
|
|
223
|
+
val key = keys.next()
|
|
224
|
+
rootStyle.put(key, style.opt(key))
|
|
225
|
+
}
|
|
226
|
+
if (rootStyle.isNull("height")) {
|
|
227
|
+
if (rootStyle.isNull("flex")) rootStyle.put("flex", 1)
|
|
228
|
+
rootStyle.put("height", "100%")
|
|
229
|
+
}
|
|
230
|
+
return rootStyle
|
|
231
|
+
}
|
|
232
|
+
|
|
215
233
|
private data class CraftNativeLayoutStyle(
|
|
216
234
|
val width: CraftNativeLength? = null,
|
|
217
235
|
val height: CraftNativeLength? = null,
|
|
@@ -1132,14 +1150,23 @@ internal class CraftNativeFlexLayout(context: Context) : LinearLayout(context) {
|
|
|
1132
1150
|
invalidateMeasurements()
|
|
1133
1151
|
}
|
|
1134
1152
|
|
|
1153
|
+
private var viewportChild: View? = null
|
|
1154
|
+
|
|
1155
|
+
fun setViewportChild(view: View?) {
|
|
1156
|
+
viewportChild = view
|
|
1157
|
+
invalidateMeasurements()
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1135
1160
|
fun setChildStyle(view: View, style: JSONObject, density: Float) {
|
|
1136
|
-
|
|
1161
|
+
val effective = if (view === viewportChild) craftNativeScreenRootStyle(style) else style
|
|
1162
|
+
styles[view] = CraftNativeLayoutStyle.from(effective, density)
|
|
1137
1163
|
invalidateMeasurements()
|
|
1138
1164
|
invalidateMeasurementAncestors(parent)
|
|
1139
1165
|
}
|
|
1140
1166
|
|
|
1141
1167
|
override fun onViewRemoved(child: View) {
|
|
1142
1168
|
val parentBeforeRemoval = parent
|
|
1169
|
+
if (child === viewportChild) viewportChild = null
|
|
1143
1170
|
styles.remove(child)
|
|
1144
1171
|
super.onViewRemoved(child)
|
|
1145
1172
|
invalidateMeasurements()
|
|
@@ -5434,6 +5461,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
5434
5461
|
screen.controls.clear()
|
|
5435
5462
|
screen.controls.putAll(next)
|
|
5436
5463
|
screen.handlers.keys.retainAll(retainedViews(screen))
|
|
5464
|
+
screen.view.setViewportChild(tree)
|
|
5437
5465
|
screen.view.setChildStyle(tree, document.optJSONObject("style") ?: JSONObject(), resources.displayMetrics.density)
|
|
5438
5466
|
promoteModalOverlays(screen)
|
|
5439
5467
|
updateSafeAreaViews()
|
package/dist/cli.js
CHANGED
|
@@ -3047,7 +3047,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3047
3047
|
`);
|
|
3048
3048
|
}
|
|
3049
3049
|
// package.json
|
|
3050
|
-
var version = "0.0.
|
|
3050
|
+
var version = "0.0.352";
|
|
3051
3051
|
|
|
3052
3052
|
// bin/cli.ts
|
|
3053
3053
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED