Remove crossAxisAlignment parameter in Column/Row
Bug:143752028
Test: tests passed + checked demo
Change-Id: Ic81f7e6ecd293e166b141eee6e98ccc8d6b06349
diff --git a/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/NestedScrollerTestCase.kt b/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/NestedScrollerTestCase.kt
index 374552e..cd8e9029 100644
--- a/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/NestedScrollerTestCase.kt
+++ b/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/NestedScrollerTestCase.kt
@@ -25,13 +25,13 @@
import androidx.ui.foundation.ColoredRect
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.FlexColumn
import androidx.ui.foundation.HorizontalScroller
import androidx.ui.layout.Row
import androidx.ui.foundation.ScrollerPosition
import androidx.ui.foundation.VerticalScroller
import androidx.ui.layout.ExpandedWidth
+import androidx.ui.layout.Gravity
import androidx.ui.material.MaterialTheme
import androidx.ui.material.surface.Surface
import androidx.ui.test.ComposeTestCase
@@ -71,7 +71,7 @@
Row(ExpandedWidth) {
repeat(6) {
WithDensity {
- FlexColumn(crossAxisAlignment = CrossAxisAlignment.Start) {
+ FlexColumn {
val color = +memo {
val red = Random.nextInt(256)
val green = Random.nextInt(256)
@@ -88,15 +88,17 @@
text = "Some title",
style = TextStyle(Color.Black, 60.px.toSp())
)
- Row(
- ExpandedWidth,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- Text("3.5 ★", style = TextStyle(fontSize = 40.px.toSp()))
+ Row(ExpandedWidth) {
+ Text(
+ "3.5 ★",
+ style = TextStyle(fontSize = 40.px.toSp()),
+ modifier = Gravity.Center
+ )
ColoredRect(
width = 40.px.toDp(),
height = 40.px.toDp(),
- color = playStoreColor
+ color = playStoreColor,
+ modifier = Gravity.Center
)
}
}
diff --git a/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/ScrollerTestCase.kt b/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/ScrollerTestCase.kt
index 21e32e8..de1288b 100644
--- a/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/ScrollerTestCase.kt
+++ b/ui/integration-tests/test/src/main/java/androidx/ui/test/cases/ScrollerTestCase.kt
@@ -26,7 +26,6 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.foundation.ScrollerPosition
import androidx.ui.foundation.VerticalScroller
import androidx.ui.graphics.Paint
@@ -46,10 +45,7 @@
VerticalScroller(
scrollerPosition = scrollerPosition
) {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(ExpandedHeight) {
for (green in 0..0xFF) {
ColorStripe(0xFF, green, 0)
}
diff --git a/ui/ui-foundation/integration-tests/foundation-demos/src/main/java/androidx/ui/foundation/demos/PopupActivity.kt b/ui/ui-foundation/integration-tests/foundation-demos/src/main/java/androidx/ui/foundation/demos/PopupActivity.kt
index 84d0564..3a4dff7 100644
--- a/ui/ui-foundation/integration-tests/foundation-demos/src/main/java/androidx/ui/foundation/demos/PopupActivity.kt
+++ b/ui/ui-foundation/integration-tests/foundation-demos/src/main/java/androidx/ui/foundation/demos/PopupActivity.kt
@@ -24,6 +24,7 @@
import androidx.ui.core.Alignment
import androidx.ui.core.Dp
import androidx.ui.core.Draw
+import androidx.ui.core.Modifier
import androidx.ui.core.Text
import androidx.ui.core.TextField
import androidx.ui.core.dp
@@ -51,9 +52,10 @@
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.layout.Wrap
import androidx.ui.graphics.Paint
-import androidx.ui.layout.CrossAxisAlignment
+import androidx.ui.layout.ColumnScope
import androidx.ui.layout.ExpandedHeight
import androidx.ui.layout.ExpandedWidth
+import androidx.ui.layout.Gravity
import androidx.ui.text.ParagraphStyle
import androidx.ui.text.TextStyle
import androidx.ui.text.style.TextAlign
@@ -66,9 +68,9 @@
val exampleIndex = +state { 0 }
val totalExamples = 9
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+ Column {
FlexRow(
- ExpandedWidth,
+ ExpandedWidth wraps Gravity.Center,
mainAxisAlignment = MainAxisAlignment.SpaceBetween
) {
inflexible {
@@ -155,11 +157,11 @@
}
@Composable
-fun PopupToggle() {
+fun ColumnScope.PopupToggle() {
val showPopup = +state { true }
val containerSize = 100.dp
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+ Column(Gravity.Center) {
Container(width = containerSize, height = containerSize) {
if (showPopup.value) {
Popup(alignment = Alignment.Center) {
@@ -187,9 +189,8 @@
}
@Composable
-fun PopupWithChangingContent() {
- Container {
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+fun ColumnScope.PopupWithChangingContent() {
+ Column(Gravity.Center) {
val heightSize = 120.dp
val widthSize = 160.dp
val popupContentState = +state { 0 }
@@ -229,11 +230,10 @@
}
)
}
- }
}
@Composable
-fun PopupWithChangingParent() {
+fun ColumnScope.PopupWithChangingParent() {
val containerWidth = 400.dp
val containerHeight = 200.dp
val parentAlignment = +state { Alignment.TopLeft }
@@ -241,7 +241,7 @@
val parentHeight = +state { 60.dp }
val parentSizeChanged = +state { false }
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+ Column(Gravity.Center) {
Container(
height = containerHeight,
width = containerWidth,
@@ -290,9 +290,8 @@
}
@Composable
-fun PopupDropdownAlignment() {
- Container {
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+fun ColumnScope.PopupDropdownAlignment() {
+ Column(Gravity.Center) {
val heightSize = 120.dp
val widthSize = 160.dp
val dropDownAlignment = +state { DropDownAlignment.Left }
@@ -327,18 +326,17 @@
}
}
}
- }
}
@Composable
-fun PopupAlignmentDemo() {
- Container(alignment = Alignment.Center) {
+fun ColumnScope.PopupAlignmentDemo() {
+ Container(Gravity.Center) {
val heightSize = 200.dp
val widthSize = 400.dp
val counter = +state { 0 }
val popupAlignment = +state { Alignment.TopLeft }
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+ Column {
ColoredContainer(
height = heightSize,
width = widthSize,
@@ -368,7 +366,7 @@
}
HeightSpacer(10.dp)
- ColoredContainer(color = Color.White) {
+ ColoredContainer(color = Color.White, modifier = Gravity.Center) {
Text("Alignment: " + popupAlignment.value.toString())
}
}
@@ -376,9 +374,8 @@
}
@Composable
-fun PopupWithEditText() {
- Container {
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+fun ColumnScope.PopupWithEditText() {
+ Column(Gravity.Center) {
val widthSize = 190.dp
val heightSize = 120.dp
val editLineSize = 150.dp
@@ -393,7 +390,8 @@
ColoredContainer(
height = heightSize,
width = widthSize,
- color = Color.Red
+ color = Color.Red,
+ modifier = Gravity.Center
) {
if (showPopup.value) {
Popup(
@@ -419,13 +417,11 @@
}
}
}
- }
}
@Composable
-fun PopupWithChangingSize() {
- Container {
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
+fun ColumnScope.PopupWithChangingSize() {
+ Column(Gravity.Center) {
val showPopup = +state { true }
val heightSize = 120.dp
val widthSize = 160.dp
@@ -473,21 +469,16 @@
}
)
}
- }
}
@Composable
-fun PopupInsideScroller() {
+fun ColumnScope.PopupInsideScroller() {
val heightSize = 400.dp
val widthSize = 200.dp
- Container(width = widthSize, height = heightSize) {
+ Container(width = widthSize, height = heightSize, modifier = Gravity.Center) {
VerticalScroller {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- ColoredContainer(
- width = 80.dp,
+ Column(ExpandedHeight) {
+ ColoredContainer(width = 80.dp,
height = 160.dp,
color = Color(0xFF00FF00)
) {
@@ -497,7 +488,7 @@
}
for (i in 0..30) {
- Text("Scroll #$i")
+ Text(text = "Scroll #$i", modifier = Gravity.Center)
}
}
}
@@ -506,40 +497,39 @@
@Composable
fun PopupOnKeyboardUp() {
- Container {
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
- val widthSize = 190.dp
- val heightSize = 120.dp
+ Column {
+ val widthSize = 190.dp
+ val heightSize = 120.dp
- HeightSpacer(350.dp)
- Text("Start typing in the EditText below the parent(Red rectangle)")
- ColoredContainer(
- height = heightSize,
- width = widthSize,
- color = Color.Red
- ) {
- Popup(Alignment.Center) {
- ColoredContainer(color = Color.Green) {
- Text("Popup")
- }
+ HeightSpacer(350.dp)
+ Text("Start typing in the EditText below the parent(Red rectangle)")
+ ColoredContainer(
+ height = heightSize,
+ width = widthSize,
+ color = Color.Red,
+ modifier = Gravity.Center
+ ) {
+ Popup(Alignment.Center) {
+ ColoredContainer(color = Color.Green) {
+ Text("Popup")
}
}
-
- EditLine(initialText = "Continue typing...", color = Color.Gray)
-
- HeightSpacer(24.dp)
}
+
+ EditLine(initialText = "Continue typing...", color = Color.Gray)
+
+ HeightSpacer(24.dp)
}
}
@Composable
-fun ClickableTextWithBackground(
+fun ColumnScope.ClickableTextWithBackground(
text: String,
color: Color,
onClick: (() -> Unit)? = null,
padding: EdgeInsets = EdgeInsets(0.dp)
) {
- Wrap {
+ Container(Gravity.Center) {
DrawShape(RectangleShape, color)
Clickable( {
Container(padding = padding) {
@@ -551,6 +541,7 @@
@Composable
fun ColoredContainer(
+ modifier: Modifier = Modifier.None,
width: Dp? = null,
height: Dp? = null,
color: Color,
@@ -560,6 +551,7 @@
children: @Composable() () -> Unit
) {
Container(
+ modifier = modifier,
width = width,
height = height,
alignment = alignment,
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
index 44903d8..493e09b 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/ScrollerTest.kt
@@ -41,7 +41,6 @@
import androidx.ui.layout.Column
import androidx.ui.layout.ConstrainedBox
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.DpConstraints
import androidx.ui.layout.Row
import androidx.ui.test.android.AndroidComposeTestRule
@@ -220,7 +219,7 @@
Align(alignment = Alignment.TopLeft) {
ConstrainedBox(constraints = constraints) {
VerticalScroller(scrollerPosition = scrollerPosition) {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
colors.forEach { color ->
Container(
height = 5.px.toDp(),
@@ -258,7 +257,7 @@
Align(alignment = Alignment.TopLeft) {
ConstrainedBox(constraints = constraints) {
HorizontalScroller(scrollerPosition = scrollerPosition) {
- Row(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Row {
colors.forEach { color ->
Container(
width = 5.px.toDp(),
diff --git a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/SemanticsL1.kt b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/SemanticsL1.kt
index cb6aa17..634bfd1 100644
--- a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/SemanticsL1.kt
+++ b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/SemanticsL1.kt
@@ -24,7 +24,6 @@
import androidx.ui.core.px
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.material.Button
import androidx.ui.material.MaterialTheme
@@ -33,6 +32,7 @@
import androidx.compose.unaryPlus
import androidx.ui.layout.ExpandedHeight
import androidx.ui.layout.ExpandedWidth
+import androidx.ui.layout.Gravity
/** A [SemanticProperty] is used to store semantic information about a component.
*
@@ -174,12 +174,13 @@
InvokeActionsByParameters(actions)
}
}
- Row(
- ExpandedWidth,
- mainAxisAlignment = MainAxisAlignment.Center,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- Container(height = 300.dp, width = 500.dp, children = children)
+ Row(ExpandedWidth, mainAxisAlignment = MainAxisAlignment.Center) {
+ Container(
+ height = 300.dp,
+ width = 500.dp,
+ modifier = Gravity.Center,
+ children = children
+ )
}
}
}
diff --git a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesActivity.kt b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesActivity.kt
index fd5be7d..29b8b46 100644
--- a/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesActivity.kt
+++ b/ui/ui-framework/integration-tests/framework-demos/src/main/java/androidx/ui/framework/demos/autofill/ExplicitAutofillTypesActivity.kt
@@ -37,7 +37,6 @@
import androidx.ui.input.ImeAction
import androidx.ui.input.KeyboardType
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.HeightSpacer
import androidx.ui.material.MaterialTheme
@@ -47,7 +46,7 @@
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
val nameState = +state { "Enter name here" }
val emailState = +state { "Enter email here" }
diff --git a/ui/ui-layout/api/0.1.0-dev03.txt b/ui/ui-layout/api/0.1.0-dev03.txt
index 94ebc47..397cdbb 100644
--- a/ui/ui-layout/api/0.1.0-dev03.txt
+++ b/ui/ui-layout/api/0.1.0-dev03.txt
@@ -126,10 +126,10 @@
public final class FlexKt {
ctor public FlexKt();
- method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
+ method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
method public static void FlexColumn(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
method public static void FlexRow(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
- method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
+ method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
}
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
diff --git a/ui/ui-layout/api/current.txt b/ui/ui-layout/api/current.txt
index 94ebc47..397cdbb 100644
--- a/ui/ui-layout/api/current.txt
+++ b/ui/ui-layout/api/current.txt
@@ -126,10 +126,10 @@
public final class FlexKt {
ctor public FlexKt();
- method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
+ method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
method public static void FlexColumn(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
method public static void FlexRow(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
- method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
+ method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
}
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
diff --git a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev03.txt b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev03.txt
index 94ebc47..397cdbb 100644
--- a/ui/ui-layout/api/public_plus_experimental_0.1.0-dev03.txt
+++ b/ui/ui-layout/api/public_plus_experimental_0.1.0-dev03.txt
@@ -126,10 +126,10 @@
public final class FlexKt {
ctor public FlexKt();
- method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
+ method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
method public static void FlexColumn(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
method public static void FlexRow(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
- method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
+ method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
}
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
diff --git a/ui/ui-layout/api/public_plus_experimental_current.txt b/ui/ui-layout/api/public_plus_experimental_current.txt
index 94ebc47..397cdbb 100644
--- a/ui/ui-layout/api/public_plus_experimental_current.txt
+++ b/ui/ui-layout/api/public_plus_experimental_current.txt
@@ -126,10 +126,10 @@
public final class FlexKt {
ctor public FlexKt();
- method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
+ method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
method public static void FlexColumn(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
method public static void FlexRow(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
- method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
+ method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
}
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
diff --git a/ui/ui-layout/api/restricted_0.1.0-dev03.txt b/ui/ui-layout/api/restricted_0.1.0-dev03.txt
index 94ebc47..397cdbb 100644
--- a/ui/ui-layout/api/restricted_0.1.0-dev03.txt
+++ b/ui/ui-layout/api/restricted_0.1.0-dev03.txt
@@ -126,10 +126,10 @@
public final class FlexKt {
ctor public FlexKt();
- method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
+ method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
method public static void FlexColumn(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
method public static void FlexRow(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
- method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
+ method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
}
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
diff --git a/ui/ui-layout/api/restricted_current.txt b/ui/ui-layout/api/restricted_current.txt
index 94ebc47..397cdbb 100644
--- a/ui/ui-layout/api/restricted_current.txt
+++ b/ui/ui-layout/api/restricted_current.txt
@@ -126,10 +126,10 @@
public final class FlexKt {
ctor public FlexKt();
- method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
+ method public static void Column(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.ColumnScope,kotlin.Unit> children);
method public static void FlexColumn(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
method public static void FlexRow(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, androidx.ui.layout.LayoutSize crossAxisSize = androidx.ui.layout.LayoutSize.Wrap, kotlin.jvm.functions.Function1<? super androidx.ui.layout.FlexChildren,kotlin.Unit> block);
- method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, androidx.ui.layout.CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
+ method public static void Row(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.layout.MainAxisAlignment mainAxisAlignment = androidx.ui.layout.MainAxisAlignment.Start, kotlin.jvm.functions.Function1<? super androidx.ui.layout.RowScope,kotlin.Unit> children);
}
@androidx.ui.layout.LayoutScopeMarker public abstract sealed class FlexScope {
diff --git a/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/ComplexLayoutDemos.kt b/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/ComplexLayoutDemos.kt
index 62861c1..c989ad36 100644
--- a/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/ComplexLayoutDemos.kt
+++ b/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/ComplexLayoutDemos.kt
@@ -52,7 +52,7 @@
import androidx.ui.core.VerticalAlignmentLine
import androidx.ui.core.sp
import androidx.ui.layout.AlignmentLineOffset
-import androidx.ui.layout.CrossAxisAlignment
+import androidx.ui.layout.Gravity
import androidx.ui.layout.Wrap
import androidx.ui.layout.samples.DrawRectangle
import androidx.ui.layout.samples.SizedRectangle
@@ -387,9 +387,9 @@
@Composable
fun RowBaselineAlignment() {
- Row(crossAxisAlignment = CrossAxisAlignment.AlignmentLine(FirstBaseline)) {
- Text("First text")
- Column {
+ Row {
+ Text("First text", modifier = Gravity.RelativeToSiblings(FirstBaseline))
+ Column(modifier = Gravity.RelativeToSiblings(FirstBaseline)) {
SizedRectangle(color = Color.Blue, width = 10.dp, height = 50.dp)
Padding(30.dp) {
Text("Second text", style = TextStyle(fontSize = 45.sp))
diff --git a/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/LayoutActivity.kt b/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/LayoutActivity.kt
index c46cab9..198ed8c 100644
--- a/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/LayoutActivity.kt
+++ b/ui/ui-layout/integration-tests/layout-demos/src/main/java/androidx/ui/layout/demos/LayoutActivity.kt
@@ -23,7 +23,6 @@
import androidx.ui.core.dp
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.HeightSpacer
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.layout.Row
@@ -32,10 +31,12 @@
import androidx.ui.graphics.Color
import androidx.ui.text.TextStyle
import androidx.compose.Composable
+import androidx.ui.core.Modifier
import androidx.ui.core.setContent
import androidx.ui.core.sp
import androidx.ui.layout.ExpandedHeight
import androidx.ui.layout.ExpandedWidth
+import androidx.ui.layout.Gravity
import androidx.ui.layout.samples.DrawRectangle
class LayoutActivity : Activity() {
@@ -64,10 +65,7 @@
@Composable
fun LayoutDemo() {
val lightGrey = Color(0xFFCFD8DC)
- Column(
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(mainAxisAlignment = MainAxisAlignment.Start) {
Text(text = "Row", style = TextStyle(fontSize = 48.sp))
ContainerWithBackground(width = ExampleSize, color = lightGrey) {
Row(ExpandedWidth) {
@@ -97,22 +95,16 @@
}
HeightSpacer(height = 24.dp)
ContainerWithBackground(width = ExampleSize, color = lightGrey) {
- Row(
- ExpandedWidth,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Row(ExpandedWidth) {
PurpleSquare()
CyanSquare()
}
}
HeightSpacer(height = 24.dp)
ContainerWithBackground(width = ExampleSize, color = lightGrey) {
- Row(
- ExpandedWidth,
- crossAxisAlignment = CrossAxisAlignment.End
- ) {
- PurpleSquare()
- CyanSquare()
+ Row(ExpandedWidth) {
+ PurpleSquare(Gravity.Bottom)
+ CyanSquare(Gravity.Bottom)
}
}
HeightSpacer(height = 24.dp)
@@ -146,22 +138,16 @@
}
WidthSpacer(width = 24.dp)
ContainerWithBackground(height = ExampleSize, color = lightGrey) {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(ExpandedHeight) {
PurpleSquare()
CyanSquare()
}
}
WidthSpacer(width = 24.dp)
ContainerWithBackground(height = ExampleSize, color = lightGrey) {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.End
- ) {
- PurpleSquare()
- CyanSquare()
+ Column(ExpandedHeight) {
+ PurpleSquare(Gravity.End)
+ CyanSquare(Gravity.End)
}
}
}
@@ -169,15 +155,15 @@
}
@Composable
-fun PurpleSquare() {
- Container(width = BigSize, height = BigSize) {
+fun PurpleSquare(modifier: Modifier = Modifier.None) {
+ Container(width = BigSize, height = BigSize, modifier = modifier) {
DrawRectangle(color = Color(0xFF6200EE))
}
}
@Composable
-fun CyanSquare() {
- Container(width = SmallSize, height = SmallSize) {
+fun CyanSquare(modifier: Modifier = Modifier.None) {
+ Container(width = SmallSize, height = SmallSize, modifier = modifier) {
DrawRectangle(color = Color(0xFF03DAC6))
}
}
diff --git a/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt b/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt
index 1063a67..14f1f30 100644
--- a/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt
+++ b/ui/ui-layout/integration-tests/samples/src/main/java/androidx/ui/layout/samples/IntrinsicSample.kt
@@ -30,6 +30,7 @@
import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.DpConstraints
import androidx.ui.layout.ExpandedHeight
+import androidx.ui.layout.ExpandedWidth
import androidx.ui.layout.FlexRow
import androidx.ui.layout.MaxIntrinsicHeight
import androidx.ui.layout.MaxIntrinsicWidth
@@ -43,7 +44,7 @@
* Here [MinIntrinsicWidth] is adding a speculative width measurement pass for the [Column],
* whose minimum intrinsic width will correspond to the preferred width of the largest
* [ConstrainedBox]. Then [MinIntrinsicWidth] will measure the [Column] with tight width, the same
- * as the premeasured minimum intrinsic width, which due to [CrossAxisAlignment.Stretch] will force
+ * as the premeasured minimum intrinsic width, which due to [ExpandedWidth] will force
* the [ConstrainedBox]s to use the same width.
*/
@Sampled
@@ -51,17 +52,23 @@
fun SameWidthBoxes() {
Wrap {
MinIntrinsicWidth {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Stretch
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(width = 20.dp, height = 10.dp)) {
+ Column(ExpandedHeight) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(width = 20.dp, height = 10.dp),
+ modifier = ExpandedWidth
+ ) {
DrawShape(RectangleShape, Color.Gray)
}
- ConstrainedBox(DpConstraints.tightConstraints(width = 30.dp, height = 10.dp)) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(width = 30.dp, height = 10.dp),
+ modifier = ExpandedWidth
+ ) {
DrawShape(RectangleShape, Color.Blue)
}
- ConstrainedBox(DpConstraints.tightConstraints(width = 10.dp, height = 10.dp)) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(width = 10.dp, height = 10.dp),
+ modifier = ExpandedWidth
+ ) {
DrawShape(RectangleShape, Color.Magenta)
}
}
@@ -106,7 +113,7 @@
* Here [MaxIntrinsicWidth] is adding a speculative width measurement pass for the [Column],
* whose maximum intrinsic width will correspond to the preferred width of the largest
* [ConstrainedBox]. Then [MaxIntrinsicWidth] will measure the [Column] with tight width, the same
- * as the premeasured maximum intrinsic width, which due to [CrossAxisAlignment.Stretch] will force
+ * as the premeasured maximum intrinsic width, which due to [ExpandedWidth] modifiers will force
* the [ConstrainedBox]s to use the same width.
*/
@Sampled
@@ -114,19 +121,16 @@
fun SameWidthTextBoxes() {
Wrap {
MaxIntrinsicWidth {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Stretch
- ) {
- Wrap {
+ Column(ExpandedHeight) {
+ Container(ExpandedWidth) {
DrawShape(RectangleShape, Color.Gray)
Text("Short text")
}
- Wrap {
+ Container(ExpandedWidth) {
DrawShape(RectangleShape, Color.Blue)
Text("Extremely long text giving the width of its siblings")
}
- Wrap {
+ Container(ExpandedWidth) {
DrawShape(RectangleShape, Color.Magenta)
Text("Medium length text")
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
index e20dd16..81a145d 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
@@ -553,107 +553,6 @@
// region Cross axis alignment tests in Row
@Test
- fun testRow_withStartCrossAxisAlignment() = withDensity(density) {
- val sizeDp = 50.dp
- val size = sizeDp.toIntPx()
-
- val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
- show {
- Align(Alignment.CenterLeft) {
- Row(crossAxisAlignment = CrossAxisAlignment.Start) {
- Container(width = sizeDp, height = sizeDp) {
- OnPositioned( coordinates ->
- childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
-
- Container(width = (sizeDp * 2), height = (sizeDp * 2)) {
- OnPositioned( coordinates ->
- childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
- }
- }
- }
- drawLatch.await(1, TimeUnit.SECONDS)
-
- val root = findAndroidComposeView()
- waitForDraw(root)
-
- assertEquals(PxSize(size, size), childSize[0])
- assertEquals(
- PxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
- childSize[1]
- )
- assertEquals(
- PxPosition(0.px, (root.height.px / 2 - size.toPx()).round().toPx()),
- childPosition[0]
- )
- assertEquals(
- PxPosition(size.toPx(), (root.height.px / 2 - size.toPx()).round().toPx()),
- childPosition[1]
- )
- }
-
- @Test
- fun testRow_withEndCrossAxisAlignment() = withDensity(density) {
- val sizeDp = 50.dp
- val size = sizeDp.toIntPx()
-
- val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
- show {
- Align(Alignment.CenterLeft) {
- Row(crossAxisAlignment = CrossAxisAlignment.End) {
- Container(width = sizeDp, height = sizeDp) {
- OnPositioned( coordinates ->
- childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
-
- Container(width = (sizeDp * 2), height = (sizeDp * 2)) {
- OnPositioned( coordinates ->
- childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
- }
- }
- }
- drawLatch.await(1, TimeUnit.SECONDS)
-
- val root = findAndroidComposeView()
- waitForDraw(root)
-
- assertEquals(PxSize(size, size), childSize[0])
- assertEquals(
- PxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
- childSize[1]
- )
- assertEquals(
- PxPosition(
- 0.px, ((root.height.px + (sizeDp.toPx() * 2)
- .round().toPx()) / 2 - size.toPx()).round().toPx()
- ),
- childPosition[0]
- )
- assertEquals(
- PxPosition(size.toPx(), (root.height.px / 2 - size.toPx()).round().toPx()),
- childPosition[1]
- )
- }
-
- @Test
fun testRow_withStretchCrossAxisAlignment() = withDensity(density) {
val sizeDp = 50.dp
val size = sizeDp.toIntPx()
@@ -663,8 +562,8 @@
val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
show {
Align(Alignment.CenterLeft) {
- Row(crossAxisAlignment = CrossAxisAlignment.Stretch) {
- Container(width = sizeDp, height = sizeDp) {
+ Row {
+ Container(width = sizeDp, height = sizeDp, modifier = ExpandedHeight) {
OnPositioned( coordinates ->
childSize[0] = coordinates.size
childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
@@ -672,7 +571,11 @@
})
}
- Container(width = (sizeDp * 2), height = (sizeDp * 2)) {
+ Container(
+ width = (sizeDp * 2),
+ height = (sizeDp * 2),
+ modifier = ExpandedHeight
+ ) {
OnPositioned( coordinates ->
childSize[1] = coordinates.size
childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
@@ -841,108 +744,6 @@
// region Cross axis alignment tests in Column
@Test
- fun testColumn_withStartCrossAxisAlignment() = withDensity(density) {
- val sizeDp = 50.dp
- val size = sizeDp.toIntPx()
-
- val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
- show {
- Align(Alignment.TopCenter) {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
- Container(width = sizeDp, height = sizeDp) {
- OnPositioned( coordinates ->
- childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
-
- Container(width = (sizeDp * 2), height = (sizeDp * 2)) {
- OnPositioned( coordinates ->
- childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
- }
- }
- }
- drawLatch.await(1, TimeUnit.SECONDS)
-
- val root = findAndroidComposeView()
- waitForDraw(root)
-
- assertEquals(PxSize(size, size), childSize[0])
- assertEquals(
- PxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
- childSize[1]
- )
- assertEquals(
- PxPosition((root.width.px / 2 - size.toPx()).round().toPx(), 0.px),
- childPosition[0]
- )
- assertEquals(
- PxPosition((root.width.px / 2 - size.toPx()).round().toPx(), size.toPx()),
- childPosition[1]
- )
- }
-
- @Test
- fun testColumn_withEndCrossAxisAlignment() = withDensity(density) {
- val sizeDp = 50.dp
- val size = sizeDp.toIntPx()
-
- val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
- val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
- show {
- Align(Alignment.TopCenter) {
- Column(crossAxisAlignment = CrossAxisAlignment.End) {
- Container(width = sizeDp, height = sizeDp) {
- OnPositioned( coordinates ->
- childSize[0] = coordinates.size
- childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
-
- Container(width = (sizeDp * 2), height = (sizeDp * 2)) {
- OnPositioned( coordinates ->
- childSize[1] = coordinates.size
- childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- drawLatch.countDown()
- })
- }
- }
- }
- }
- drawLatch.await(1, TimeUnit.SECONDS)
-
- val root = findAndroidComposeView()
- waitForDraw(root)
-
- assertEquals(PxSize(size, size), childSize[0])
- assertEquals(
- PxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
- childSize[1]
- )
- assertEquals(
- PxPosition(
- (((root.width.px + (sizeDp.toPx() * 2)
- .round().toPx()) / 2).round() - size).toPx(),
- 0.px
- ),
- childPosition[0]
- )
- assertEquals(
- PxPosition((root.width.px / 2 - size.toPx()).round().toPx(), size.toPx()),
- childPosition[1]
- )
- }
-
- @Test
fun testColumn_withStretchCrossAxisAlignment() = withDensity(density) {
val sizeDp = 50.dp
val size = sizeDp.toIntPx()
@@ -952,8 +753,8 @@
val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
show {
Align(Alignment.TopCenter) {
- Column(crossAxisAlignment = CrossAxisAlignment.Stretch) {
- Container(width = sizeDp, height = sizeDp) {
+ Column {
+ Container(width = sizeDp, height = sizeDp, modifier = ExpandedWidth) {
OnPositioned( coordinates ->
childSize[0] = coordinates.size
childPosition[0] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
@@ -961,7 +762,9 @@
})
}
- Container(width = (sizeDp * 2), height = (sizeDp * 2)) {
+ Container(
+ width = (sizeDp * 2), height = (sizeDp * 2), modifier = ExpandedWidth
+ ) {
OnPositioned( coordinates ->
childSize[1] = coordinates.size
childPosition[1] = coordinates.localToGlobal(PxPosition(0.px, 0.px))
@@ -2652,40 +2455,24 @@
) { }
}
}, @Composable {
- Row(
- ExpandedWidth,
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Row(ExpandedWidth, mainAxisAlignment = MainAxisAlignment.Start) {
Container(AspectRatio(2f)) { }
ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
}
}, @Composable {
- Row(
- ExpandedWidth,
- mainAxisAlignment = MainAxisAlignment.Center,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- Container(AspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ Row(ExpandedWidth, mainAxisAlignment = MainAxisAlignment.Center) {
+ Container(Gravity.Center wraps AspectRatio(2f)) { }
+ ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), Gravity.Center) { }
}
}, @Composable {
- Row(
- ExpandedWidth,
- mainAxisAlignment = MainAxisAlignment.End,
- crossAxisAlignment = CrossAxisAlignment.End
- ) {
- Container(AspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ Row(ExpandedWidth, mainAxisAlignment = MainAxisAlignment.End) {
+ Container(Gravity.Bottom wraps AspectRatio(2f)) { }
+ ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), Gravity.Bottom) { }
}
}, @Composable {
- Row(
- ExpandedWidth,
- mainAxisAlignment = MainAxisAlignment.SpaceAround,
- crossAxisAlignment = CrossAxisAlignment.Stretch
- ) {
- Container(AspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ Row(ExpandedWidth, mainAxisAlignment = MainAxisAlignment.SpaceAround) {
+ Container(ExpandedHeight wraps AspectRatio(2f)) { }
+ ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), ExpandedHeight) { }
}
}, @Composable {
Row(
@@ -2746,44 +2533,65 @@
ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), Gravity.Bottom) { }
}
}, @Composable {
- Row(
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Row(mainAxisAlignment = MainAxisAlignment.Start) {
ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), Flexible(3f)) { }
ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), Flexible(2f)) { }
Container(AspectRatio(2f) wraps Flexible(2f)) { }
ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
}
}, @Composable {
- Row(
- mainAxisAlignment = MainAxisAlignment.Center,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), Flexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), Flexible(2f)) { }
- Container(AspectRatio(2f) wraps Flexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ Row(mainAxisAlignment = MainAxisAlignment.Center) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ modifier = Flexible(3f) wraps Gravity.Center
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 40.dp),
+ modifier = Flexible(2f) wraps Gravity.Center
+ ) { }
+ Container(
+ AspectRatio(2f) wraps Flexible(2f) wraps Gravity.Center
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ modifier = Gravity.Center
+ ) { }
}
}, @Composable {
- Row(
- mainAxisAlignment = MainAxisAlignment.End,
- crossAxisAlignment = CrossAxisAlignment.End
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), Flexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), Flexible(2f)) { }
- Container(AspectRatio(2f) wraps Flexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ Row(mainAxisAlignment = MainAxisAlignment.End) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ modifier = Flexible(3f) wraps Gravity.Bottom
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 40.dp),
+ modifier = Flexible(2f) wraps Gravity.Bottom
+ ) { }
+ Container(
+ AspectRatio(2f) wraps Flexible(2f) wraps Gravity.Bottom
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ modifier = Gravity.Bottom
+ ) { }
}
}, @Composable {
- Row(
- mainAxisAlignment = MainAxisAlignment.SpaceAround,
- crossAxisAlignment = CrossAxisAlignment.Stretch
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp), Flexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 40.dp), Flexible(2f)) { }
- Container(AspectRatio(2f) wraps Flexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
+ Row(mainAxisAlignment = MainAxisAlignment.SpaceAround) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ modifier = Flexible(3f) wraps ExpandedHeight
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 40.dp),
+ modifier = Flexible(2f) wraps ExpandedHeight
+ ) { }
+ Container(
+ AspectRatio(2f) wraps Flexible(2f) wraps ExpandedHeight
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(20.dp, 30.dp),
+ modifier = ExpandedHeight
+ ) { }
}
}, @Composable {
Row(mainAxisAlignment = MainAxisAlignment.SpaceBetween) {
@@ -2873,40 +2681,24 @@
ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
}
}, @Composable {
- Column(
- ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(ExpandedHeight, mainAxisAlignment = MainAxisAlignment.Start) {
Container(AspectRatio(2f)) { }
ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
}
}, @Composable {
- Column(
- ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.Center,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- Container(AspectRatio(2f)) { }
+ Column(ExpandedHeight, mainAxisAlignment = MainAxisAlignment.Center) {
+ Container(Gravity.Center wraps AspectRatio(2f)) { }
ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
}
}, @Composable {
- Column(
- ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.End,
- crossAxisAlignment = CrossAxisAlignment.End
- ) {
- Container(AspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ Column(ExpandedHeight, mainAxisAlignment = MainAxisAlignment.End) {
+ Container(Gravity.End wraps AspectRatio(2f)) { }
+ ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), Gravity.End) { }
}
}, @Composable {
- Column(
- ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.SpaceAround,
- crossAxisAlignment = CrossAxisAlignment.Stretch
- ) {
- Container(AspectRatio(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp)) { }
+ Column(ExpandedHeight, mainAxisAlignment = MainAxisAlignment.SpaceAround) {
+ Container(ExpandedWidth wraps AspectRatio(2f)) { }
+ ConstrainedBox(DpConstraints.tightConstraints(50.dp, 40.dp), ExpandedWidth) { }
}
}, @Composable {
Column(
@@ -2967,44 +2759,65 @@
ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), Gravity.End) { }
}
}, @Composable {
- Column(
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(mainAxisAlignment = MainAxisAlignment.Start) {
ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), Flexible(3f)) { }
ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), Flexible(2f)) { }
Container(AspectRatio(0.5f) wraps Flexible(2f)) { }
ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
}
}, @Composable {
- Column(
- mainAxisAlignment = MainAxisAlignment.Center,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), Flexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), Flexible(2f)) { }
- Container(AspectRatio(0.5f) wraps Flexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ Column(mainAxisAlignment = MainAxisAlignment.Center) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ modifier = Flexible(3f) wraps Gravity.Center
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(40.dp, 30.dp),
+ modifier = Flexible(2f) wraps Gravity.Center
+ ) { }
+ Container(
+ AspectRatio(0.5f) wraps Flexible(2f) wraps Gravity.Center
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ modifier = Gravity.Center
+ ) { }
}
}, @Composable {
- Column(
- mainAxisAlignment = MainAxisAlignment.End,
- crossAxisAlignment = CrossAxisAlignment.End
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), Flexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), Flexible(2f)) { }
- Container(AspectRatio(0.5f) wraps Flexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ Column(mainAxisAlignment = MainAxisAlignment.End) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ modifier = Flexible(3f) wraps Gravity.End
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(40.dp, 30.dp),
+ modifier = Flexible(2f) wraps Gravity.End
+ ) { }
+ Container(
+ AspectRatio(0.5f) wraps Flexible(2f) wraps Gravity.End
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ modifier = Gravity.End
+ ) { }
}
}, @Composable {
- Column(
- mainAxisAlignment = MainAxisAlignment.SpaceAround,
- crossAxisAlignment = CrossAxisAlignment.Stretch
- ) {
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp), Flexible(3f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(40.dp, 30.dp), Flexible(2f)) { }
- Container(AspectRatio(0.5f) wraps Flexible(2f)) { }
- ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
+ Column(mainAxisAlignment = MainAxisAlignment.SpaceAround) {
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ modifier = Flexible(3f) wraps ExpandedWidth
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(40.dp, 30.dp),
+ modifier = Flexible(2f) wraps ExpandedWidth
+ ) { }
+ Container(
+ AspectRatio(0.5f) wraps Flexible(2f) wraps ExpandedWidth
+ ) { }
+ ConstrainedBox(
+ constraints = DpConstraints.tightConstraints(30.dp, 20.dp),
+ modifier = ExpandedWidth
+ ) { }
}
}, @Composable {
Column(mainAxisAlignment = MainAxisAlignment.SpaceBetween) {
@@ -3086,10 +2899,7 @@
}
}
}, @Composable {
- FlexRow(
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ FlexRow(mainAxisAlignment = MainAxisAlignment.Start) {
expanded(flex = 3f) {
ConstrainedBox(DpConstraints.tightConstraints(20.dp, 30.dp)) { }
}
@@ -3253,10 +3063,7 @@
}
}
}, @Composable {
- FlexColumn(
- mainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ FlexColumn(mainAxisAlignment = MainAxisAlignment.Start) {
expanded(flex = 3f) {
ConstrainedBox(DpConstraints.tightConstraints(30.dp, 20.dp)) { }
}
@@ -3403,32 +3210,34 @@
}
@Test
- fun testRow_alignmentUsingAlignmentKey() = withDensity(density) {
+ fun testFlexRow_alignmentUsingAlignmentKey() = withDensity(density) {
val TestAlignmentLine = HorizontalAlignmentLine(::min)
val rowSize = Ref<PxSize>()
val childPosition = arrayOf<Ref<PxPosition>>(Ref(), Ref(), Ref())
val layoutLatch = CountDownLatch(4)
show {
Wrap {
- Row(crossAxisAlignment = CrossAxisAlignment.AlignmentLine(TestAlignmentLine)) {
- SaveLayoutInfo(rowSize, Ref(), layoutLatch)
- OnChildPositioned({ coordinates ->
- childPosition[0].value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- layoutLatch.countDown()
- }) {
- FixedSizeLayout(10.ipx, 30.ipx, mapOf(TestAlignmentLine to 10.ipx))
- }
- OnChildPositioned({ coordinates ->
- childPosition[1].value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- layoutLatch.countDown()
- }) {
- FixedSizeLayout(10.ipx, 10.ipx, mapOf())
- }
- OnChildPositioned({ coordinates ->
- childPosition[2].value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- layoutLatch.countDown()
- }) {
- FixedSizeLayout(10.ipx, 30.ipx, mapOf(TestAlignmentLine to 20.ipx))
+ FlexRow(crossAxisAlignment = CrossAxisAlignment.AlignmentLine(TestAlignmentLine)) {
+ inflexible {
+ SaveLayoutInfo(rowSize, Ref(), layoutLatch)
+ OnChildPositioned({ coordinates ->
+ childPosition[0].value = coordinates.localToGlobal(PxPosition.Origin)
+ layoutLatch.countDown()
+ }) {
+ FixedSizeLayout(10.ipx, 30.ipx, mapOf(TestAlignmentLine to 10.ipx))
+ }
+ OnChildPositioned({ coordinates ->
+ childPosition[1].value = coordinates.localToGlobal(PxPosition.Origin)
+ layoutLatch.countDown()
+ }) {
+ FixedSizeLayout(10.ipx, 10.ipx, mapOf())
+ }
+ OnChildPositioned({ coordinates ->
+ childPosition[2].value = coordinates.localToGlobal(PxPosition.Origin)
+ layoutLatch.countDown()
+ }) {
+ FixedSizeLayout(10.ipx, 30.ipx, mapOf(TestAlignmentLine to 20.ipx))
+ }
}
}
}
@@ -3442,32 +3251,36 @@
}
@Test
- fun testColumn_alignmentUsingAlignmentKey() = withDensity(density) {
+ fun testFlexColumn_alignmentUsingAlignmentKey() = withDensity(density) {
val TestAlignmentLine = VerticalAlignmentLine(::min)
val columnSize = Ref<PxSize>()
val childPosition = arrayOf<Ref<PxPosition>>(Ref(), Ref(), Ref())
val layoutLatch = CountDownLatch(4)
show {
Wrap {
- Column(crossAxisAlignment = CrossAxisAlignment.AlignmentLine(TestAlignmentLine)) {
- SaveLayoutInfo(columnSize, Ref(), layoutLatch)
- OnChildPositioned({ coordinates ->
- childPosition[0].value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- layoutLatch.countDown()
- }) {
- FixedSizeLayout(30.ipx, 10.ipx, mapOf(TestAlignmentLine to 10.ipx))
- }
- OnChildPositioned({ coordinates ->
- childPosition[1].value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- layoutLatch.countDown()
- }) {
- FixedSizeLayout(10.ipx, 10.ipx, mapOf())
- }
- OnChildPositioned({ coordinates ->
- childPosition[2].value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
- layoutLatch.countDown()
- }) {
- FixedSizeLayout(30.ipx, 10.ipx, mapOf(TestAlignmentLine to 20.ipx))
+ FlexColumn(
+ crossAxisAlignment = CrossAxisAlignment.AlignmentLine(TestAlignmentLine)
+ ) {
+ inflexible {
+ SaveLayoutInfo(columnSize, Ref(), layoutLatch)
+ OnChildPositioned({ coordinates ->
+ childPosition[0].value = coordinates.localToGlobal(PxPosition.Origin)
+ layoutLatch.countDown()
+ }) {
+ FixedSizeLayout(30.ipx, 10.ipx, mapOf(TestAlignmentLine to 10.ipx))
+ }
+ OnChildPositioned({ coordinates ->
+ childPosition[1].value = coordinates.localToGlobal(PxPosition.Origin)
+ layoutLatch.countDown()
+ }) {
+ FixedSizeLayout(10.ipx, 10.ipx, mapOf())
+ }
+ OnChildPositioned({ coordinates ->
+ childPosition[2].value = coordinates.localToGlobal(PxPosition.Origin)
+ layoutLatch.countDown()
+ }) {
+ FixedSizeLayout(30.ipx, 10.ipx, mapOf(TestAlignmentLine to 20.ipx))
+ }
}
}
}
diff --git a/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt b/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt
index 5e14130..2f1b111 100644
--- a/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt
+++ b/ui/ui-layout/src/main/java/androidx/ui/layout/Flex.kt
@@ -313,21 +313,18 @@
*
* @param mainAxisAlignment The alignment of the layout's children in main axis direction.
* Default is [MainAxisAlignment.Start].
- * @param crossAxisAlignment The alignment of the layout's children in cross axis direction.
- * Default is [CrossAxisAlignment.Start].
*/
@Composable
fun Row(
modifier: Modifier = Modifier.None,
mainAxisAlignment: MainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment: CrossAxisAlignment = CrossAxisAlignment.Start,
children: @Composable() RowScope.() -> Unit
) {
FlexLayout(
orientation = LayoutOrientation.Horizontal,
modifier = modifier,
mainAxisAlignment = mainAxisAlignment,
- crossAxisAlignment = crossAxisAlignment,
+ crossAxisAlignment = CrossAxisAlignment.Start,
crossAxisSize = LayoutSize.Wrap,
children = { RowScope().children() }
)
@@ -346,21 +343,18 @@
*
* @param mainAxisAlignment The alignment of the layout's children in main axis direction.
* Default is [MainAxisAlignment.Start].
- * @param crossAxisAlignment The alignment of the layout's children in cross axis direction.
- * Default is [CrossAxisAlignment.Start].
*/
@Composable
fun Column(
modifier: Modifier = Modifier.None,
mainAxisAlignment: MainAxisAlignment = MainAxisAlignment.Start,
- crossAxisAlignment: CrossAxisAlignment = CrossAxisAlignment.Start,
children: @Composable() ColumnScope.() -> Unit
) {
FlexLayout(
orientation = LayoutOrientation.Vertical,
modifier = modifier,
mainAxisAlignment = mainAxisAlignment,
- crossAxisAlignment = crossAxisAlignment,
+ crossAxisAlignment = CrossAxisAlignment.Start,
crossAxisSize = LayoutSize.Wrap,
children = { ColumnScope().children() }
)
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/AppBarActivity.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/AppBarActivity.kt
index 414ba6f..672fc95 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/AppBarActivity.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/AppBarActivity.kt
@@ -24,7 +24,6 @@
import androidx.ui.core.dp
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.FlexColumn
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.material.RadioGroup
@@ -94,8 +93,7 @@
flexible(1f) {
Column(
ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.SpaceBetween,
- crossAxisAlignment = CrossAxisAlignment.Center
+ mainAxisAlignment = MainAxisAlignment.SpaceBetween
) {
DemoText("TopAppBar options")
RadioGroup {
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ButtonActivity.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ButtonActivity.kt
index 43e54c6..5af9694 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ButtonActivity.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/ButtonActivity.kt
@@ -37,7 +37,6 @@
import androidx.compose.unaryPlus
import androidx.ui.layout.Center
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.ExpandedHeight
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.material.Button
@@ -54,11 +53,7 @@
override fun materialContent() {
val onClick: () -> Unit = { Log.e("ButtonDemo", "onClick") }
Center {
- Column(
- ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.SpaceEvenly,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
+ Column(ExpandedHeight, mainAxisAlignment = MainAxisAlignment.SpaceEvenly) {
ContainedButtonSample(onClick)
OutlinedButtonSample(onClick)
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DividersSpacersActivity.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DividersSpacersActivity.kt
index 4ae3b55..37bc67d 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DividersSpacersActivity.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/DividersSpacersActivity.kt
@@ -24,8 +24,8 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.EdgeInsets
+import androidx.ui.layout.Gravity
import androidx.ui.layout.HeightSpacer
import androidx.ui.layout.Row
import androidx.ui.layout.WidthSpacer
@@ -77,15 +77,17 @@
val avatarSize = ItemSize - ItemPadding * 2
val textStyle = (+MaterialTheme.typography()).body1
Container(height = ItemSize, padding = EdgeInsets(ItemPadding)) {
- Row(crossAxisAlignment = CrossAxisAlignment.Center) {
+ Row {
if (color != null) {
ColoredRect(
width = avatarSize,
height = avatarSize,
- color = color)
+ color = color,
+ modifier = Gravity.Center
+ )
WidthSpacer(width = ItemPadding)
}
- Text(text = text, style = textStyle)
+ Text(text = text, style = textStyle, modifier = Gravity.Center)
}
}
}
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/FloatingActionButtonActivity.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/FloatingActionButtonActivity.kt
index b294606..bb85e5b 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/FloatingActionButtonActivity.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/FloatingActionButtonActivity.kt
@@ -21,8 +21,8 @@
import androidx.ui.graphics.imageFromResource
import androidx.ui.layout.Center
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.ExpandedHeight
+import androidx.ui.layout.Gravity
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.material.FloatingActionButton
@@ -33,14 +33,18 @@
val icon = imageFromResource(resources, R.drawable.ic_favorite)
Center {
val onClick: () -> Unit = { Log.e("FABDemo", "onClick") }
- Column(
- ExpandedHeight,
- mainAxisAlignment = MainAxisAlignment.SpaceEvenly,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
- FloatingActionButton(icon = icon, >
- FloatingActionButton(text = "EXTENDED", >
- FloatingActionButton(icon = icon, text = "ADD TO FAVS", >
+ Column(ExpandedHeight, mainAxisAlignment = MainAxisAlignment.SpaceEvenly) {
+ FloatingActionButton(icon = icon, modifier = Gravity.Center)
+ FloatingActionButton(
+ text = "EXTENDED",
+ >
+ modifier = Gravity.Center
+ )
+ FloatingActionButton(
+ icon = icon, text = "ADD TO FAVS",
+ >
+ modifier = Gravity.Center
+ )
}
}
}
diff --git a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/SelectionControlsActivity.kt b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/SelectionControlsActivity.kt
index d4d3b78..5fd2c06 100644
--- a/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/SelectionControlsActivity.kt
+++ b/ui/ui-material/integration-tests/material-demos/src/main/java/androidx/ui/material/demos/SelectionControlsActivity.kt
@@ -22,7 +22,6 @@
import androidx.ui.core.dp
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.EdgeInsets
import androidx.ui.layout.Padding
import androidx.ui.material.MaterialTheme
@@ -42,7 +41,7 @@
Surface(color = Color.White) {
Padding(padding = padding) {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
Text(text = "Checkbox", style = headerStyle)
Padding(padding = padding) {
TriStateCheckboxSample()
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyAlertDialog.kt b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyAlertDialog.kt
index 3ee7de7..cb1c976 100644
--- a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyAlertDialog.kt
+++ b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyAlertDialog.kt
@@ -22,8 +22,8 @@
import androidx.ui.core.dp
import androidx.ui.foundation.shape.RectangleShape
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.EdgeInsets
+import androidx.ui.layout.ExpandedWidth
import androidx.ui.layout.Spacing
import androidx.ui.material.AlertDialog
import androidx.ui.material.Button
@@ -43,12 +43,17 @@
text = { Text(bodyText) },
buttons = {
val style = TextButtonStyle(RectangleShape).copy(paddings = EdgeInsets(16.dp))
- Column(crossAxisAlignment = CrossAxisAlignment.Stretch) {
+ Column {
Divider(
Spacing(left = 12.dp, right = 12.dp),
color = (+MaterialTheme.colors()).onSurface.copy(alpha = 0.2f)
)
- Button(text = buttonText, style = style)
+ Button(
+ text = buttonText,
+ >
+ style = style,
+ modifier = ExpandedWidth
+ )
}
}
)
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyCards.kt b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyCards.kt
index 163762b..93ecb03 100644
--- a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyCards.kt
+++ b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/rally/RallyCards.kt
@@ -28,10 +28,10 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.ExpandedWidth
import androidx.ui.layout.FixedSpacer
import androidx.ui.layout.FlexRow
+import androidx.ui.layout.Gravity
import androidx.ui.layout.HeightSpacer
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.layout.Row
@@ -159,9 +159,17 @@
Container(height = 300.dp, expanded = true) {
DrawAnimatedCircle(accountsProportion, colors)
}
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
- Text(text = "Total", style = (+MaterialTheme.typography()).body1)
- Text(text = "$12,132.49", style = (+MaterialTheme.typography()).h3)
+ Column {
+ Text(
+ text = "Total",
+ style = (+MaterialTheme.typography()).body1,
+ modifier = Gravity.Center
+ )
+ Text(
+ text = "$12,132.49",
+ style = (+MaterialTheme.typography()).h3,
+ modifier = Gravity.Center
+ )
}
}
}
@@ -210,7 +218,7 @@
inflexible {
AccountIndicator(color = color)
WidthSpacer(width = 8.dp)
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
Text(text = name, style = (+MaterialTheme.typography()).body1)
Text(text = "•••••$number", style = (+MaterialTheme.typography()).subtitle1)
}
@@ -289,9 +297,17 @@
Container(height = 300.dp, expanded = true) {
DrawAnimatedCircle(accountsProportion, colors)
}
- Column(crossAxisAlignment = CrossAxisAlignment.Center) {
- Text(text = "Due", style = (+MaterialTheme.typography()).body1)
- Text(text = "$1,810.00", style = (+MaterialTheme.typography()).h3)
+ Column {
+ Text(
+ text = "Due",
+ style = (+MaterialTheme.typography()).body1,
+ modifier = Gravity.Center
+ )
+ Text(
+ text = "$1,810.00",
+ style = (+MaterialTheme.typography()).h3,
+ modifier = Gravity.Center
+ )
}
}
}
diff --git a/ui/ui-material/integration-tests/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt b/ui/ui-material/integration-tests/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt
index 9fc9fc9..ef10226 100644
--- a/ui/ui-material/integration-tests/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt
+++ b/ui/ui-material/integration-tests/samples/src/main/java/androidx/ui/material/samples/TabSamples.kt
@@ -40,7 +40,6 @@
import androidx.ui.layout.Center
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.EdgeInsets
import androidx.ui.layout.FlexColumn
import androidx.ui.layout.Padding
@@ -48,6 +47,7 @@
import androidx.ui.material.TabRow
import androidx.ui.graphics.Image
import androidx.ui.layout.ExpandedHeight
+import androidx.ui.layout.Gravity
import androidx.ui.material.MaterialTheme
@Sampled
@@ -289,14 +289,15 @@
fun FancyTab(title: String, onClick: () -> Unit, selected: Boolean) {
MutuallyExclusiveSetItem(selected = selected, {
Container(height = 50.dp, padding = EdgeInsets(10.dp)) {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
+ Column(ExpandedHeight) {
val color = if (selected) Color.Red else Color.Gray
- ColoredRect(height = 10.dp, width = 10.dp, color = color)
+ ColoredRect(height = 10.dp, width = 10.dp, color = color, modifier = Gravity.Center)
Padding(5.dp) {
- Text(text = title, style = (+MaterialTheme.typography()).body1)
+ Text(
+ text = title,
+ style = (+MaterialTheme.typography()).body1,
+ modifier = Gravity.Center
+ )
}
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt b/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
index f84da65..4959f59 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
@@ -25,7 +25,6 @@
import androidx.ui.foundation.shape.corner.RoundedCornerShape
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.EdgeInsets
import androidx.ui.layout.ExpandedWidth
import androidx.ui.layout.HeightSpacer
@@ -118,7 +117,7 @@
MaterialTheme(colors = currentColors, typography = currentTypography) {
Surface(shape = AlertDialogShape) {
Container(width = AlertDialogWidth) {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
if (title != null) {
Container(
alignment = Alignment.CenterLeft,
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt b/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
index c1b33c1..76f5268 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/DataTable.kt
@@ -38,9 +38,9 @@
import androidx.ui.graphics.Image
import androidx.ui.layout.Column
import androidx.ui.layout.Container
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.EdgeInsets
import androidx.ui.layout.Expanded
+import androidx.ui.layout.Gravity
import androidx.ui.layout.MainAxisAlignment
import androidx.ui.layout.Row
import androidx.ui.layout.Table
@@ -483,48 +483,49 @@
Column {
table()
Container(height = dataRowHeight, padding = cellSpacing) {
- Row(
- Expanded,
- mainAxisAlignment = MainAxisAlignment.End,
- crossAxisAlignment = CrossAxisAlignment.Center
- ) {
+ Row(Expanded, mainAxisAlignment = MainAxisAlignment.End) {
val pages = (rows.size - 1) / pagination.rowsPerPage + 1
val startRow = pagination.rowsPerPage * pagination.page
val endRow = (startRow + pagination.rowsPerPage).coerceAtMost(rows.size)
+ val modifier = Gravity.Center
// TODO(calintat): Replace this with a dropdown menu whose items are taken
// from availableRowsPerPage (filtered to those that are in the range
// 0 until rows.size). When an item is selected, it should invoke
// onRowsPerPageChange with the appropriate value.
- Text(text = "Rows per page: ${pagination.rowsPerPage}")
+ Text(text = "Rows per page: ${pagination.rowsPerPage}", modifier = modifier)
WidthSpacer(width = 32.dp)
- Text(text = "${startRow + 1}-$endRow of ${rows.size}")
+ Text(text = "${startRow + 1}-$endRow of ${rows.size}", modifier = modifier)
WidthSpacer(width = 32.dp)
// TODO(calintat): Replace this with an image button with chevron_left icon.
- Ripple(bounded = false) {
- Clickable(>
- val newPage = pagination.page - 1
- if (newPage >= 0)
- pagination.onPageChange.invoke(newPage)
- }) {
- Text(text = "Prev")
+ Container(modifier = modifier) {
+ Ripple(bounded = false) {
+ Clickable(>
+ val newPage = pagination.page - 1
+ if (newPage >= 0)
+ pagination.onPageChange.invoke(newPage)
+ }) {
+ Text(text = "Prev")
+ }
}
}
WidthSpacer(width = 24.dp)
// TODO(calintat): Replace this with an image button with chevron_right icon.
- Ripple(bounded = false) {
- Clickable(>
- val newPage = pagination.page + 1
- if (newPage < pages)
- pagination.onPageChange.invoke(newPage)
- }) {
- Text(text = "Next")
+ Container(modifier = modifier) {
+ Ripple(bounded = false) {
+ Clickable(>
+ val newPage = pagination.page + 1
+ if (newPage < pages)
+ pagination.onPageChange.invoke(newPage)
+ }) {
+ Text(text = "Next")
+ }
}
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt b/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
index 8a84047..b049f8d 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/ListItem.kt
@@ -260,7 +260,7 @@
) {
val minHeight = if (icon == null) MinHeight else MinHeightWithIcon
ConstrainedBox(constraints = DpConstraints(minHeight = minHeight)) {
- FlexRow(crossAxisAlignment = CrossAxisAlignment.Start) {
+ FlexRow {
inflexible {
if (icon != null) {
Container(
@@ -357,7 +357,7 @@
trailing: @Composable() (() -> Unit)?
) {
ConstrainedBox(constraints = DpConstraints(minHeight = MinHeight)) {
- FlexRow(crossAxisAlignment = CrossAxisAlignment.Start) {
+ FlexRow {
inflexible {
if (icon != null) {
Container(
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputField.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputField.kt
index c55e8dc..7d0f2b1 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputField.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputField.kt
@@ -23,7 +23,6 @@
import androidx.ui.input.ImeAction
import androidx.ui.input.KeyboardType
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.foundation.VerticalScroller
import androidx.ui.layout.ExpandedHeight
import androidx.ui.text.TextStyle
@@ -52,10 +51,7 @@
@Composable
fun InputFieldDemo() {
VerticalScroller {
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(ExpandedHeight) {
TagLine(tag = "simple editing")
EditLine()
TagLine(tag = "simple editing2")
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldFocusTransition.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldFocusTransition.kt
index 8e3ef59..0cf4ff6 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldFocusTransition.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldFocusTransition.kt
@@ -24,7 +24,6 @@
import androidx.ui.core.TextField
import androidx.ui.core.sp
import androidx.ui.foundation.VerticalScroller
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.graphics.Color
import androidx.ui.input.ImeAction
import androidx.ui.layout.Column
@@ -33,7 +32,7 @@
@Composable
fun TextFieldFocusTransition() {
VerticalScroller {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
TextFieldWithFocusId("Focus 1", "Focus 2")
TextFieldWithFocusId("Focus 2", "Focus 3")
TextFieldWithFocusId("Focus 3", "Focus 4")
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldTrickyUseCase.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldTrickyUseCase.kt
index f33a865..eef0d12 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldTrickyUseCase.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeInputFieldTrickyUseCase.kt
@@ -22,7 +22,6 @@
import androidx.ui.core.TextField
import androidx.ui.core.sp
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.foundation.VerticalScroller
import androidx.ui.input.KeyboardType
import androidx.ui.text.TextStyle
@@ -30,7 +29,7 @@
@Composable
fun InputFieldTrickyUseCase() {
VerticalScroller {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
TagLine(tag = "don't set if non number is added")
RejectNonDigits()
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeMultiParagraph.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeMultiParagraph.kt
index 124c2ef..41d4b7f 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeMultiParagraph.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeMultiParagraph.kt
@@ -21,7 +21,6 @@
import androidx.ui.core.sp
import androidx.ui.foundation.VerticalScroller
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.text.AnnotatedString
import androidx.ui.text.ParagraphStyle
import androidx.ui.text.TextStyle
@@ -35,7 +34,7 @@
@Composable
fun MultiParagraphDemo() {
VerticalScroller {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
TagLine(tag = "multiple paragraphs basic")
TextDemoParagraph()
TagLine(tag = "multiple paragraphs TextAlign")
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeText.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeText.kt
index d4eefde..404c846 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeText.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeText.kt
@@ -28,7 +28,6 @@
import androidx.ui.graphics.Color
import androidx.ui.graphics.lerp
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.Row
import androidx.ui.foundation.VerticalScroller
import androidx.ui.text.ParagraphStyle
@@ -65,7 +64,7 @@
@Composable
fun TextDemo() {
VerticalScroller {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
TagLine(tag = "color, fontSize, fontWeight and fontStyle")
TextDemoBasic()
TagLine(tag = "color, fontSize, fontWeight, fontFamily, fontStyle, letterSpacing, " +
@@ -369,10 +368,7 @@
for (i in 1..10) {
text = "$text$displayText "
}
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(ExpandedHeight) {
SecondTagLine(tag = "textAlign = TextAlign.Left")
Text(paragraphStyle = ParagraphStyle(textAlign = TextAlign.Left)) {
Span(text = displayText, style = TextStyle(fontSize = fontSize8))
@@ -441,10 +437,7 @@
val textStyle =
TextStyle(fontSize = fontSize8, color = Color(0xFFFF0000))
- Column(
- ExpandedHeight,
- crossAxisAlignment = CrossAxisAlignment.Start
- ) {
+ Column(ExpandedHeight) {
Text {
Span(text = text, style = textStyle)
}
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelection.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelection.kt
index 4c815f4..8104626 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelection.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelection.kt
@@ -27,7 +27,6 @@
import androidx.ui.foundation.text.SelectionContainer
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.ExpandedHeight
import androidx.ui.layout.ExpandedWidth
import androidx.ui.layout.Row
@@ -39,7 +38,7 @@
@Composable
fun TextSelectionDemo() {
VerticalScroller {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
TagLine(tag = "selection")
TextDemoSelection()
TagLine(tag = "selection with string input")
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelectionSample.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelectionSample.kt
index 42c5fe7..9400fb1 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelectionSample.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeTextSelectionSample.kt
@@ -33,7 +33,6 @@
import androidx.ui.foundation.text.SelectionContainer
import androidx.ui.graphics.Color
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.layout.FlexRow
import androidx.ui.layout.Padding
import androidx.ui.text.AnnotatedString
@@ -90,7 +89,7 @@
selection.value = it }
) {
Padding(12.dp) {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
Basics()
AddTextElement()
langContent.forEach {
diff --git a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
index 763c5f4..8f7e43a 100644
--- a/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
+++ b/ui/ui-text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/ComposeVariousInputField.kt
@@ -31,7 +31,6 @@
import androidx.ui.input.ImeAction
import androidx.ui.input.KeyboardType
import androidx.ui.layout.Column
-import androidx.ui.layout.CrossAxisAlignment
import androidx.ui.foundation.VerticalScroller
import androidx.ui.text.AnnotatedString
import androidx.ui.text.LocaleList
@@ -173,7 +172,7 @@
@Composable
fun VariousInputFieldDemo() {
VerticalScroller {
- Column(crossAxisAlignment = CrossAxisAlignment.Start) {
+ Column {
TagLine(tag = "Capitalization")
VariousEditLine(
keyboardType = KeyboardType.Ascii,