diff --git a/build-support/src/main/resources/app/cash/redwood/buildsupport/flexboxHelpers.kt b/build-support/src/main/resources/app/cash/redwood/buildsupport/flexboxHelpers.kt index ec213e9e13..65738de681 100644 --- a/build-support/src/main/resources/app/cash/redwood/buildsupport/flexboxHelpers.kt +++ b/build-support/src/main/resources/app/cash/redwood/buildsupport/flexboxHelpers.kt @@ -18,13 +18,12 @@ package com.example import app.cash.redwood.Modifier import app.cash.redwood.layout.api.CrossAxisAlignment import app.cash.redwood.layout.api.MainAxisAlignment +import app.cash.redwood.layout.modifier.Alignment as AlignmentModifier import app.cash.redwood.layout.modifier.Grow as GrowModifier import app.cash.redwood.layout.modifier.Height as HeightModifier -import app.cash.redwood.layout.modifier.HorizontalAlignment as HorizontalAlignmentModifier import app.cash.redwood.layout.modifier.Margin as MarginModifier import app.cash.redwood.layout.modifier.Shrink as ShrinkModifier import app.cash.redwood.layout.modifier.Size as SizeModifier -import app.cash.redwood.layout.modifier.VerticalAlignment as VerticalAlignmentModifier import app.cash.redwood.layout.modifier.Width as WidthModifier import app.cash.redwood.ui.Density import app.cash.redwood.yoga.AlignItems @@ -73,10 +72,7 @@ internal fun Node.applyModifier(parentModifier: Modifier, density: Density) { marginTop = childModifier.margin.top.toPx().toFloat() marginBottom = childModifier.margin.bottom.toPx().toFloat() } - is HorizontalAlignmentModifier -> { - alignSelf = childModifier.alignment.toAlignSelf() - } - is VerticalAlignmentModifier -> { + is AlignmentModifier -> { alignSelf = childModifier.alignment.toAlignSelf() } is WidthModifier -> with(density) { diff --git a/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/modifiers.kt b/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/modifiers.kt index 3e99464ee5..5c0f36ba82 100644 --- a/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/modifiers.kt +++ b/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/modifiers.kt @@ -52,18 +52,10 @@ public data class Margin( ) /** - * Set the alignment for an item along the horizontal axis. + * Set the alignment for an item. */ -@Modifier(4, ColumnScope::class) -public data class HorizontalAlignment( - val alignment: CrossAxisAlignment, -) - -/** - * Set the alignment for an item along the vertical axis. - */ -@Modifier(5, RowScope::class) -public data class VerticalAlignment( +@Modifier(4, RowScope::class, ColumnScope::class) +public data class Alignment( val alignment: CrossAxisAlignment, ) diff --git a/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/schema.kt b/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/schema.kt index 035e8e6b1f..52a91c0d30 100644 --- a/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/schema.kt +++ b/redwood-layout-schema/src/main/kotlin/app/cash/redwood/layout/schema.kt @@ -25,8 +25,7 @@ import app.cash.redwood.schema.Schema Grow::class, Shrink::class, Margin::class, - HorizontalAlignment::class, - VerticalAlignment::class, + Alignment::class, Width::class, Height::class, Size::class, diff --git a/redwood-layout-shared-test/src/main/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt b/redwood-layout-shared-test/src/main/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt index 163ec20a70..28c3a05fcf 100644 --- a/redwood-layout-shared-test/src/main/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt +++ b/redwood-layout-shared-test/src/main/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt @@ -18,10 +18,9 @@ package app.cash.redwood.layout import app.cash.redwood.Modifier import app.cash.redwood.layout.api.Constraint import app.cash.redwood.layout.api.CrossAxisAlignment +import app.cash.redwood.layout.modifier.Alignment import app.cash.redwood.layout.modifier.Height -import app.cash.redwood.layout.modifier.HorizontalAlignment import app.cash.redwood.layout.modifier.Size -import app.cash.redwood.layout.modifier.VerticalAlignment import app.cash.redwood.layout.modifier.Width import app.cash.redwood.ui.Dp import app.cash.redwood.ui.Margin @@ -94,10 +93,10 @@ abstract class AbstractFlexContainerTest { container.margin(Margin(start = 5.dp, end = 10.dp, top = 20.dp, bottom = 20.dp)) movies.forEachIndexed { index, movie -> val modifier = when (index % 4) { - 0 -> CrossAxisAlignmentImpl(CrossAxisAlignment.Start) - 1 -> CrossAxisAlignmentImpl(CrossAxisAlignment.Center) - 2 -> CrossAxisAlignmentImpl(CrossAxisAlignment.End) - else -> CrossAxisAlignmentImpl(CrossAxisAlignment.Stretch) + 0 -> AlignmentImpl(CrossAxisAlignment.Start) + 1 -> AlignmentImpl(CrossAxisAlignment.Center) + 2 -> AlignmentImpl(CrossAxisAlignment.End) + else -> AlignmentImpl(CrossAxisAlignment.Stretch) } container.add(widget(movie, modifier)) } @@ -239,9 +238,9 @@ private val movies = listOf( "Seven Samurai", ) -private data class CrossAxisAlignmentImpl( +private data class AlignmentImpl( override val alignment: CrossAxisAlignment, -) : HorizontalAlignment, VerticalAlignment +) : Alignment private data class WidthImpl( override val width: Dp,