diff --git a/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshLayout.kt b/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshLayout.kt index 5be11ae5e..a68175bfd 100644 --- a/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshLayout.kt +++ b/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshLayout.kt @@ -209,14 +209,14 @@ private fun updateLayoutTree( layoutNodes.add( layoutNode { - layoutId - parentLayoutId - -1 // not childIdx! - resolvedNode.style.layoutStyle - resolvedNode.view.name - useMeasureFunc - null - null + this.layoutId = layoutId + this.parentLayoutId = parentLayoutId + this.childIndex = -1 // not childIdx! + this.style = resolvedNode.style.layoutStyle + this.name = resolvedNode.view.name + this.useMeasureFunc = useMeasureFunc + clearFixedWidth() + clearFixedHeight() } ) layoutCache[layoutId] = layoutCacheKey @@ -296,8 +296,8 @@ internal fun layoutTree( val layoutParentChildren = arrayListOf() updateLayoutTree(manager, root, layoutCache, layoutNodes, layoutParentChildren) val layoutNodeList = layoutNodeList { - layoutNodes - layoutParentChildren + this.layoutNodes.addAll(layoutNodes) + parentChildren.addAll(layoutParentChildren) } // Now we can give the new layoutNodeList to the Rust JNI layout implementation diff --git a/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshTreeBuilder.kt b/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshTreeBuilder.kt index 3974d6aaf..5219e4881 100644 --- a/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshTreeBuilder.kt +++ b/designcompose/src/main/java/com/android/designcompose/squoosh/SquooshTreeBuilder.kt @@ -54,6 +54,7 @@ import com.android.designcompose.definition.view.View import com.android.designcompose.definition.view.ViewDataKt.container import com.android.designcompose.definition.view.ViewStyle import com.android.designcompose.definition.view.containerOrNull +import com.android.designcompose.definition.view.copy import com.android.designcompose.definition.view.frameExtrasOrNull import com.android.designcompose.definition.view.overridesOrNull import com.android.designcompose.definition.view.styleOrNull @@ -566,24 +567,26 @@ private fun generateOverlayNode( } } - val nodeStyleBuilder = node.style.nodeStyle.toBuilder() - nodeStyleBuilder.overflow = Overflow.OVERFLOW_VISIBLE - nodeStyleBuilder.backgroundsList.clear() - - overlay.overlayBackgroundOrNull?.colorOrNull?.let { - val bgColor = - com.android.designcompose.definition.element.color { - r = (it.r * 255.0).toInt() - g = (it.g * 255.0).toInt() - b = (it.b * 255.0).toInt() - a = (it.a * 255.0).toInt() - } - nodeStyleBuilder.backgroundsList.add(background { solid = colorOrVar { color = bgColor } }) + val newNodeStyle = node.style.nodeStyle.copy { + overflow = Overflow.OVERFLOW_VISIBLE + this.backgrounds.clear() + + overlay.overlayBackgroundOrNull?.colorOrNull?.let { + val bgColor = + com.android.designcompose.definition.element.color { + r = (it.r * 255.0).toInt() + g = (it.g * 255.0).toInt() + b = (it.b * 255.0).toInt() + a = (it.a * 255.0).toInt() + } + this.backgrounds.add(background { solid = colorOrVar { color = bgColor } }) + } } + val overlayStyle = viewStyle { layoutStyle = layoutStyleBuilder.build() - nodeStyle = nodeStyleBuilder.build() + nodeStyle = newNodeStyle } // Now synthesize a view.