diff --git a/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/UIViewSpacer.kt b/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/UIViewSpacer.kt index 89c07bdebe..40ceb9685f 100644 --- a/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/UIViewSpacer.kt +++ b/redwood-layout-uiview/src/commonMain/kotlin/app/cash/redwood/layout/uiview/UIViewSpacer.kt @@ -45,17 +45,17 @@ internal class UIViewSpacer : Spacer { private fun invalidate() { value.setNeedsLayout() } +} - private inner class SpacerUIView : UIView(cValue { CGRectZero }) { - var width = 0.0 - var height = 0.0 +private class SpacerUIView : UIView(cValue { CGRectZero }) { + var width = 0.0 + var height = 0.0 - override fun intrinsicContentSize(): CValue { - return CGSizeMake(width, height) - } + override fun intrinsicContentSize(): CValue { + return CGSizeMake(width, height) + } - override fun sizeThatFits(size: CValue): CValue { - return CGSizeMake(width, height) - } + override fun sizeThatFits(size: CValue): CValue { + return CGSizeMake(width, height) } } diff --git a/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/ViewSpacer.kt b/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/ViewSpacer.kt index 5046ee23cf..e3fc496b8c 100644 --- a/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/ViewSpacer.kt +++ b/redwood-layout-view/src/main/kotlin/app/cash/redwood/layout/view/ViewSpacer.kt @@ -27,11 +27,10 @@ import kotlin.math.min internal class ViewSpacer( context: Context, -) : View(context), - Spacer { +) : Spacer { private val density = Density(context.resources) - override val value get() = this + override val value: View = SpacerView(context) override var modifier: Modifier = Modifier @@ -44,7 +43,9 @@ internal class ViewSpacer( value.minimumHeight = with(density) { height.toPxInt() } value.requestLayout() } +} +private class SpacerView(context: Context) : View(context) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { setMeasuredDimension( getDefaultSizeSpace(suggestedMinimumWidth, widthMeasureSpec),