size -> requiredSize, preferredSize -> size
Relnote: "Size modifiers were renamed. Modifier.width/height/size were renamed to requiredWidth/requiredHeight/requiredSize. Modifier.preferredWidth/preferredHeight/preferredSize were renamed to width/height/size."
Fixes: 177366628
Test: built and ran
Change-Id: I5b4145953d360b1fb851c0056fc9a7875bb34088
diff --git a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/FocusInteropAndroidInCompose.kt b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/FocusInteropAndroidInCompose.kt
index 91c4bd6..1790cdd 100644
--- a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/FocusInteropAndroidInCompose.kt
+++ b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/FocusInteropAndroidInCompose.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.runtime.Composable
@@ -44,7 +44,7 @@
val text = remember { mutableStateOf("") }
TextField(text.value, text.value = it })
}
- Spacer(Modifier.height(20.dp))
+ Spacer(Modifier.requiredHeight(20.dp))
Row(horizontalArrangement = SpaceEvenly, verticalAlignment = CenterVertically) {
AndroidView({
LinearLayout(it).apply {
diff --git a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropAndroidInCompose.kt b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropAndroidInCompose.kt
index 89fa78f..82c0088 100644
--- a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropAndroidInCompose.kt
+++ b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropAndroidInCompose.kt
@@ -29,8 +29,8 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@@ -82,7 +82,7 @@
Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(240.dp)
+ .size(240.dp)
) {
AndroidView({ context ->
LayoutInflater.from(context)
@@ -131,7 +131,7 @@
Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(240.dp)
+ .size(240.dp)
.pointerInput(Unit) {
detectTapGestures(>
}
@@ -252,7 +252,7 @@
modifier = Modifier
.padding(96.dp)
.background(color = androidx.compose.ui.graphics.Color.Red)
- .preferredHeight(750.dp)
+ .height(750.dp)
) {
AndroidView({ context ->
LayoutInflater.from(context)
diff --git a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropComposeInAndroid.kt b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropComposeInAndroid.kt
index d524cc1..35373e5 100644
--- a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropComposeInAndroid.kt
+++ b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/PointerInputInteropComposeInAndroid.kt
@@ -35,9 +35,9 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@@ -200,7 +200,7 @@
Modifier
.background(color = Color.Gray)
.fillMaxWidth()
- .preferredHeight(456.dp)
+ .height(456.dp)
.wrapContentSize()
.clickable {
currentColor.value = if (currentColor.value == Color.Blue) {
@@ -210,7 +210,7 @@
}
}
.background(currentColor.value, RectangleShape)
- .preferredSize(192.dp)
+ .size(192.dp)
)
}
},
@@ -249,7 +249,7 @@
.padding(48.dp)
.background(color = Color.Gray)
.fillMaxWidth()
- .preferredHeight(456.dp)
+ .height(456.dp)
.verticalScroll(rememberScrollState())
) {
Box(
@@ -257,7 +257,7 @@
.padding(48.dp)
.background(color = Color.LightGray)
.fillMaxWidth()
- .preferredHeight(456.dp)
+ .height(456.dp)
)
}
}
@@ -295,14 +295,14 @@
.padding(48.dp)
.background(color = Color.Gray)
.fillMaxWidth()
- .preferredHeight(456.dp)
+ .height(456.dp)
.verticalScroll(rememberScrollState())
) {
Box(
Modifier
.padding(48.dp)
.background(color = Color.LightGray)
- .preferredWidth(360.dp)
+ .width(360.dp)
.fillMaxHeight()
)
}
diff --git a/compose/animation/animation-core/samples/src/main/java/androidx/compose/animation/core/samples/AnimatedValueSamples.kt b/compose/animation/animation-core/samples/src/main/java/androidx/compose/animation/core/samples/AnimatedValueSamples.kt
index 31eeda6..81d4777 100644
--- a/compose/animation/animation-core/samples/src/main/java/androidx/compose/animation/core/samples/AnimatedValueSamples.kt
+++ b/compose/animation/animation-core/samples/src/main/java/androidx/compose/animation/core/samples/AnimatedValueSamples.kt
@@ -27,8 +27,8 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@@ -80,7 +80,7 @@
convertFromVector = { MySize(it.v1.dp, it.v2.dp) }
)
)
- Box(Modifier.preferredSize(animSize.width, animSize.height).background(color = Color.Red))
+ Box(Modifier.size(animSize.width, animSize.height).background(color = Color.Red))
}
}
@@ -91,7 +91,7 @@
fun HeightAnimation(collapsed: Boolean) {
// Animates a height of [Dp] type to different target values based on the [collapsed] flag.
val height: Dp by animateDpAsState(if (collapsed) 10.dp else 20.dp)
- Box(Modifier.fillMaxWidth().height(height).background(color = Color.Red))
+ Box(Modifier.fillMaxWidth().requiredHeight(height).background(color = Color.Red))
}
}
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt
index fb933a0..24e6a0f 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt
@@ -25,9 +25,9 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.sizeIn
+import androidx.compose.foundation.layout.requiredSizeIn
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -53,9 +53,9 @@
.padding(50.dp)
) {
Text()
- Spacer(Modifier.height(20.dp))
+ Spacer(Modifier.requiredHeight(20.dp))
Button()
- Spacer(Modifier.height(20.dp))
+ Spacer(Modifier.requiredHeight(20.dp))
Image()
}
}
@@ -112,7 +112,7 @@
var portraitMode by remember { mutableStateOf(true) }
Box(
Modifier.clickable { portraitMode = !portraitMode }
- .sizeIn(maxWidth = 300.dp, maxHeight = 300.dp)
+ .requiredSizeIn(maxWidth = 300.dp, maxHeight = 300.dp)
.background(if (portraitMode) Color(0xFFfffbd0) else Color(0xFFe3ffd9))
.animateContentSize(tween(500))
.aspectRatio(if (portraitMode) 3 / 4f else 16 / 9f)
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisibilityDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisibilityDemo.kt
index 27cb284..7e4c686 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisibilityDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisibilityDemo.kt
@@ -38,7 +38,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.Button
@@ -127,7 +127,7 @@
@Composable
fun Item(color: Color, text: String = "") {
- Box(Modifier.height(80.dp).fillMaxWidth().background(color)) {
+ Box(Modifier.requiredHeight(80.dp).fillMaxWidth().background(color)) {
Text(
text,
modifier = Modifier.align(Alignment.CenterStart).padding(start = 10.dp)
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisiblilityLazyColumnDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisiblilityLazyColumnDemo.kt
index 85eda9a..96ed035 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisiblilityLazyColumnDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimatedVisiblilityLazyColumnDemo.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
@@ -70,7 +70,7 @@
enter = expandVertically(),
exit = shrinkVertically()
) {
- Spacer(Modifier.fillMaxWidth().height(90.dp).background(color))
+ Spacer(Modifier.fillMaxWidth().requiredHeight(90.dp).background(color))
}
}
}
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/CrossfadeDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/CrossfadeDemo.kt
index 603d293..d2cf405 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/CrossfadeDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/CrossfadeDemo.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -51,7 +51,7 @@
}
}
.weight(1f, true)
- .preferredHeight(48.dp)
+ .height(48.dp)
.background(tab.color)
)
}
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/EnterExitTransitionDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/EnterExitTransitionDemo.kt
index f04c311..643168a 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/EnterExitTransitionDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/EnterExitTransitionDemo.kt
@@ -35,7 +35,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
@@ -247,7 +247,7 @@
Row(
Modifier
.fillMaxWidth()
- .preferredHeight(30.dp)
+ .height(30.dp)
.selectable(
selected = (i == selectedOption),
onOptionSelected(i) }
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/FancyScrollingDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/FancyScrollingDemo.kt
index dddee00..47d9136 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/FancyScrollingDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/FancyScrollingDemo.kt
@@ -28,7 +28,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
@@ -88,7 +88,7 @@
}
)
- Canvas(modifier.fillMaxWidth().preferredHeight(400.dp)) {
+ Canvas(modifier.fillMaxWidth().height(400.dp)) {
val width = size.width / 2f
val scroll = animScroll.value + width / 2
itemWidth.value = width
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/RepeatedRotationDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/RepeatedRotationDemo.kt
index 48f412e..8374f9e 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/RepeatedRotationDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/RepeatedRotationDemo.kt
@@ -27,8 +27,8 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Button
import androidx.compose.material.Text
@@ -56,13 +56,13 @@
) {
Text(text = "Rotate 10 times")
}
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Button(
{ state.value = RotationStates.Original }
) {
Text(text = "Reset")
}
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
val transition = updateTransition(state.value)
val rotation by transition.animateFloat(
transitionSpec = {
@@ -82,7 +82,7 @@
) {
0f
}
- Canvas(Modifier.preferredSize(100.dp)) {
+ Canvas(Modifier.size(100.dp)) {
rotate(rotation, Offset.Zero) {
drawRect(Color(0xFF00FF00))
}
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SpringBackScrollingDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SpringBackScrollingDemo.kt
index 30d9009..7ffd010 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SpringBackScrollingDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SpringBackScrollingDemo.kt
@@ -32,7 +32,7 @@
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -127,7 +127,7 @@
}
}
}
- Canvas(gesture.fillMaxWidth().preferredHeight(400.dp)) {
+ Canvas(gesture.fillMaxWidth().height(400.dp)) {
itemWidth.value = size.width / 2f
if (DEBUG) {
println(
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SwipeToDismissDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SwipeToDismissDemo.kt
index c28d6d2..efa3219 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SwipeToDismissDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SwipeToDismissDemo.kt
@@ -25,10 +25,10 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -56,9 +56,9 @@
fun SwipeToDismissDemo() {
Column {
var index by remember { mutableStateOf(0) }
- Box(Modifier.height(300.dp).fillMaxWidth()) {
+ Box(Modifier.requiredHeight(300.dp).fillMaxWidth()) {
Box(
- Modifier.swipeToDismiss(index).align(Alignment.BottomCenter).size(150.dp)
+ Modifier.swipeToDismiss(index).align(Alignment.BottomCenter).requiredSize(150.dp)
.background(pastelColors[index])
)
}
diff --git a/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimatedVisibilitySamples.kt b/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimatedVisibilitySamples.kt
index c28b367..8ab8fbd 100644
--- a/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimatedVisibilitySamples.kt
+++ b/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimatedVisibilitySamples.kt
@@ -46,7 +46,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
@@ -87,7 +87,7 @@
)
) {
// Content that needs to appear/disappear goes here:
- Box(Modifier.fillMaxWidth().height(200.dp))
+ Box(Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}
@@ -114,7 +114,7 @@
) + fadeOut()
) {
// Content that needs to appear/disappear goes here:
- Box(Modifier.fillMaxWidth().height(200.dp)) {}
+ Box(Modifier.fillMaxWidth().requiredHeight(200.dp)) {}
}
}
@@ -135,7 +135,7 @@
)
) {
// Content that needs to appear/disappear goes here:
- Text("Content to appear/disappear", Modifier.fillMaxWidth().height(200.dp))
+ Text("Content to appear/disappear", Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}
@@ -156,7 +156,7 @@
exit = slideOutVertically() + shrinkVertically() + fadeOut()
) {
// Content that needs to appear/disappear goes here:
- Text("Content to appear/disappear", Modifier.fillMaxWidth().height(200.dp))
+ Text("Content to appear/disappear", Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}
@@ -183,7 +183,7 @@
}
}
}
- Spacer(Modifier.height(20.dp))
+ Spacer(Modifier.requiredHeight(20.dp))
}
@OptIn(ExperimentalAnimationApi::class)
@@ -209,7 +209,7 @@
)
) {
// Content that needs to appear/disappear goes here:
- Text("Content to appear/disappear", Modifier.fillMaxWidth().height(200.dp))
+ Text("Content to appear/disappear", Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}
@@ -234,7 +234,7 @@
)
) {
// Content that needs to appear/disappear goes here:
- Text("Content to appear/disappear", Modifier.fillMaxWidth().height(200.dp))
+ Text("Content to appear/disappear", Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}
@@ -266,7 +266,7 @@
)
) {
// Content that needs to appear/disappear goes here:
- Text("Content to appear/disappear", Modifier.fillMaxWidth().height(200.dp))
+ Text("Content to appear/disappear", Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}
@@ -285,7 +285,7 @@
// By default ColumnScope.AnimatedVisibility expands and shrinks new content while
// fading.
AnimatedVisibility(i <= itemIndex) {
- Box(Modifier.height(40.dp).fillMaxWidth().background(color))
+ Box(Modifier.requiredHeight(40.dp).fillMaxWidth().background(color))
}
}
}
diff --git a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt
index a069b0e..d758980 100644
--- a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt
+++ b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -80,7 +80,7 @@
Box(
Modifier.onGloballyPositioned {
offset = it.localToRoot(Offset.Zero)
- }.size(100.dp, 100.dp)
+ }.requiredSize(100.dp, 100.dp)
) {
DisposableEffect(Unit) {
onDispose {
@@ -190,7 +190,7 @@
Box(
Modifier.onGloballyPositioned {
offset = it.localToRoot(Offset.Zero)
- }.size(100.dp, 100.dp)
+ }.requiredSize(100.dp, 100.dp)
) {
DisposableEffect(Unit) {
onDispose {
diff --git a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt
index 997558f..6f5b9b1 100644
--- a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt
+++ b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -98,7 +98,7 @@
animationStartSize = startSize
animationEndSize = endSize
}
- .size(width.dp, height.dp)
+ .requiredSize(width.dp, height.dp)
)
density = LocalDensity.current.density
}
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/example1/Main.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/example1/Main.kt
index 2db6b25..cf18564 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/example1/Main.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/example1/Main.kt
@@ -35,7 +35,6 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
@@ -179,7 +178,7 @@
color = Color.Black,
modifier = Modifier
.background(Color.Blue)
- .preferredHeight(56.dp)
+ .height(56.dp)
.wrapContentSize(Alignment.Center)
)
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.kt
index b22d848..6371a56 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/AppContent.kt
@@ -28,8 +28,7 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.AlertDialog
@@ -91,7 +90,7 @@
Row(
modifier = Modifier.background(color = Color(75, 75, 75))
.fillMaxWidth()
- .preferredHeight(30.dp)
+ .height(30.dp)
.padding(start = 20.dp, end = 10.dp),
verticalAlignment = Alignment.CenterVertically
) {
@@ -236,7 +235,7 @@
Box(
modifier = Modifier.background(color = Color(32, 32, 32))
.fillMaxWidth()
- .preferredHeight(30.dp)
+ .height(30.dp)
) {
Row(modifier = Modifier.padding(start = 20.dp)) {
TextBox(
@@ -331,7 +330,7 @@
@Composable
fun PopupContent(onDismiss: () -> Unit) {
Box(
- Modifier.preferredSize(300.dp, 150.dp).background(color = Color(65, 65, 65)),
+ Modifier.size(300.dp, 150.dp).background(color = Color(65, 65, 65)),
contentAlignment = Alignment.Center
) {
Column {
@@ -378,7 +377,7 @@
color
),
modifier = Modifier
- .preferredSize(size.width.dp, size.height.dp)
+ .size(size.width.dp, size.height.dp)
.hover(
>
buttonHover.value = true
@@ -503,7 +502,7 @@
fun SwingActionButton(text: String, action: (() -> Unit)? = null) {
SwingPanel(
background = Color(55, 55, 55),
- modifier = Modifier.preferredSize(200.dp, 35.dp),
+ modifier = Modifier.size(200.dp, 35.dp),
componentBlock = {
JButton(text).apply {
addActionListener(object : ActionListener {
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/swingexample/Main.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/swingexample/Main.kt
index ed20b55..1fc46d1 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/swingexample/Main.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/swingexample/Main.kt
@@ -29,7 +29,6 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -167,7 +166,7 @@
}
Spacer(modifier = Modifier.width(20.dp))
SwingPanel(
- modifier = Modifier.preferredSize(200.dp, 39.dp),
+ modifier = Modifier.size(200.dp, 39.dp),
componentBlock = {
actionButton(
text = "JComponent",
@@ -183,7 +182,7 @@
Spacer(modifier = Modifier.width(20.dp))
SwingPanel(
background = background,
- modifier = Modifier.preferredSize(200.dp, 39.dp),
+ modifier = Modifier.size(200.dp, 39.dp),
componentBlock = { ComposableColoredPanel(Color.Red) }
)
}
diff --git a/compose/desktop/desktop/src/jvmTest/kotlin/androidx/compose/desktop/ParagraphTest.kt b/compose/desktop/desktop/src/jvmTest/kotlin/androidx/compose/desktop/ParagraphTest.kt
index c46473e..bbc2233 100644
--- a/compose/desktop/desktop/src/jvmTest/kotlin/androidx/compose/desktop/ParagraphTest.kt
+++ b/compose/desktop/desktop/src/jvmTest/kotlin/androidx/compose/desktop/ParagraphTest.kt
@@ -20,8 +20,8 @@
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.ProvideTextStyle
import androidx.compose.material.Text
@@ -87,7 +87,7 @@
color = Color.Black,
modifier = Modifier
.background(Color.Blue)
- .preferredHeight(56.dp)
+ .height(56.dp)
.wrapContentSize(Alignment.Center)
)
diff --git a/compose/foundation/foundation-layout/api/current.txt b/compose/foundation/foundation-layout/api/current.txt
index f461d4e..805adfa 100644
--- a/compose/foundation/foundation-layout/api/current.txt
+++ b/compose/foundation/foundation-layout/api/current.txt
@@ -123,8 +123,8 @@
}
public final class IntrinsicKt {
- method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeight(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
- method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidth(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
+ method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier height(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
+ method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier width(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
}
public enum IntrinsicSize {
@@ -195,13 +195,13 @@
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier fillMaxWidth(androidx.compose.ui.Modifier, optional float fraction);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier height-wxomhCo(androidx.compose.ui.Modifier, float height);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier heightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeight-wxomhCo(androidx.compose.ui.Modifier, float height);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSize-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSize-wxomhCo(androidx.compose.ui.Modifier, float size);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidth-wxomhCo(androidx.compose.ui.Modifier, float width);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidthIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredHeight-wxomhCo(androidx.compose.ui.Modifier, float height);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredHeightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSize-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSize-wxomhCo(androidx.compose.ui.Modifier, float size);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredWidth-wxomhCo(androidx.compose.ui.Modifier, float width);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredWidthIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier size-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier size-wxomhCo(androidx.compose.ui.Modifier, float size);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier sizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
diff --git a/compose/foundation/foundation-layout/api/public_plus_experimental_current.txt b/compose/foundation/foundation-layout/api/public_plus_experimental_current.txt
index f461d4e..805adfa 100644
--- a/compose/foundation/foundation-layout/api/public_plus_experimental_current.txt
+++ b/compose/foundation/foundation-layout/api/public_plus_experimental_current.txt
@@ -123,8 +123,8 @@
}
public final class IntrinsicKt {
- method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeight(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
- method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidth(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
+ method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier height(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
+ method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier width(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
}
public enum IntrinsicSize {
@@ -195,13 +195,13 @@
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier fillMaxWidth(androidx.compose.ui.Modifier, optional float fraction);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier height-wxomhCo(androidx.compose.ui.Modifier, float height);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier heightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeight-wxomhCo(androidx.compose.ui.Modifier, float height);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSize-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSize-wxomhCo(androidx.compose.ui.Modifier, float size);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidth-wxomhCo(androidx.compose.ui.Modifier, float width);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidthIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredHeight-wxomhCo(androidx.compose.ui.Modifier, float height);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredHeightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSize-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSize-wxomhCo(androidx.compose.ui.Modifier, float size);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredWidth-wxomhCo(androidx.compose.ui.Modifier, float width);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredWidthIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier size-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier size-wxomhCo(androidx.compose.ui.Modifier, float size);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier sizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
diff --git a/compose/foundation/foundation-layout/api/restricted_current.txt b/compose/foundation/foundation-layout/api/restricted_current.txt
index 8f54c3b..f1b5266 100644
--- a/compose/foundation/foundation-layout/api/restricted_current.txt
+++ b/compose/foundation/foundation-layout/api/restricted_current.txt
@@ -126,8 +126,8 @@
}
public final class IntrinsicKt {
- method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeight(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
- method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidth(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
+ method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier height(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
+ method @androidx.compose.foundation.layout.ExperimentalLayout @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier width(androidx.compose.ui.Modifier, androidx.compose.foundation.layout.IntrinsicSize intrinsicSize);
}
public enum IntrinsicSize {
@@ -200,13 +200,13 @@
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier fillMaxWidth(androidx.compose.ui.Modifier, optional float fraction);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier height-wxomhCo(androidx.compose.ui.Modifier, float height);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier heightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeight-wxomhCo(androidx.compose.ui.Modifier, float height);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredHeightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSize-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSize-wxomhCo(androidx.compose.ui.Modifier, float size);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredSizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidth-wxomhCo(androidx.compose.ui.Modifier, float width);
- method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier preferredWidthIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredHeight-wxomhCo(androidx.compose.ui.Modifier, float height);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredHeightIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSize-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSize-wxomhCo(androidx.compose.ui.Modifier, float size);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredSizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredWidth-wxomhCo(androidx.compose.ui.Modifier, float width);
+ method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier requiredWidthIn-S2lCeAQ(androidx.compose.ui.Modifier, optional float min, optional float max);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier size-S2lCeAQ(androidx.compose.ui.Modifier, float width, float height);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier size-wxomhCo(androidx.compose.ui.Modifier, float size);
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier sizeIn-w2-DAAU(androidx.compose.ui.Modifier, optional float minWidth, optional float minHeight, optional float maxWidth, optional float maxHeight);
diff --git a/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt b/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt
index 5c70ba6..3cdefdd 100644
--- a/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt
+++ b/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
@@ -88,7 +88,7 @@
}
}
-private val boxSize = Modifier.preferredSize(50.dp, 20.dp)
+private val boxSize = Modifier.size(50.dp, 20.dp)
@Composable
private fun TestRow() {
@@ -184,7 +184,7 @@
} else {
Color.Magenta
}
- Box(Modifier.preferredSize(w, 20.dp).background(color)) {
+ Box(Modifier.size(w, 20.dp).background(color)) {
Text(text, Modifier.align(Alignment.Center))
}
}
diff --git a/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/SimpleLayoutDemo.kt b/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/SimpleLayoutDemo.kt
index 31d5e1a..e285ad6 100644
--- a/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/SimpleLayoutDemo.kt
+++ b/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/SimpleLayoutDemo.kt
@@ -24,9 +24,9 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -41,72 +41,72 @@
Column {
Text(text = "Row", fontSize = 48.sp)
- Box(Modifier.preferredWidth(ExampleSize).background(color = lightGrey)) {
+ Box(Modifier.width(ExampleSize).background(color = lightGrey)) {
Row(Modifier.fillMaxWidth()) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredHeight(24.dp))
- Box(Modifier.preferredWidth(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.height(24.dp))
+ Box(Modifier.width(ExampleSize).background(color = lightGrey)) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredHeight(24.dp))
- Box(Modifier.preferredWidth(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.height(24.dp))
+ Box(Modifier.width(ExampleSize).background(color = lightGrey)) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredHeight(24.dp))
- Box(Modifier.preferredWidth(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.height(24.dp))
+ Box(Modifier.width(ExampleSize).background(color = lightGrey)) {
Row(Modifier.fillMaxWidth()) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredHeight(24.dp))
- Box(Modifier.preferredWidth(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.height(24.dp))
+ Box(Modifier.width(ExampleSize).background(color = lightGrey)) {
Row(Modifier.fillMaxWidth()) {
PurpleSquare(Modifier.align(Alignment.Bottom))
CyanSquare(Modifier.align(Alignment.Bottom))
}
}
- Spacer(Modifier.preferredHeight(24.dp))
+ Spacer(Modifier.height(24.dp))
Text(text = "Column", fontSize = 48.sp)
Row(Modifier.fillMaxWidth()) {
- Box(Modifier.preferredHeight(ExampleSize).background(color = lightGrey)) {
+ Box(Modifier.height(ExampleSize).background(color = lightGrey)) {
Column(Modifier.fillMaxHeight()) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredWidth(24.dp))
- Box(Modifier.preferredHeight(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.width(24.dp))
+ Box(Modifier.height(ExampleSize).background(color = lightGrey)) {
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.Center) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredWidth(24.dp))
- Box(Modifier.preferredHeight(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.width(24.dp))
+ Box(Modifier.height(ExampleSize).background(color = lightGrey)) {
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.Bottom) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredWidth(24.dp))
- Box(Modifier.preferredHeight(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.width(24.dp))
+ Box(Modifier.height(ExampleSize).background(color = lightGrey)) {
Column(Modifier.fillMaxHeight()) {
PurpleSquare()
CyanSquare()
}
}
- Spacer(Modifier.preferredWidth(24.dp))
- Box(Modifier.preferredHeight(ExampleSize).background(color = lightGrey)) {
+ Spacer(Modifier.width(24.dp))
+ Box(Modifier.height(ExampleSize).background(color = lightGrey)) {
Column(Modifier.fillMaxHeight()) {
PurpleSquare(Modifier.align(Alignment.End))
CyanSquare(Modifier.align(Alignment.End))
@@ -118,12 +118,12 @@
@Composable
private fun PurpleSquare(modifier: Modifier = Modifier) {
- Box(modifier.preferredSize(48.dp).background(Color(0xFF6200EE)))
+ Box(modifier.size(48.dp).background(Color(0xFF6200EE)))
}
@Composable
private fun CyanSquare(modifier: Modifier = Modifier) {
- Box(modifier.preferredSize(24.dp).background(Color(0xFF03DAC6)))
+ Box(modifier.size(24.dp).background(Color(0xFF03DAC6)))
}
private val ExampleSize = 140.dp
\ No newline at end of file
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/AspectRatioSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/AspectRatioSample.kt
index 4e39fa5..9063cd8 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/AspectRatioSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/AspectRatioSample.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.aspectRatio
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -29,5 +29,5 @@
@Sampled
@Composable
fun SimpleAspectRatio() {
- Box(Modifier.preferredWidth(100.dp).aspectRatio(2f).background(Color.Green))
+ Box(Modifier.width(100.dp).aspectRatio(2f).background(Color.Green))
}
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxSample.kt
index e2bd1ba..03f6a9f 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxSample.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -45,17 +45,17 @@
)
Box(
Modifier.align(Alignment.Center)
- .preferredSize(300.dp, 300.dp)
+ .size(300.dp, 300.dp)
.background(Color.Green)
)
Box(
Modifier.align(Alignment.TopStart)
- .preferredSize(150.dp, 150.dp)
+ .size(150.dp, 150.dp)
.background(Color.Red)
)
Box(
Modifier.align(Alignment.BottomEnd)
- .preferredSize(150.dp, 150.dp)
+ .size(150.dp, 150.dp)
.background(Color.Blue)
)
}
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxWithConstraintsSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxWithConstraintsSample.kt
index 71e5f26..8c17d20 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxWithConstraintsSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/BoxWithConstraintsSample.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -33,11 +33,11 @@
BoxWithConstraints {
val rectangleHeight = 100.dp
if (maxHeight < rectangleHeight * 2) {
- Box(Modifier.preferredSize(50.dp, rectangleHeight).background(Color.Blue))
+ Box(Modifier.size(50.dp, rectangleHeight).background(Color.Blue))
} else {
Column {
- Box(Modifier.preferredSize(50.dp, rectangleHeight).background(Color.Blue))
- Box(Modifier.preferredSize(50.dp, rectangleHeight).background(Color.Gray))
+ Box(Modifier.size(50.dp, rectangleHeight).background(Color.Blue))
+ Box(Modifier.size(50.dp, rectangleHeight).background(Color.Gray))
}
}
}
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/ColumnSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/ColumnSample.kt
index ec4ede2..f2b28bf 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/ColumnSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/ColumnSample.kt
@@ -21,8 +21,8 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.layout.Layout
@@ -39,13 +39,13 @@
fun SimpleColumn() {
Column {
// The child with no weight will have the specified size.
- Box(Modifier.preferredSize(40.dp, 80.dp).background(Color.Magenta))
+ Box(Modifier.size(40.dp, 80.dp).background(Color.Magenta))
// Has weight, the child will occupy half of the remaining height.
- Box(Modifier.preferredWidth(40.dp).weight(1f).background(Color.Yellow))
+ Box(Modifier.width(40.dp).weight(1f).background(Color.Yellow))
// Has weight and does not fill, the child will occupy at most half of the remaining height.
// Therefore it will occupy 80.dp (its preferred height) if the assigned height is larger.
Box(
- Modifier.preferredSize(40.dp, 80.dp)
+ Modifier.size(40.dp, 80.dp)
.weight(1f, fill = false)
.background(Color.Green)
)
@@ -59,25 +59,25 @@
// The child with no align modifier is positioned by default so that its start edge
// aligned with the start edge of the horizontal axis.
- Box(Modifier.preferredSize(80.dp, 40.dp).background(Color.Magenta))
+ Box(Modifier.size(80.dp, 40.dp).background(Color.Magenta))
// Alignment.Start, the child will be positioned so that its start edge is aligned with
// the start edge of the horizontal axis.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.align(Alignment.Start)
.background(Color.Red)
)
// Alignment.Center, the child will be positioned so that its center is in the middle of
// the horizontal axis.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.align(Alignment.CenterHorizontally)
.background(Color.Yellow)
)
// Alignment.End, the child will be positioned so that its end edge aligned to the end of
// the horizontal axis.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.align(Alignment.End)
.background(Color.Green)
)
@@ -91,17 +91,17 @@
// Center of the first rectangle is aligned to the right edge of the second rectangle and
// left edge of the third one.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.alignBy { it.width / 2 }
.background(Color.Blue)
)
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.alignBy { it.width }
.background(Color.Magenta)
)
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.alignBy { 0 }
.background(Color.Red)
)
@@ -138,7 +138,7 @@
// Center of the first rectangle is aligned to the right edge of the second rectangle and
// left edge of the third one.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.alignBy { it.width / 2 }
.background(Color.Blue)
)
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/IntrinsicSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/IntrinsicSample.kt
index d87425c..8fdf412 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/IntrinsicSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/IntrinsicSample.kt
@@ -26,9 +26,9 @@
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@@ -41,26 +41,26 @@
fun SameWidthBoxes() {
// Builds a layout containing three Box having the same width as the widest one.
//
- // Here preferredWidth min intrinsic is adding a width premeasurement pass for the
+ // Here width min intrinsic is adding a width premeasurement pass for the
// Column, whose minimum intrinsic width will correspond to the preferred width of the largest
- // Box. Then preferredWidth min intrinsic will measure the Column with tight width, the
+ // Box. Then width min intrinsic will measure the Column with tight width, the
// same as the premeasured minimum intrinsic width, which due to fillMaxWidth will force
// the Box's to use the same width.
Box {
- Column(Modifier.preferredWidth(IntrinsicSize.Min).fillMaxHeight()) {
+ Column(Modifier.width(IntrinsicSize.Min).fillMaxHeight()) {
Box(
modifier = Modifier.fillMaxWidth()
- .preferredSize(20.dp, 10.dp)
+ .size(20.dp, 10.dp)
.background(Color.Gray)
)
Box(
modifier = Modifier.fillMaxWidth()
- .preferredSize(30.dp, 10.dp)
+ .size(30.dp, 10.dp)
.background(Color.Blue)
)
Box(
modifier = Modifier.fillMaxWidth()
- .preferredSize(10.dp, 10.dp)
+ .size(10.dp, 10.dp)
.background(Color.Magenta)
)
}
@@ -74,18 +74,18 @@
// Builds a layout containing two pieces of text separated by a divider, where the divider
// is sized according to the height of the longest text.
//
- // Here preferredHeight min intrinsic is adding a height premeasurement pass for the Row,
+ // Here height min intrinsic is adding a height premeasurement pass for the Row,
// whose minimum intrinsic height will correspond to the height of the largest Text. Then
- // preferredHeight min intrinsic will measure the Row with tight height, the same as the
+ // height min intrinsic will measure the Row with tight height, the same as the
// premeasured minimum intrinsic height, which due to fillMaxHeight will force the Texts and
// the divider to use the same height.
Box {
- Row(Modifier.preferredHeight(IntrinsicSize.Min)) {
+ Row(Modifier.height(IntrinsicSize.Min)) {
Text(
text = "This is a really short text",
modifier = Modifier.weight(1f).fillMaxHeight()
)
- Box(Modifier.preferredWidth(1.dp).fillMaxHeight().background(Color.Black))
+ Box(Modifier.width(1.dp).fillMaxHeight().background(Color.Black))
Text(
text = "This is a much much much much much much much much much much" +
" much much much much much much longer text",
@@ -101,14 +101,14 @@
fun SameWidthTextBoxes() {
// Builds a layout containing three Text boxes having the same width as the widest one.
//
- // Here preferredWidth max intrinsic is adding a width premeasurement pass for the Column,
+ // Here width max intrinsic is adding a width premeasurement pass for the Column,
// whose maximum intrinsic width will correspond to the preferred width of the largest
- // Box. Then preferredWidth max intrinsic will measure the Column with tight width, the
+ // Box. Then width max intrinsic will measure the Column with tight width, the
// same as the premeasured maximum intrinsic width, which due to fillMaxWidth modifiers will
// force the Boxs to use the same width.
Box {
- Column(Modifier.preferredWidth(IntrinsicSize.Max).fillMaxHeight()) {
+ Column(Modifier.width(IntrinsicSize.Max).fillMaxHeight()) {
Box(Modifier.fillMaxWidth().background(Color.Gray)) {
Text("Short text")
}
@@ -129,17 +129,17 @@
// Builds a layout containing two aspectRatios separated by a divider, where the divider
// is sized according to the height of the taller aspectRatio.
//
- // Here preferredHeight max intrinsic is adding a height premeasurement pass for the
+ // Here height max intrinsic is adding a height premeasurement pass for the
// Row, whose maximum intrinsic height will correspond to the height of the taller
- // aspectRatio. Then preferredHeight max intrinsic will measure the Row with tight height,
+ // aspectRatio. Then height max intrinsic will measure the Row with tight height,
// the same as the premeasured maximum intrinsic height, which due to fillMaxHeight modifier
// will force the aspectRatios and the divider to use the same height.
//
Box {
- Row(Modifier.preferredHeight(IntrinsicSize.Max)) {
+ Row(Modifier.height(IntrinsicSize.Max)) {
val modifier = Modifier.fillMaxHeight().weight(1f)
Box(modifier.aspectRatio(2f).background(Color.Gray))
- Box(Modifier.preferredWidth(1.dp).fillMaxHeight().background(Color.Black))
+ Box(Modifier.width(1.dp).fillMaxHeight().background(Color.Black))
Box(modifier.aspectRatio(1f).background(Color.Blue))
}
}
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/LayoutPaddingSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/LayoutPaddingSample.kt
index 68a3299..b34d40f 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/LayoutPaddingSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/LayoutPaddingSample.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.absolutePadding
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -34,7 +34,7 @@
Box(Modifier.background(color = Color.Gray)) {
Box(
Modifier.padding(start = 20.dp, top = 30.dp, end = 20.dp, bottom = 30.dp)
- .preferredSize(50.dp)
+ .size(50.dp)
.background(Color.Blue)
)
}
@@ -47,7 +47,7 @@
Box(
Modifier
.padding(horizontal = 20.dp, vertical = 30.dp)
- .preferredSize(50.dp)
+ .size(50.dp)
.background(Color.Blue)
)
}
@@ -57,7 +57,7 @@
@Composable
fun PaddingAllModifier() {
Box(Modifier.background(color = Color.Gray)) {
- Box(Modifier.padding(all = 20.dp).preferredSize(50.dp).background(Color.Blue))
+ Box(Modifier.padding(all = 20.dp).size(50.dp).background(Color.Blue))
}
}
@@ -66,7 +66,7 @@
fun PaddingValuesModifier() {
val innerPadding = PaddingValues(top = 10.dp, start = 15.dp)
Box(Modifier.background(color = Color.Gray)) {
- Box(Modifier.padding(innerPadding).preferredSize(50.dp).background(Color.Blue))
+ Box(Modifier.padding(innerPadding).size(50.dp).background(Color.Blue))
}
}
@@ -76,7 +76,7 @@
Box(Modifier.background(color = Color.Gray)) {
Box(
Modifier.absolutePadding(left = 20.dp, top = 30.dp, right = 20.dp, bottom = 30.dp)
- .preferredSize(50.dp)
+ .size(50.dp)
.background(Color.Blue)
)
}
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RowSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RowSample.kt
index fa242d2..a535211 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RowSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RowSample.kt
@@ -21,8 +21,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -36,13 +36,13 @@
fun SimpleRow() {
Row {
// The child with no weight will have the specified size.
- Box(Modifier.preferredSize(40.dp, 80.dp).background(Color.Magenta))
+ Box(Modifier.size(40.dp, 80.dp).background(Color.Magenta))
// Has weight, the child will occupy half of the remaining width.
- Box(Modifier.preferredHeight(40.dp).weight(1f).background(Color.Yellow))
+ Box(Modifier.height(40.dp).weight(1f).background(Color.Yellow))
// Has weight and does not fill, the child will occupy at most half of the remaining width.
// Therefore it will occupy 80.dp (its preferred width) if the assigned width is larger.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.weight(1f, fill = false)
.background(Color.Green)
)
@@ -55,25 +55,25 @@
Row(Modifier.fillMaxHeight()) {
// The child with no align modifier is positioned by default so that its top edge is
// aligned to the top of the vertical axis.
- Box(Modifier.preferredSize(80.dp, 40.dp).background(Color.Magenta))
+ Box(Modifier.size(80.dp, 40.dp).background(Color.Magenta))
// Gravity.Top, the child will be positioned so that its top edge is aligned to the top
// of the vertical axis.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.align(Alignment.Top)
.background(Color.Red)
)
// Gravity.Center, the child will be positioned so that its center is in the middle of
// the vertical axis.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.align(Alignment.CenterVertically)
.background(Color.Yellow)
)
// Gravity.Bottom, the child will be positioned so that its bottom edge is aligned to the
// bottom of the vertical axis.
Box(
- Modifier.preferredSize(80.dp, 40.dp)
+ Modifier.size(80.dp, 40.dp)
.align(Alignment.Bottom)
.background(Color.Green)
)
@@ -92,7 +92,7 @@
// If no other sibling had alignBy() or alignByBaseline(), the modifier would have no
// effect.
Box(
- modifier = Modifier.preferredSize(80.dp, 40.dp)
+ modifier = Modifier.size(80.dp, 40.dp)
.alignBy { it.height / 2 }
.background(Color.Magenta)
)
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SizeModifierSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SizeModifierSample.kt
index 1563dcc..e9668f3 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SizeModifierSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SizeModifierSample.kt
@@ -24,14 +24,14 @@
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredSizeIn
-import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredSizeIn
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
@@ -43,28 +43,28 @@
@Sampled
@Composable
-fun SimpleSizeModifier() {
+fun SimpleRequiredSizeModifier() {
// The result is a 50.dp x 50.dp red box centered in a 100.dp x 100.dp space.
// Note that although a previous modifier asked it to be 100.dp x 100.dp, this
- // will not be respected. They would be respected if preferredSize was used instead of size.
+ // will not be respected. They would be respected if size was used instead of requiredSize.
Box(
Modifier
- .size(100.dp, 100.dp)
- .size(50.dp, 50.dp)
+ .requiredSize(100.dp, 100.dp)
+ .requiredSize(50.dp, 50.dp)
.background(Color.Red)
)
}
@Sampled
@Composable
-fun SimpleWidthModifier() {
+fun SimpleRequiredWidthModifier() {
// The result is a 50.dp x 50.dp magenta box centered in a 100.dp x 100.dp space.
// Note that although a previous modifier asked it to be 100.dp width, this
- // will not be respected. They would be respected if preferredWidth was used instead of width.
+ // will not be respected. They would be respected if width was used instead of requiredWidth.
Box(
Modifier
- .width(100.dp)
- .width(50.dp)
+ .requiredWidth(100.dp)
+ .requiredWidth(50.dp)
.aspectRatio(1f)
.background(Color.Magenta)
)
@@ -72,14 +72,14 @@
@Sampled
@Composable
-fun SimpleHeightModifier() {
+fun SimpleRequiredHeightModifier() {
// The result is a 50.dp x 50.dp blue box centered in a 100.dp x 100.dp space.
// Note that although a previous modifier asked it to be 100.dp height, this
- // will not be respected. They would be respected if preferredHeight was used instead of height.
+ // will not be respected. They would be respected if height was used instead of requiredHeight.
Box(
Modifier
- .height(100.dp)
- .height(50.dp)
+ .requiredHeight(100.dp)
+ .requiredHeight(50.dp)
.aspectRatio(1f)
.background(Color.Blue)
)
@@ -87,25 +87,25 @@
@Sampled
@Composable
-fun SimplePreferredSizeModifier() {
+fun SimpleSizeModifier() {
Box {
- Box(Modifier.preferredSize(100.dp, 100.dp).background(Color.Red))
+ Box(Modifier.size(100.dp, 100.dp).background(Color.Red))
}
}
@Sampled
@Composable
-fun SimplePreferredWidthModifier() {
+fun SimpleWidthModifier() {
Box {
- Box(Modifier.preferredWidth(100.dp).aspectRatio(1f).background(Color.Magenta))
+ Box(Modifier.width(100.dp).aspectRatio(1f).background(Color.Magenta))
}
}
@Sampled
@Composable
-fun SimplePreferredHeightModifier() {
+fun SimpleHeightModifier() {
Box {
- Box(Modifier.preferredHeight(100.dp).aspectRatio(1f).background(Color.Blue))
+ Box(Modifier.height(100.dp).aspectRatio(1f).background(Color.Blue))
}
}
@@ -113,18 +113,18 @@
@Composable
fun SimpleFillWidthModifier() {
Box(Modifier.fillMaxWidth().background(Color.Red), contentAlignment = Alignment.Center) {
- Box(Modifier.preferredSize(100.dp).background(color = Color.Magenta))
+ Box(Modifier.size(100.dp).background(color = Color.Magenta))
}
}
@Sampled
@Composable
fun FillHalfWidthModifier() {
- Box(Modifier.size(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
+ Box(Modifier.requiredSize(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
// The inner Box will be (50.dp x 30.dp).
Box(
Modifier.fillMaxWidth(fraction = 0.5f)
- .height(30.dp)
+ .requiredHeight(30.dp)
.background(color = Color.Magenta)
)
}
@@ -134,17 +134,17 @@
@Composable
fun SimpleFillHeightModifier() {
Box(Modifier.fillMaxHeight().background(Color.Red), contentAlignment = Alignment.Center) {
- Box(Modifier.preferredSize(100.dp).background(color = Color.Magenta))
+ Box(Modifier.size(100.dp).background(color = Color.Magenta))
}
}
@Sampled
@Composable
fun FillHalfHeightModifier() {
- Box(Modifier.size(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
+ Box(Modifier.requiredSize(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
// The inner Box will be (30.dp x 50.dp).
Box(
- Modifier.width(30.dp)
+ Modifier.requiredWidth(30.dp)
.fillMaxHeight(0.5f)
.background(color = Color.Magenta)
)
@@ -155,17 +155,17 @@
@Composable
fun SimpleFillModifier() {
Box(Modifier.fillMaxSize().background(Color.Red), contentAlignment = Alignment.Center) {
- Box(Modifier.preferredSize(100.dp).background(color = Color.Magenta))
+ Box(Modifier.size(100.dp).background(color = Color.Magenta))
}
}
@Sampled
@Composable
fun FillHalfSizeModifier() {
- Box(Modifier.size(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
+ Box(Modifier.requiredSize(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
// The inner Box will be (50.dp x 50.dp).
Box(
- Modifier.width(30.dp)
+ Modifier.requiredWidth(30.dp)
.fillMaxSize(0.5f)
.background(color = Color.Magenta)
)
@@ -176,15 +176,15 @@
@Composable
fun SimpleWrapContentAlignedModifier() {
// Here the result will be a 20.dp x 20.dp blue box top-centered in a 40.dp x 40.dp space.
- // Because of the preferredSizeIn modifier, if wrapContentSize did not exist, the blue rectangle
+ // Because of the sizeIn modifier, if wrapContentSize did not exist, the blue rectangle
// would actually be 40.dp x 40.dp to satisfy the min size set by the modifier. However,
// because we provide wrapContentSize, the blue rectangle is specified to be wrap
// content - if the desired size is smaller than 40.dp x 40.dp, it will be top-centered in
// this space. Therefore the 20.dp x 20.dp is top-centered in the space.
Box(
- Modifier.preferredSizeIn(minWidth = 40.dp, minHeight = 40.dp)
+ Modifier.sizeIn(minWidth = 40.dp, minHeight = 40.dp)
.wrapContentSize(Alignment.TopCenter)
- .preferredSize(20.dp)
+ .size(20.dp)
.background(Color.Blue)
)
}
@@ -193,15 +193,15 @@
@Composable
fun SimpleWrapContentVerticallyAlignedModifier() {
// Here the result will be a 50.dp x 20.dp blue box centered vertically in a 50.dp x 50.dp
- // space. Because of the preferredSize modifier, if wrapContentHeight did not exist,
+ // space. Because of the size modifier, if wrapContentHeight did not exist,
// the blue rectangle would actually be 50.dp x 50.dp to satisfy the size set by the modifier.
// However, because we provide wrapContentHeight, the blue rectangle is specified to be wrap
// content in height - if the desired height is smaller than 50.dp, it will be centered
// vertically in this space. Therefore the 50.dp x 20.dp is centered vertically in the space.
Box(
- Modifier.preferredSize(50.dp)
+ Modifier.size(50.dp)
.wrapContentHeight(Alignment.CenterVertically)
- .preferredHeight(20.dp)
+ .height(20.dp)
.background(Color.Blue)
)
}
@@ -210,16 +210,16 @@
@Composable
fun SimpleWrapContentHorizontallyAlignedModifier() {
// Here the result will be a 20.dp x 50.dp blue box centered vertically in a 50.dp x 50.dp
- // space. Because of the preferredSize modifier, if wrapContentWidth did not exist,
+ // space. Because of the size modifier, if wrapContentWidth did not exist,
// the blue rectangle would actually be 50.dp x 50.dp to satisfy the size set by the modifier.
// However, because we provide wrapContentWidth, the blue rectangle is specified to be wrap
// content in width - if the desired width is smaller than 50.dp, it will be centered
// horizontally in this space. Therefore the 50.dp x 20.dp is centered horizontally
// in the space.
Box(
- Modifier.preferredSize(50.dp)
+ Modifier.size(50.dp)
.wrapContentWidth(Alignment.CenterHorizontally)
- .preferredWidth(20.dp)
+ .width(20.dp)
.background(Color.Blue)
)
}
@@ -239,8 +239,8 @@
DefaultMinBox()
// This will be a 50.dp x 50.dp blue box. Because we are providing min constraints
// to the DefaultMinBox, defaultMinSize will not apply its min constraints.
- DefaultMinBox(Modifier.sizeIn(minWidth = 50.dp, minHeight = 50.dp))
- // Note that if DefaultMinBox used sizeIn or preferredSizeIn rather than
+ DefaultMinBox(Modifier.requiredSizeIn(minWidth = 50.dp, minHeight = 50.dp))
+ // Note that if DefaultMinBox used requiredSizeIn or sizeIn rather than
// defaultMinSize, the min constraints would have been applied with either
// of the above usages.
}
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SpacerSample.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SpacerSample.kt
index 96c8252..fe7d2d5 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SpacerSample.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/SpacerSample.kt
@@ -21,8 +21,8 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -32,10 +32,10 @@
@Composable
fun SpacerExample() {
Row {
- Box(Modifier.preferredSize(100.dp).background(Color.Red))
- Spacer(Modifier.preferredWidth(20.dp))
- Box(Modifier.preferredSize(100.dp).background(Color.Magenta))
+ Box(Modifier.size(100.dp).background(Color.Red))
+ Spacer(Modifier.width(20.dp))
+ Box(Modifier.size(100.dp).background(Color.Magenta))
Spacer(Modifier.weight(1f))
- Box(Modifier.preferredSize(100.dp).background(Color.Black))
+ Box(Modifier.size(100.dp).background(Color.Black))
}
}
\ No newline at end of file
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/AlignmentLineTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/AlignmentLineTest.kt
index d4883b2..43f64fb 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/AlignmentLineTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/AlignmentLineTest.kt
@@ -230,7 +230,7 @@
Box(Modifier.saveLayoutInfo(parentSize, Ref(), layoutLatch)) {
AlignmentLineLayout(
childDp, 0.dp, testLine, lineDp,
- Modifier.preferredSizeIn(maxWidth = maxWidth)
+ Modifier.sizeIn(maxWidth = maxWidth)
.saveLayoutInfo(childSize, childPosition, layoutLatch)
.paddingFrom(testLine, beforeDp, afterDp)
)
@@ -264,7 +264,7 @@
Box(Modifier.saveLayoutInfo(parentSize, Ref(), layoutLatch)) {
AlignmentLineLayout(
0.dp, childDp, testLine, lineDp,
- Modifier.preferredSizeIn(maxHeight = maxHeight)
+ Modifier.sizeIn(maxHeight = maxHeight)
.saveLayoutInfo(childSize, childPosition, layoutLatch)
.paddingFrom(testLine, beforeDp, afterDp)
)
@@ -290,7 +290,7 @@
Box {
BoxWithConstraints(
Modifier
- .preferredSizeIn(minHeight = minHeight)
+ .sizeIn(minHeight = minHeight)
.paddingFrom(testLine, 0.dp)
) {
Assert.assertEquals(minHeight.roundToPx(), constraints.minHeight)
@@ -310,7 +310,7 @@
Box {
BoxWithConstraints(
Modifier
- .preferredSizeIn(minWidth = minWidth)
+ .sizeIn(minWidth = minWidth)
.paddingFrom(testLine, 0.dp)
) {
Assert.assertEquals(minWidth.roundToPx(), constraints.minWidth)
@@ -340,7 +340,7 @@
Box {
AlignmentLineLayout(
childSize, childSize, testLine, linePosition,
- Modifier.preferredWidth(incomingSize)
+ Modifier.width(incomingSize)
.paddingFrom(testLine, before = before)
.onGloballyPositioned {
Assert.assertEquals(beforePx - linePositionPx, it.positionInParent.x)
@@ -349,7 +349,7 @@
)
AlignmentLineLayout(
childSize, childSize, testLine, linePosition,
- Modifier.preferredWidth(incomingSize)
+ Modifier.width(incomingSize)
.paddingFrom(testLine, after = after)
.onGloballyPositioned {
Assert.assertEquals(
@@ -383,7 +383,7 @@
Box {
AlignmentLineLayout(
childSize, childSize, testLine, linePosition,
- Modifier.preferredHeight(incomingSize)
+ Modifier.height(incomingSize)
.paddingFrom(testLine, before = before)
.onGloballyPositioned {
Assert.assertEquals(beforePx - linePositionPx, it.positionInParent.y)
@@ -392,7 +392,7 @@
)
AlignmentLineLayout(
childSize, childSize, testLine, linePosition,
- Modifier.preferredHeight(incomingSize)
+ Modifier.height(incomingSize)
.paddingFrom(testLine, after = after)
.onGloballyPositioned {
Assert.assertEquals(
@@ -489,7 +489,7 @@
show {
Box {
Box(
- Modifier.preferredHeight(incomingSize)
+ Modifier.height(incomingSize)
.paddingFromBaseline(top = before, bottom = after)
.onGloballyPositioned {
Assert.assertEquals(beforePx - linePositionPx, it.positionInParent.y)
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt
index f0981a7..49d0f47 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt
@@ -261,7 +261,7 @@
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(
Modifier
- .preferredSize(tripleSizeDp)
+ .size(tripleSizeDp)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
stackSize.value = coordinates.size
positionedLatch.countDown()
@@ -269,55 +269,55 @@
) {
Box(
Modifier.align(Alignment.TopStart)
- .preferredSize(sizeDp, sizeDp)
+ .size(sizeDp, sizeDp)
.saveLayoutInfo(childSize[0], childPosition[0], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.TopCenter)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[1], childPosition[1], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.TopEnd)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[2], childPosition[2], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.CenterStart)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[3], childPosition[3], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.Center)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[4], childPosition[4], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.CenterEnd)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[5], childPosition[5], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.BottomStart)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[6], childPosition[6], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.BottomCenter)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[7], childPosition[7], positionedLatch)
) {
}
Box(
Modifier.align(Alignment.BottomEnd)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize[8], childPosition[8], positionedLatch)
) {
}
@@ -368,7 +368,7 @@
show {
Container(alignment = Alignment.TopStart) {
Container(
- Modifier.preferredSize(
+ Modifier.size(
sizeDp,
sizeDp
).then(
@@ -421,10 +421,10 @@
show {
Box(
contentAlignment = Alignment.BottomEnd,
- modifier = Modifier.size(outerSize)
+ modifier = Modifier.requiredSize(outerSize)
) {
Box(
- Modifier.size(innerSize).onGloballyPositioned {
+ Modifier.requiredSize(innerSize).onGloballyPositioned {
assertEquals(outerSizePx - innerSizePx, it.positionInParent.x)
assertEquals(outerSizePx - innerSizePx, it.positionInParent.y)
positionedLatch.countDown()
@@ -441,7 +441,7 @@
val size = 10f
val sizeDp = size.toDp()
show {
- Box(Modifier.size(sizeDp)) {
+ Box(Modifier.requiredSize(sizeDp)) {
Box(
Modifier.align(Alignment.BottomEnd).align(Alignment.TopStart)
.onGloballyPositioned {
@@ -467,7 +467,7 @@
content = {
Box {
Box(
- Modifier.size(size.value, 10.dp).onGloballyPositioned {
+ Modifier.requiredSize(size.value, 10.dp).onGloballyPositioned {
layoutLatch.countDown()
}
)
@@ -501,11 +501,11 @@
show {
Box(
- Modifier.widthIn(20.dp, 40.dp),
+ Modifier.requiredWidthIn(20.dp, 40.dp),
propagateMinConstraints = true
) {
Box(
- Modifier.preferredWidth(10.dp).onSizeChanged {
+ Modifier.width(10.dp).onSizeChanged {
assertEquals(20.dp.roundToPx(), it.width)
measuredLatch.countDown()
}
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt
index a4171e8..0ed532c 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt
@@ -54,7 +54,7 @@
minIntrinsicWidthSize.value = coordinates.size
positionedLatch.countDown()
}
- .preferredWidth(IntrinsicSize.Min).saveLayoutInfo(
+ .width(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -82,7 +82,7 @@
Modifier.onGloballyPositioned { coordinates: LayoutCoordinates ->
minIntrinsicHeightSize.value = coordinates.size
positionedLatch.countDown()
- }.preferredHeight(IntrinsicSize.Min).saveLayoutInfo(
+ }.height(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -110,7 +110,7 @@
Modifier.onGloballyPositioned { coordinates: LayoutCoordinates ->
maxIntrinsicWidthSize.value = coordinates.size
positionedLatch.countDown()
- }.preferredWidth(IntrinsicSize.Max).saveLayoutInfo(
+ }.width(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -138,7 +138,7 @@
Modifier.onGloballyPositioned { coordinates: LayoutCoordinates ->
maxIntrinsicHeightSize.value = coordinates.size
positionedLatch.countDown()
- }.preferredHeight(IntrinsicSize.Max).saveLayoutInfo(
+ }.height(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -167,7 +167,7 @@
Modifier.onGloballyPositioned { coordinates: LayoutCoordinates ->
minIntrinsicWidthSize.value = coordinates.size
positionedLatch.countDown()
- }.preferredWidth(IntrinsicSize.Min).saveLayoutInfo(
+ }.width(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -197,7 +197,7 @@
Modifier.onGloballyPositioned { coordinates: LayoutCoordinates ->
minIntrinsicWidthSize.value = coordinates.size
positionedLatch.countDown()
- }.preferredWidth(IntrinsicSize.Min).saveLayoutInfo(
+ }.width(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -230,7 +230,7 @@
}
) {
FixedIntrinsicsBox(
- Modifier.preferredHeight(IntrinsicSize.Min).saveLayoutInfo(
+ Modifier.height(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -263,7 +263,7 @@
}
) {
FixedIntrinsicsBox(
- Modifier.preferredHeight(IntrinsicSize.Min).saveLayoutInfo(
+ Modifier.height(IntrinsicSize.Min).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -296,7 +296,7 @@
}
) {
FixedIntrinsicsBox(
- Modifier.preferredWidth(IntrinsicSize.Max).saveLayoutInfo(
+ Modifier.width(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -329,7 +329,7 @@
}
) {
FixedIntrinsicsBox(
- Modifier.preferredWidth(IntrinsicSize.Max).saveLayoutInfo(
+ Modifier.width(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -362,7 +362,7 @@
}
) {
FixedIntrinsicsBox(
- Modifier.preferredHeight(IntrinsicSize.Max).saveLayoutInfo(
+ Modifier.height(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -395,7 +395,7 @@
}
) {
FixedIntrinsicsBox(
- Modifier.preferredHeight(IntrinsicSize.Max).saveLayoutInfo(
+ Modifier.height(IntrinsicSize.Max).saveLayoutInfo(
size = childSize,
position = childPosition,
positionedLatch = positionedLatch
@@ -416,7 +416,7 @@
fun testMinIntrinsicWidth_intrinsicMeasurements() = with(density) {
testIntrinsics({
FixedIntrinsicsBox(
- Modifier.preferredWidth(IntrinsicSize.Min), 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ Modifier.width(IntrinsicSize.Min), 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
)
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
assertEquals(10.dp.roundToPx(), minIntrinsicWidth(0))
@@ -430,7 +430,7 @@
fun testMinIntrinsicHeight_intrinsicMeasurements() = with(density) {
testIntrinsics({
FixedIntrinsicsBox(
- Modifier.preferredHeight(IntrinsicSize.Min),
+ Modifier.height(IntrinsicSize.Min),
10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
)
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
@@ -445,7 +445,7 @@
fun testMaxIntrinsicWidth_intrinsicMeasurements() = with(density) {
testIntrinsics({
FixedIntrinsicsBox(
- Modifier.preferredWidth(IntrinsicSize.Max), 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
+ Modifier.width(IntrinsicSize.Max), 10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
)
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
assertEquals(30.dp.roundToPx(), minIntrinsicWidth(0))
@@ -459,7 +459,7 @@
fun testMaxIntrinsicHeight_intrinsicMeasurements() = with(density) {
testIntrinsics({
FixedIntrinsicsBox(
- Modifier.preferredHeight(IntrinsicSize.Max),
+ Modifier.height(IntrinsicSize.Max),
10.dp, 20.dp, 30.dp, 40.dp, 50.dp, 60.dp
)
}) { minIntrinsicWidth, minIntrinsicHeight, maxIntrinsicWidth, maxIntrinsicHeight ->
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt
index 63d0da7..0e1a1e4 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt
@@ -108,7 +108,7 @@
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
- .preferredWidth(containerWidth)
+ .width(containerWidth)
.wrapContentSize(Alignment.TopStart)
.offset(offsetX, offsetY)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
@@ -117,7 +117,7 @@
}
) {
// TODO(soboleva): this box should not be needed after b/154758475 is fixed.
- Box(Modifier.size(boxSize.toDp()))
+ Box(Modifier.requiredSize(boxSize.toDp()))
}
}
}
@@ -168,7 +168,7 @@
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
- .preferredWidth(containerWidth)
+ .width(containerWidth)
.wrapContentSize(Alignment.TopStart)
.absoluteOffset(offsetX, offsetY)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
@@ -177,7 +177,7 @@
}
) {
// TODO(soboleva): this box should not be needed after b/154758475 is fixed.
- Box(Modifier.size(boxSize.toDp()))
+ Box(Modifier.requiredSize(boxSize.toDp()))
}
}
}
@@ -228,7 +228,7 @@
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
- .preferredWidth(containerWidth)
+ .width(containerWidth)
.wrapContentSize(Alignment.TopStart)
.offset { IntOffset(offsetX, offsetY) }
.onGloballyPositioned { coordinates: LayoutCoordinates ->
@@ -237,7 +237,7 @@
}
) {
// TODO(soboleva): this box should not be needed after b/154758475 is fixed.
- Box(Modifier.size(boxSize.toDp()))
+ Box(Modifier.requiredSize(boxSize.toDp()))
}
}
}
@@ -291,7 +291,7 @@
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
- .preferredWidth(containerWidth)
+ .width(containerWidth)
.wrapContentSize(Alignment.TopStart)
.absoluteOffset { IntOffset(offsetX, offsetY) }
.onGloballyPositioned { coordinates: LayoutCoordinates ->
@@ -300,7 +300,7 @@
}
) {
// TODO(soboleva): this box should not be needed after b/154758475 is fixed.
- Box(Modifier.size(boxSize.toDp()))
+ Box(Modifier.requiredSize(boxSize.toDp()))
}
}
}
@@ -362,7 +362,7 @@
rule.setContent {
Box(
Modifier
- .size(10.dp)
+ .requiredSize(10.dp)
.offset { IntOffset(offset.roundToInt(), 0) }
.drawBehind {
contentRedrawsCount ++
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt
index 2750c52..3fe5d20 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt
@@ -279,7 +279,7 @@
Row(Modifier.fillMaxSize()) {
Box(
Modifier.padding(start = padding1Dp, end = padding2Dp)
- .preferredSize(sizeDp, sizeDp)
+ .size(sizeDp, sizeDp)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
childSize[0] = coordinates.size
childPosition[0] = coordinates.positionInRoot()
@@ -290,7 +290,7 @@
Box(
Modifier.padding(end = padding3Dp)
- .preferredSize(sizeDp, sizeDp)
+ .size(sizeDp, sizeDp)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
childSize[1] = coordinates.size
childPosition[1] = coordinates.positionInRoot()
@@ -301,7 +301,7 @@
Box(
Modifier.padding(start = padding1Dp)
- .preferredSize(sizeDp, sizeDp)
+ .size(sizeDp, sizeDp)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
childSize[2] = coordinates.size
childPosition[2] = coordinates.positionInRoot()
@@ -355,7 +355,7 @@
Row(Modifier.fillMaxSize()) {
Box(
Modifier.absolutePadding(left = padding1Dp, right = padding2Dp)
- .preferredSize(sizeDp, sizeDp)
+ .size(sizeDp, sizeDp)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
childPosition[0] = coordinates.positionInRoot()
drawLatch.countDown()
@@ -364,7 +364,7 @@
}
Box(
Modifier.absolutePadding(right = padding3Dp)
- .preferredSize(sizeDp, sizeDp)
+ .size(sizeDp, sizeDp)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
childPosition[1] = coordinates.positionInRoot()
drawLatch.countDown()
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
index e152de4..0245250 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
@@ -390,7 +390,7 @@
Row(
Modifier.wrapContentSize(Alignment.TopStart)
.padding(start = leftPadding.toDp())
- .preferredWidthIn(max = expectedRowWidth.toDp())
+ .widthIn(max = expectedRowWidth.toDp())
.onGloballyPositioned { coordinates ->
rowWidth = coordinates.size.width.toFloat()
}
@@ -436,7 +436,7 @@
Row(
Modifier.wrapContentSize(Alignment.TopStart)
.padding(start = leftPadding.toDp())
- .preferredWidthIn(max = expectedRowWidth.toDp())
+ .widthIn(max = expectedRowWidth.toDp())
.onGloballyPositioned { coordinates ->
rowWidth = coordinates.size.width.toFloat()
}
@@ -492,7 +492,7 @@
Column(
Modifier.wrapContentSize(Alignment.TopStart)
.padding(top = topPadding.toDp())
- .preferredHeightIn(max = expectedColumnHeight.toDp())
+ .heightIn(max = expectedColumnHeight.toDp())
.onGloballyPositioned { coordinates ->
columnHeight = coordinates.size.height.toFloat()
}
@@ -548,7 +548,7 @@
Column(
Modifier.wrapContentSize(Alignment.TopStart)
.padding(top = topPadding.toDp())
- .preferredHeightIn(max = expectedColumnHeight.toDp())
+ .heightIn(max = expectedColumnHeight.toDp())
.onGloballyPositioned { coordinates ->
columnHeight = coordinates.size.height.toFloat()
}
@@ -1277,8 +1277,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1307,8 +1307,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1376,8 +1376,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1406,8 +1406,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1438,8 +1438,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -1513,8 +1513,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -1546,8 +1546,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -1579,8 +1579,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -1755,8 +1755,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1785,8 +1785,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1854,8 +1854,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1884,8 +1884,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = (sizeDp * 2), height = (sizeDp * 2)))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = (sizeDp * 2), height = (sizeDp * 2)))
}
}
}
@@ -1916,8 +1916,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -1991,8 +1991,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -2024,8 +2024,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -2057,8 +2057,8 @@
drawLatch.countDown()
}
) {
- Spacer(Modifier.preferredSize(width = sizeDp, height = sizeDp))
- Spacer(Modifier.preferredSize(width = sizeDp * 2, height = sizeDp * 2))
+ Spacer(Modifier.size(width = sizeDp, height = sizeDp))
+ Spacer(Modifier.size(width = sizeDp * 2, height = sizeDp * 2))
}
}
}
@@ -2093,7 +2093,7 @@
ConstrainedBox(constraints = DpConstraints(minHeight = columnHeightDp)) {
// TODO: add maxHeight(Constraints.Infinity) modifier
Column(
- Modifier.preferredHeightIn(max = Dp.Infinity)
+ Modifier.heightIn(max = Dp.Infinity)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
columnSize = coordinates.size
drawLatch.countDown()
@@ -2557,13 +2557,13 @@
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(0f, it.positionInParent.x)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(sizePx + spacePx, it.positionInParent.x)
latch.countDown()
}
@@ -2587,19 +2587,19 @@
Column {
Row(
horizontalArrangement = Arrangement.spacedBy(space, Alignment.End),
- modifier = Modifier.size(rowSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(rowSize).onGloballyPositioned {
assertEquals(rowSizePx, it.size.width)
latch.countDown()
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(rowSizePx - spacePx - sizePx * 2, it.positionInParent.x)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(rowSizePx - sizePx, it.positionInParent.x)
latch.countDown()
}
@@ -2623,27 +2623,27 @@
Column {
Row(
horizontalArrangement = Arrangement.spacedBy(space),
- modifier = Modifier.size(rowSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(rowSize).onGloballyPositioned {
assertEquals(rowSizePx.roundToInt(), it.size.width)
latch.countDown()
}
) {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(0f, it.positionInParent.x)
assertEquals(sizePx.roundToInt(), it.size.width)
latch.countDown()
}
)
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(sizePx + spacePx, it.positionInParent.x)
assertEquals((rowSizePx - spacePx - sizePx).roundToInt(), it.size.width)
latch.countDown()
}
)
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(rowSizePx, it.positionInParent.x)
assertEquals(0, it.size.width)
latch.countDown()
@@ -2666,20 +2666,20 @@
Column {
Row(
horizontalArrangement = Arrangement.aligned(Alignment.End),
- modifier = Modifier.size(rowSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(rowSize).onGloballyPositioned {
assertEquals(rowSizePx.roundToInt(), it.size.width)
latch.countDown()
}
) {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(rowSizePx - sizePx * 2, it.positionInParent.x)
assertEquals(sizePx.roundToInt(), it.size.width)
latch.countDown()
}
)
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(rowSizePx - sizePx, it.positionInParent.x)
assertEquals(sizePx.roundToInt(), it.size.width)
latch.countDown()
@@ -3030,13 +3030,13 @@
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(0f, it.positionInParent.x)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(sizePx + spacePx, it.positionInParent.y)
latch.countDown()
}
@@ -3060,19 +3060,19 @@
Row {
Column(
verticalArrangement = Arrangement.spacedBy(space, Alignment.Bottom),
- modifier = Modifier.size(columnSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(columnSize).onGloballyPositioned {
assertEquals(columnSizePx, it.size.height)
latch.countDown()
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(columnSizePx - spacePx - sizePx * 2, it.positionInParent.y)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(columnSizePx - sizePx, it.positionInParent.y)
latch.countDown()
}
@@ -3096,20 +3096,20 @@
Row {
Column(
verticalArrangement = Arrangement.spacedBy(space),
- modifier = Modifier.size(columnSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(columnSize).onGloballyPositioned {
assertEquals(columnSizePx.roundToInt(), it.size.height)
latch.countDown()
}
) {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(0f, it.positionInParent.y)
assertEquals(sizePx.roundToInt(), it.size.height)
latch.countDown()
}
)
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(sizePx + spacePx, it.positionInParent.y)
assertEquals(
(columnSizePx - spacePx - sizePx).roundToInt(), it.size.height
@@ -3118,7 +3118,7 @@
}
)
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
assertEquals(columnSizePx, it.positionInParent.y)
assertEquals(0, it.size.height)
latch.countDown()
@@ -3141,19 +3141,19 @@
Row {
Column(
verticalArrangement = Arrangement.aligned(Alignment.Bottom),
- modifier = Modifier.size(columnSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(columnSize).onGloballyPositioned {
assertEquals(columnSizePx, it.size.height)
latch.countDown()
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(columnSizePx - sizePx * 2, it.positionInParent.y)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(columnSizePx - sizePx, it.positionInParent.y)
latch.countDown()
}
@@ -3179,7 +3179,7 @@
) {
Row {
Spacer(
- Modifier.preferredSize(width = childSizeDp, height = childSizeDp)
+ Modifier.size(width = childSizeDp, height = childSizeDp)
.onGloballyPositioned { coordinates ->
containerSize.value = coordinates.size
layoutLatch.countDown()
@@ -3209,7 +3209,7 @@
) {
Column {
Spacer(
- Modifier.preferredSize(width = childSizeDp, height = childSizeDp).then(
+ Modifier.size(width = childSizeDp, height = childSizeDp).then(
Modifier.onGloballyPositioned { coordinates ->
containerSize.value = coordinates.size
layoutLatch.countDown()
@@ -3917,9 +3917,9 @@
val positionedLatch = CountDownLatch(1)
show {
@OptIn(ExperimentalLayout::class)
- Row(Modifier.width(rowWidth).preferredHeight(IntrinsicSize.Min)) {
+ Row(Modifier.requiredWidth(rowWidth).height(IntrinsicSize.Min)) {
Container(
- Modifier.width(dividerWidth).fillMaxHeight().onGloballyPositioned {
+ Modifier.requiredWidth(dividerWidth).fillMaxHeight().onGloballyPositioned {
assertEquals(
it.size.height,
(rowWidth.roundToPx() - dividerWidth.roundToPx()) / 2
@@ -3948,9 +3948,9 @@
val positionedLatch = CountDownLatch(1)
show {
@OptIn(ExperimentalLayout::class)
- Column(Modifier.height(columnHeight).preferredWidth(IntrinsicSize.Min)) {
+ Column(Modifier.requiredHeight(columnHeight).width(IntrinsicSize.Min)) {
Container(
- Modifier.height(dividerHeight).fillMaxWidth().onGloballyPositioned {
+ Modifier.requiredHeight(dividerHeight).fillMaxWidth().onGloballyPositioned {
assertEquals(
it.size.width,
(columnHeight.roundToPx() - dividerHeight.roundToPx()) / 2
@@ -3982,7 +3982,7 @@
show {
Box {
- Column(Modifier.preferredHeight(columnHeight.toDp())) {
+ Column(Modifier.height(columnHeight.toDp())) {
Container(
Modifier.weight(2f)
.weight(1f)
@@ -4052,7 +4052,7 @@
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(Modifier.fillMaxWidth()) {
Container(
- Modifier.preferredSize(sizeDp).onGloballyPositioned { coordinates ->
+ Modifier.size(sizeDp).onGloballyPositioned { coordinates ->
childPosition[0] = coordinates.positionInRoot()
drawLatch.countDown()
}
@@ -4060,7 +4060,7 @@
}
Container(
- Modifier.preferredSize(sizeDp * 2)
+ Modifier.size(sizeDp * 2)
.onGloballyPositioned { coordinates ->
childPosition[1] = coordinates.positionInRoot()
drawLatch.countDown()
@@ -4313,7 +4313,7 @@
horizontalArrangement = Arrangement.End
) {
Container(
- Modifier.preferredSize(sizeDp).onGloballyPositioned { coordinates ->
+ Modifier.size(sizeDp).onGloballyPositioned { coordinates ->
childPosition[0] = coordinates.positionInRoot()
drawLatch.countDown()
}
@@ -4321,7 +4321,7 @@
}
Container(
- Modifier.preferredSize(sizeDp * 2)
+ Modifier.size(sizeDp * 2)
.onGloballyPositioned { coordinates ->
childPosition[1] = coordinates.positionInRoot()
drawLatch.countDown()
@@ -4358,19 +4358,19 @@
Column {
Row(
horizontalArrangement = Arrangement.spacedBy(space, Alignment.End),
- modifier = Modifier.size(rowSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(rowSize).onGloballyPositioned {
assertEquals(rowSizePx, it.size.width)
latch.countDown()
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(sizePx + spacePx, it.positionInParent.x)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(0f, it.positionInParent.x)
latch.countDown()
}
@@ -4393,7 +4393,7 @@
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(Modifier.fillMaxWidth()) {
Container(
- Modifier.preferredSize(sizeDp).onGloballyPositioned { coordinates ->
+ Modifier.size(sizeDp).onGloballyPositioned { coordinates ->
childPosition[0] = coordinates.positionInRoot()
drawLatch.countDown()
}
@@ -4401,7 +4401,7 @@
}
Container(
- Modifier.preferredSize(sizeDp * 2)
+ Modifier.size(sizeDp * 2)
.onGloballyPositioned { coordinates ->
childPosition[1] = coordinates.positionInRoot()
drawLatch.countDown()
@@ -4438,7 +4438,7 @@
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(Modifier.fillMaxWidth()) {
Container(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.align(Alignment.End)
.onGloballyPositioned { coordinates ->
childPosition[0] = coordinates.positionInRoot()
@@ -4448,7 +4448,7 @@
}
Container(
- Modifier.preferredSize(sizeDp * 2)
+ Modifier.size(sizeDp * 2)
.align(Alignment.End)
.onGloballyPositioned { coordinates ->
childPosition[1] = coordinates.positionInRoot()
@@ -4477,7 +4477,7 @@
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(Modifier.fillMaxWidth()) {
Container(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.alignBy { it.width }
.onGloballyPositioned { coordinates ->
childPosition[0] = coordinates.positionInRoot()
@@ -4487,7 +4487,7 @@
}
Container(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.alignBy { it.width / 2 }
.onGloballyPositioned { coordinates ->
childPosition[1] = coordinates.positionInRoot()
@@ -5299,19 +5299,19 @@
Column {
Row(
horizontalArrangement = Arrangement.Absolute.spacedBy(space, Alignment.End),
- modifier = Modifier.size(rowSize).onGloballyPositioned {
+ modifier = Modifier.requiredSize(rowSize).onGloballyPositioned {
assertEquals(rowSizePx, it.size.width)
latch.countDown()
}
) {
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(0f, it.positionInParent.x)
latch.countDown()
}
)
Box(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertEquals(sizePx + spacePx, it.positionInParent.x)
latch.countDown()
}
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
index 17683e1..7c80e56 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
@@ -76,39 +76,39 @@
Box {
Column {
Container(
- Modifier.preferredWidthIn(min = sizeDp, max = sizeDp * 2)
- .preferredHeight(sizeDp)
+ Modifier.widthIn(min = sizeDp, max = sizeDp * 2)
+ .height(sizeDp)
.saveLayoutInfo(size[0], position[0], positionedLatch)
) {
}
Container(
- Modifier.preferredWidthIn(max = sizeDp * 2)
- .preferredHeight(sizeDp)
+ Modifier.widthIn(max = sizeDp * 2)
+ .height(sizeDp)
.saveLayoutInfo(size[1], position[1], positionedLatch)
) {
}
Container(
- Modifier.preferredWidthIn(min = sizeDp)
- .preferredHeight(sizeDp)
+ Modifier.widthIn(min = sizeDp)
+ .height(sizeDp)
.saveLayoutInfo(size[2], position[2], positionedLatch)
) {
}
Container(
- Modifier.preferredWidthIn(max = sizeDp)
- .preferredWidthIn(min = sizeDp * 2)
- .preferredHeight(sizeDp)
+ Modifier.widthIn(max = sizeDp)
+ .widthIn(min = sizeDp * 2)
+ .height(sizeDp)
.saveLayoutInfo(size[3], position[3], positionedLatch)
) {
}
Container(
- Modifier.preferredWidthIn(min = sizeDp * 2)
- .preferredWidthIn(max = sizeDp)
- .preferredHeight(sizeDp)
+ Modifier.widthIn(min = sizeDp * 2)
+ .widthIn(max = sizeDp)
+ .height(sizeDp)
.saveLayoutInfo(size[4], position[4], positionedLatch)
) {
}
Container(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.saveLayoutInfo(size[5], position[5], positionedLatch)
) {
}
@@ -148,39 +148,39 @@
Box {
Row {
Container(
- Modifier.preferredHeightIn(min = sizeDp, max = sizeDp * 2)
- .preferredWidth(sizeDp)
+ Modifier.heightIn(min = sizeDp, max = sizeDp * 2)
+ .width(sizeDp)
.saveLayoutInfo(size[0], position[0], positionedLatch)
) {
}
Container(
- Modifier.preferredHeightIn(max = sizeDp * 2)
- .preferredWidth(sizeDp)
+ Modifier.heightIn(max = sizeDp * 2)
+ .width(sizeDp)
.saveLayoutInfo(size[1], position[1], positionedLatch)
) {
}
Container(
- Modifier.preferredHeightIn(min = sizeDp)
- .preferredWidth(sizeDp)
+ Modifier.heightIn(min = sizeDp)
+ .width(sizeDp)
.saveLayoutInfo(size[2], position[2], positionedLatch)
) {
}
Container(
- Modifier.preferredHeightIn(max = sizeDp)
- .preferredHeightIn(min = sizeDp * 2)
- .preferredWidth(sizeDp)
+ Modifier.heightIn(max = sizeDp)
+ .heightIn(min = sizeDp * 2)
+ .width(sizeDp)
.saveLayoutInfo(size[3], position[3], positionedLatch)
) {
}
Container(
- Modifier.preferredHeightIn(min = sizeDp * 2)
- .preferredHeightIn(max = sizeDp)
- .preferredWidth(sizeDp)
+ Modifier.heightIn(min = sizeDp * 2)
+ .heightIn(max = sizeDp)
+ .width(sizeDp)
.saveLayoutInfo(size[4], position[4], positionedLatch)
) {
}
Container(
- Modifier.preferredHeight(sizeDp).then(Modifier.preferredWidth(sizeDp)).then(
+ Modifier.height(sizeDp).then(Modifier.width(sizeDp)).then(
Modifier.saveLayoutInfo(size[5], position[5], positionedLatch)
)
) {
@@ -222,33 +222,33 @@
Row {
val maxSize = sizeDp * 2
Container(
- Modifier.preferredSizeIn(maxWidth = maxSize, maxHeight = maxSize)
- .preferredSizeIn(minWidth = sizeDp, minHeight = sizeDp)
+ Modifier.sizeIn(maxWidth = maxSize, maxHeight = maxSize)
+ .sizeIn(minWidth = sizeDp, minHeight = sizeDp)
.saveLayoutInfo(size[0], position[0], positionedLatch)
) {
}
Container(
- Modifier.preferredSizeIn(maxWidth = sizeDp, maxHeight = sizeDp)
- .preferredSizeIn(minWidth = sizeDp * 2, minHeight = sizeDp)
+ Modifier.sizeIn(maxWidth = sizeDp, maxHeight = sizeDp)
+ .sizeIn(minWidth = sizeDp * 2, minHeight = sizeDp)
.saveLayoutInfo(size[1], position[1], positionedLatch)
) {
}
val maxSize1 = sizeDp * 2
Container(
- Modifier.preferredSizeIn(minWidth = sizeDp, minHeight = sizeDp)
- .preferredSizeIn(maxWidth = maxSize1, maxHeight = maxSize1)
+ Modifier.sizeIn(minWidth = sizeDp, minHeight = sizeDp)
+ .sizeIn(maxWidth = maxSize1, maxHeight = maxSize1)
.saveLayoutInfo(size[2], position[2], positionedLatch)
) {
}
val minSize = sizeDp * 2
Container(
- Modifier.preferredSizeIn(minWidth = minSize, minHeight = minSize)
- .preferredSizeIn(maxWidth = sizeDp, maxHeight = sizeDp)
+ Modifier.sizeIn(minWidth = minSize, minHeight = minSize)
+ .sizeIn(maxWidth = sizeDp, maxHeight = sizeDp)
.saveLayoutInfo(size[3], position[3], positionedLatch)
) {
}
Container(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.saveLayoutInfo(size[4], position[4], positionedLatch)
) {
}
@@ -286,8 +286,8 @@
Box {
Container(width = sizeDp, height = sizeDp) {
Container(
- Modifier.preferredWidth(sizeDp * 2)
- .preferredHeight(sizeDp * 3)
+ Modifier.width(sizeDp * 2)
+ .height(sizeDp * 3)
.onGloballyPositioned { coordinates: LayoutCoordinates ->
constrainedBoxSize.value = coordinates.size
positionedLatch.countDown()
@@ -324,7 +324,7 @@
show {
Box {
Row {
- Container(Modifier.preferredWidthIn(max = Dp.Infinity)) {
+ Container(Modifier.widthIn(max = Dp.Infinity)) {
Container(
width = sizeDp, height = sizeDp,
modifier = Modifier.saveLayoutInfo(
@@ -334,7 +334,7 @@
) {
}
}
- Container(Modifier.preferredHeightIn(max = Dp.Infinity)) {
+ Container(Modifier.heightIn(max = Dp.Infinity)) {
Container(
width = sizeDp, height = sizeDp,
modifier = Modifier.saveLayoutInfo(
@@ -346,15 +346,15 @@
}
}
Container(
- Modifier.preferredWidth(sizeDp)
- .preferredHeight(sizeDp)
- .preferredWidthIn(max = Dp.Infinity)
- .preferredHeightIn(max = Dp.Infinity)
+ Modifier.width(sizeDp)
+ .height(sizeDp)
+ .widthIn(max = Dp.Infinity)
+ .heightIn(max = Dp.Infinity)
.saveLayoutInfo(size[2], position[2], positionedLatch)
) {
}
Container(
- Modifier.preferredSizeIn(
+ Modifier.sizeIn(
maxWidth = Dp.Infinity,
maxHeight = Dp.Infinity
)
@@ -392,8 +392,8 @@
show {
Box(
Modifier.wrapContentSize(Alignment.TopStart)
- .size(sizeDp * 2)
- .size(sizeDp)
+ .requiredSize(sizeDp * 2)
+ .requiredSize(sizeDp)
.saveLayoutInfo(boxSize, boxPosition, positionedLatch)
)
}
@@ -420,8 +420,8 @@
show {
Box(
Modifier.wrapContentSize(Alignment.TopStart)
- .size(sizeDp)
- .size(sizeDp * 2)
+ .requiredSize(sizeDp)
+ .requiredSize(sizeDp * 2)
.saveLayoutInfo(boxSize, boxPosition, positionedLatch)
)
}
@@ -438,74 +438,6 @@
fun testMeasurementConstraints_preferredSatisfiable() = with(density) {
assertConstraints(
Constraints(10, 30, 15, 35),
- Modifier.preferredWidth(20.toDp()),
- Constraints(20, 20, 15, 35)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredHeight(20.toDp()),
- Constraints(10, 30, 20, 20)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredSize(20.toDp()),
- Constraints(20, 20, 20, 20)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredWidthIn(20.toDp(), 25.toDp()),
- Constraints(20, 25, 15, 35)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredHeightIn(20.toDp(), 25.toDp()),
- Constraints(10, 30, 20, 25)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredSizeIn(20.toDp(), 20.toDp(), 25.toDp(), 25.toDp()),
- Constraints(20, 25, 20, 25)
- )
- }
-
- @Test
- fun testMeasurementConstraints_preferredUnsatisfiable() = with(density) {
- assertConstraints(
- Constraints(20, 40, 15, 35),
- Modifier.preferredWidth(15.toDp()),
- Constraints(20, 20, 15, 35)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredHeight(10.toDp()),
- Constraints(10, 30, 15, 15)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredSize(40.toDp()),
- Constraints(30, 30, 35, 35)
- )
- assertConstraints(
- Constraints(20, 30, 15, 35),
- Modifier.preferredWidthIn(10.toDp(), 15.toDp()),
- Constraints(20, 20, 15, 35)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredHeightIn(5.toDp(), 10.toDp()),
- Constraints(10, 30, 15, 15)
- )
- assertConstraints(
- Constraints(10, 30, 15, 35),
- Modifier.preferredSizeIn(40.toDp(), 50.toDp(), 45.toDp(), 55.toDp()),
- Constraints(30, 30, 35, 35)
- )
- }
-
- @Test
- fun testMeasurementConstraints_compulsorySatisfiable() = with(density) {
- assertConstraints(
- Constraints(10, 30, 15, 35),
Modifier.width(20.toDp()),
Constraints(20, 20, 15, 35)
)
@@ -537,46 +469,114 @@
}
@Test
- fun testMeasurementConstraints_compulsoryUnsatisfiable() = with(density) {
+ fun testMeasurementConstraints_preferredUnsatisfiable() = with(density) {
assertConstraints(
Constraints(20, 40, 15, 35),
Modifier.width(15.toDp()),
- Constraints(15, 15, 15, 35)
+ Constraints(20, 20, 15, 35)
)
assertConstraints(
Constraints(10, 30, 15, 35),
Modifier.height(10.toDp()),
- Constraints(10, 30, 10, 10)
+ Constraints(10, 30, 15, 15)
)
assertConstraints(
Constraints(10, 30, 15, 35),
Modifier.size(40.toDp()),
- Constraints(40, 40, 40, 40)
+ Constraints(30, 30, 35, 35)
)
assertConstraints(
Constraints(20, 30, 15, 35),
Modifier.widthIn(10.toDp(), 15.toDp()),
- Constraints(10, 15, 15, 35)
+ Constraints(20, 20, 15, 35)
)
assertConstraints(
Constraints(10, 30, 15, 35),
Modifier.heightIn(5.toDp(), 10.toDp()),
- Constraints(10, 30, 5, 10)
+ Constraints(10, 30, 15, 15)
)
assertConstraints(
Constraints(10, 30, 15, 35),
Modifier.sizeIn(40.toDp(), 50.toDp(), 45.toDp(), 55.toDp()),
+ Constraints(30, 30, 35, 35)
+ )
+ }
+
+ @Test
+ fun testMeasurementConstraints_compulsorySatisfiable() = with(density) {
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredWidth(20.toDp()),
+ Constraints(20, 20, 15, 35)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredHeight(20.toDp()),
+ Constraints(10, 30, 20, 20)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredSize(20.toDp()),
+ Constraints(20, 20, 20, 20)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredWidthIn(20.toDp(), 25.toDp()),
+ Constraints(20, 25, 15, 35)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredHeightIn(20.toDp(), 25.toDp()),
+ Constraints(10, 30, 20, 25)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredSizeIn(20.toDp(), 20.toDp(), 25.toDp(), 25.toDp()),
+ Constraints(20, 25, 20, 25)
+ )
+ }
+
+ @Test
+ fun testMeasurementConstraints_compulsoryUnsatisfiable() = with(density) {
+ assertConstraints(
+ Constraints(20, 40, 15, 35),
+ Modifier.requiredWidth(15.toDp()),
+ Constraints(15, 15, 15, 35)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredHeight(10.toDp()),
+ Constraints(10, 30, 10, 10)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredSize(40.toDp()),
+ Constraints(40, 40, 40, 40)
+ )
+ assertConstraints(
+ Constraints(20, 30, 15, 35),
+ Modifier.requiredWidthIn(10.toDp(), 15.toDp()),
+ Constraints(10, 15, 15, 35)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredHeightIn(5.toDp(), 10.toDp()),
+ Constraints(10, 30, 5, 10)
+ )
+ assertConstraints(
+ Constraints(10, 30, 15, 35),
+ Modifier.requiredSizeIn(40.toDp(), 50.toDp(), 45.toDp(), 55.toDp()),
Constraints(40, 45, 50, 55)
)
// When one dimension is unspecified and the other contradicts the incoming constraint.
assertConstraints(
Constraints(10, 10, 10, 10),
- Modifier.sizeIn(20.toDp(), 30.toDp(), Dp.Unspecified, Dp.Unspecified),
+ Modifier.requiredSizeIn(20.toDp(), 30.toDp(), Dp.Unspecified, Dp.Unspecified),
Constraints(20, 20, 30, 30)
)
assertConstraints(
Constraints(40, 40, 40, 40),
- Modifier.sizeIn(Dp.Unspecified, Dp.Unspecified, 20.toDp(), 30.toDp()),
+ Modifier.requiredSizeIn(Dp.Unspecified, Dp.Unspecified, 20.toDp(), 30.toDp()),
Constraints(20, 20, 30, 30)
)
}
@@ -589,7 +589,7 @@
Layout(
{},
Modifier.wrapContentSize()
- .sizeIn(maxWidth = 30.toDp(), maxHeight = 40.toDp())
+ .requiredSizeIn(maxWidth = 30.toDp(), maxHeight = 40.toDp())
.defaultMinSize(minWidth = 10.toDp(), minHeight = 20.toDp())
) { _, constraints ->
assertEquals(10, constraints.minWidth)
@@ -602,7 +602,7 @@
// Constraints are not applied.
Layout(
{},
- Modifier.sizeIn(
+ Modifier.requiredSizeIn(
minWidth = 10.toDp(),
minHeight = 20.toDp(),
maxWidth = 100.toDp(),
@@ -622,7 +622,7 @@
// Defaults values are not changing.
Layout(
{},
- Modifier.sizeIn(
+ Modifier.requiredSizeIn(
minWidth = 10.toDp(),
minHeight = 20.toDp(),
maxWidth = 100.toDp(),
@@ -647,7 +647,7 @@
Layout(
{},
Modifier.wrapContentSize()
- .sizeIn(maxWidth = 30.toDp(), maxHeight = 40.toDp())
+ .requiredSizeIn(maxWidth = 30.toDp(), maxHeight = 40.toDp())
.defaultMinSize(minWidth = 70.toDp(), minHeight = 80.toDp())
) { _, constraints ->
assertEquals(30, constraints.minWidth)
@@ -665,7 +665,7 @@
fun testMinWidthModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredWidthIn(min = 10.toDp())) {
+ Container(Modifier.widthIn(min = 10.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -697,7 +697,7 @@
fun testMaxWidthModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredWidthIn(max = 20.toDp())) {
+ Container(Modifier.widthIn(max = 20.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -729,7 +729,7 @@
fun testMinHeightModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredHeightIn(min = 30.toDp())) {
+ Container(Modifier.heightIn(min = 30.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -761,7 +761,7 @@
fun testMaxHeightModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredHeightIn(max = 40.toDp())) {
+ Container(Modifier.heightIn(max = 40.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -793,7 +793,7 @@
fun testWidthModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredWidth(10.toDp())) {
+ Container(Modifier.width(10.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -825,7 +825,7 @@
fun testHeightModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredHeight(10.toDp())) {
+ Container(Modifier.height(10.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -858,7 +858,7 @@
testIntrinsics(
@Composable {
Container(
- Modifier.preferredSizeIn(
+ Modifier.sizeIn(
minWidth = 10.toDp(),
maxWidth = 20.toDp(),
minHeight = 30.toDp(),
@@ -896,7 +896,7 @@
fun testMinSizeModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredSizeIn(minWidth = 20.toDp(), minHeight = 30.toDp())) {
+ Container(Modifier.sizeIn(minWidth = 20.toDp(), minHeight = 30.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -928,7 +928,7 @@
fun testMaxSizeModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredSizeIn(maxWidth = 40.toDp(), maxHeight = 50.toDp())) {
+ Container(Modifier.sizeIn(maxWidth = 40.toDp(), maxHeight = 50.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -960,7 +960,7 @@
fun testPreferredSizeModifier_hasCorrectIntrinsicMeasurements() = with(density) {
testIntrinsics(
@Composable {
- Container(Modifier.preferredSize(40.toDp(), 50.toDp())) {
+ Container(Modifier.size(40.toDp(), 50.toDp())) {
Container(Modifier.aspectRatio(1f)) { }
}
}
@@ -992,10 +992,10 @@
fun testFillModifier_correctSize() = with(density) {
val parentWidth = 100
val parentHeight = 80
- val parentModifier = Modifier.size(parentWidth.toDp(), parentHeight.toDp())
+ val parentModifier = Modifier.requiredSize(parentWidth.toDp(), parentHeight.toDp())
val childWidth = 40
val childHeight = 30
- val childModifier = Modifier.preferredSize(childWidth.toDp(), childHeight.toDp())
+ val childModifier = Modifier.size(childWidth.toDp(), childHeight.toDp())
assertEquals(
IntSize(childWidth, childHeight),
@@ -1019,10 +1019,10 @@
fun testFractionalFillModifier_correctSize_whenSmallerChild() = with(density) {
val parentWidth = 100
val parentHeight = 80
- val parentModifier = Modifier.size(parentWidth.toDp(), parentHeight.toDp())
+ val parentModifier = Modifier.requiredSize(parentWidth.toDp(), parentHeight.toDp())
val childWidth = 40
val childHeight = 30
- val childModifier = Modifier.preferredSize(childWidth.toDp(), childHeight.toDp())
+ val childModifier = Modifier.size(childWidth.toDp(), childHeight.toDp())
assertEquals(
IntSize(childWidth, childHeight),
@@ -1046,10 +1046,10 @@
fun testFractionalFillModifier_correctSize_whenLargerChild() = with(density) {
val parentWidth = 100
val parentHeight = 80
- val parentModifier = Modifier.size(parentWidth.toDp(), parentHeight.toDp())
+ val parentModifier = Modifier.requiredSize(parentWidth.toDp(), parentHeight.toDp())
val childWidth = 70
val childHeight = 50
- val childModifier = Modifier.preferredSize(childWidth.toDp(), childHeight.toDp())
+ val childModifier = Modifier.size(childWidth.toDp(), childHeight.toDp())
assertEquals(
IntSize(childWidth, childHeight),
@@ -1075,7 +1075,7 @@
val childMinHeight = 30
val childMaxWidth = 60
val childMaxHeight = 50
- val childModifier = Modifier.sizeIn(
+ val childModifier = Modifier.requiredSizeIn(
childMinWidth.toDp(),
childMinHeight.toDp(),
childMaxWidth.toDp(),
@@ -1137,6 +1137,31 @@
@Test
fun testInspectableParameter() {
+ checkModifier(Modifier.requiredWidth(200.0.dp), "requiredWidth", 200.0.dp, listOf())
+ checkModifier(Modifier.requiredHeight(300.0.dp), "requiredHeight", 300.0.dp, listOf())
+ checkModifier(Modifier.requiredSize(400.0.dp), "requiredSize", 400.0.dp, listOf())
+ checkModifier(
+ Modifier.requiredSize(100.0.dp, 200.0.dp), "requiredSize", null,
+ listOf(
+ ValueElement("width", 100.0.dp),
+ ValueElement("height", 200.0.dp)
+ )
+ )
+ checkModifier(
+ Modifier.requiredWidthIn(100.0.dp, 200.0.dp), "requiredWidthIn", null,
+ listOf(ValueElement("min", 100.0.dp), ValueElement("max", 200.0.dp))
+ )
+ checkModifier(
+ Modifier.requiredHeightIn(10.0.dp, 200.0.dp), "requiredHeightIn", null,
+ listOf(ValueElement("min", 10.0.dp), ValueElement("max", 200.0.dp))
+ )
+ checkModifier(
+ Modifier.requiredSizeIn(10.dp, 20.dp, 30.dp, 40.dp), "requiredSizeIn", null,
+ listOf(
+ ValueElement("minWidth", 10.dp), ValueElement("minHeight", 20.dp),
+ ValueElement("maxWidth", 30.dp), ValueElement("maxHeight", 40.dp)
+ )
+ )
checkModifier(Modifier.width(200.0.dp), "width", 200.0.dp, listOf())
checkModifier(Modifier.height(300.0.dp), "height", 300.0.dp, listOf())
checkModifier(Modifier.size(400.0.dp), "size", 400.0.dp, listOf())
@@ -1159,28 +1184,6 @@
ValueElement("maxWidth", 30.dp), ValueElement("maxHeight", 40.dp)
)
)
- checkModifier(Modifier.preferredWidth(200.0.dp), "preferredWidth", 200.0.dp, listOf())
- checkModifier(Modifier.preferredHeight(300.0.dp), "preferredHeight", 300.0.dp, listOf())
- checkModifier(Modifier.preferredSize(400.0.dp), "preferredSize", 400.0.dp, listOf())
- checkModifier(
- Modifier.preferredSize(100.0.dp, 200.0.dp), "preferredSize", null,
- listOf(ValueElement("width", 100.0.dp), ValueElement("height", 200.0.dp))
- )
- checkModifier(
- Modifier.preferredWidthIn(100.0.dp, 200.0.dp), "preferredWidthIn", null,
- listOf(ValueElement("min", 100.0.dp), ValueElement("max", 200.0.dp))
- )
- checkModifier(
- Modifier.preferredHeightIn(10.0.dp, 200.0.dp), "preferredHeightIn", null,
- listOf(ValueElement("min", 10.0.dp), ValueElement("max", 200.0.dp))
- )
- checkModifier(
- Modifier.preferredSizeIn(10.dp, 20.dp, 30.dp, 40.dp), "preferredSizeIn", null,
- listOf(
- ValueElement("minWidth", 10.dp), ValueElement("minHeight", 20.dp),
- ValueElement("maxWidth", 30.dp), ValueElement("maxHeight", 40.dp)
- )
- )
checkModifier(
Modifier.fillMaxWidth(), "fillMaxWidth", null,
@@ -1350,7 +1353,7 @@
Container(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.BottomEnd)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize, childPosition, positionedLatch)
) {
}
@@ -1391,7 +1394,7 @@
Container(
Modifier.fillMaxSize()
.wrapContentWidth(Alignment.End)
- .preferredWidth(sizeDp)
+ .width(sizeDp)
.saveLayoutInfo(childSize, childPosition, positionedLatch)
) {
}
@@ -1421,21 +1424,21 @@
Box(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize().wrapContentSize(Alignment.TopStart)) {
Box(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.saveLayoutInfo(childSize[0], childPosition[0], positionedLatch)
) {
}
}
Box(Modifier.fillMaxSize().wrapContentHeight(Alignment.CenterVertically)) {
Box(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.saveLayoutInfo(childSize[1], childPosition[1], positionedLatch)
) {
}
}
Box(Modifier.fillMaxSize().wrapContentSize(Alignment.BottomEnd)) {
Box(
- Modifier.preferredSize(sizeDp)
+ Modifier.size(sizeDp)
.saveLayoutInfo(childSize[2], childPosition[2], positionedLatch)
) {
}
@@ -1475,7 +1478,7 @@
Container(Modifier.saveLayoutInfo(size, Ref(), latch)) {
Container(
Modifier.wrapContentSize(Alignment.TopStart)
- .preferredSize(contentSize)
+ .size(contentSize)
) {}
}
}
@@ -1503,7 +1506,7 @@
) {
Container(
Modifier.wrapContentSize(Alignment.BottomEnd)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize, childPosition, positionedLatch)
) {
}
@@ -1549,7 +1552,7 @@
content = {
Container(
Modifier.wrapContentSize(Alignment.Center)
- .preferredSize(sizeDp)
+ .size(sizeDp)
.saveLayoutInfo(childSize, childPosition, positionedLatch)
) {
}
@@ -1591,7 +1594,7 @@
val positionedLatch = CountDownLatch(4)
show {
Box(
- Modifier.size(outerSize.toDp())
+ Modifier.requiredSize(outerSize.toDp())
.onGloballyPositioned {
assertEquals(outerSize, it.size.width.toFloat())
positionedLatch.countDown()
@@ -1599,7 +1602,7 @@
) {
Box(
Modifier.wrapContentSize(Alignment.BottomEnd, unbounded = true)
- .size(innerSize.toDp())
+ .requiredSize(innerSize.toDp())
.onGloballyPositioned {
assertEquals(
Offset(outerSize - innerSize, outerSize - innerSize),
@@ -1610,7 +1613,7 @@
)
Box(
Modifier.wrapContentWidth(Alignment.End, unbounded = true)
- .size(innerSize.toDp())
+ .requiredSize(innerSize.toDp())
.onGloballyPositioned {
assertEquals(outerSize - innerSize, it.positionInParent.x)
positionedLatch.countDown()
@@ -1618,7 +1621,7 @@
)
Box(
Modifier.wrapContentHeight(Alignment.Bottom, unbounded = true)
- .size(innerSize.toDp())
+ .requiredSize(innerSize.toDp())
.onGloballyPositioned {
assertEquals(outerSize - innerSize, it.positionInParent.y)
positionedLatch.countDown()
@@ -1722,13 +1725,13 @@
Layout(
content = {
Container(
- Modifier.preferredSize(parentSize)
+ Modifier.size(parentSize)
.saveLayoutInfo(alignSize, alignPosition, positionedLatch)
) {
Container(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.BottomEnd)
- .preferredSize(childSizeDp)
+ .size(childSizeDp)
.saveLayoutInfo(childSize, childPosition, positionedLatch)
) {
}
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SpacerTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SpacerTest.kt
index 9d1dc2b..cb7da5b 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SpacerTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SpacerTest.kt
@@ -49,7 +49,7 @@
show {
Container(constraints = bigConstraints) {
Spacer(
- Modifier.preferredSize(width = width, height = height)
+ Modifier.size(width = width, height = height)
.onGloballyPositioned { position: LayoutCoordinates ->
size = position.size
drawLatch.countDown()
@@ -83,7 +83,7 @@
)
) {
Spacer(
- Modifier.preferredSize(width = width, height = height)
+ Modifier.size(width = width, height = height)
.onGloballyPositioned { position: LayoutCoordinates ->
size = position.size
drawLatch.countDown()
@@ -109,7 +109,7 @@
show {
Container(constraints = bigConstraints) {
Spacer(
- Modifier.preferredWidth(width).onGloballyPositioned { position ->
+ Modifier.width(width).onGloballyPositioned { position ->
size = position.size
drawLatch.countDown()
}
@@ -141,7 +141,7 @@
)
) {
Spacer(
- Modifier.preferredWidth(width)
+ Modifier.width(width)
.onGloballyPositioned { position: LayoutCoordinates ->
size = position.size
drawLatch.countDown()
@@ -167,7 +167,7 @@
show {
Container(constraints = bigConstraints) {
Spacer(
- Modifier.preferredHeight(height)
+ Modifier.height(height)
.onGloballyPositioned { position: LayoutCoordinates ->
size = position.size
drawLatch.countDown()
@@ -200,7 +200,7 @@
)
) {
Spacer(
- Modifier.preferredHeight(height)
+ Modifier.height(height)
.onGloballyPositioned { position: LayoutCoordinates ->
size = position.size
drawLatch.countDown()
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Column.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Column.kt
index 0a63f78..674d2cd 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Column.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Column.kt
@@ -40,10 +40,10 @@
*
* When none of its children have weights, a [Column] will be as small as possible to fit its
* children one on top of the other. In order to change the height of the [Column], use the
- * [Modifier.height] modifiers; e.g. to make it fill the available height [Modifier.fillMaxHeight]
+ * [Modifier.requiredHeight] modifiers; e.g. to make it fill the available height [Modifier.fillMaxHeight]
* can be used. If at least one child of a [Column] has a [weight][ColumnScope.weight],
* the [Column] will fill the available height, so there is no need for [Modifier.fillMaxHeight].
- * However, if [Column]'s size should be limited, the [Modifier.height] or [Modifier.size] layout
+ * However, if [Column]'s size should be limited, the [Modifier.requiredHeight] or [Modifier.requiredSize] layout
* modifiers should be applied.
*
* When the size of the [Column] is larger than the sum of its children sizes, a
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Intrinsic.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Intrinsic.kt
index 538c4f2..8cf81e8 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Intrinsic.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Intrinsic.kt
@@ -33,8 +33,8 @@
* the content. The incoming measurement [Constraints] may override this value, forcing the content
* to be either smaller or larger.
*
- * See [preferredHeight] for options of sizing to intrinsic height.
- * Also see [preferredWidth] and [preferredWidthIn] for other options to set the preferred width.
+ * See [height] for options of sizing to intrinsic height.
+ * Also see [width] and [widthIn] for other options to set the preferred width.
*
* Example usage for min intrinsic:
* @sample androidx.compose.foundation.layout.samples.SameWidthBoxes
@@ -44,7 +44,7 @@
*/
@ExperimentalLayout
@Stable
-fun Modifier.preferredWidth(intrinsicSize: IntrinsicSize) = when (intrinsicSize) {
+fun Modifier.width(intrinsicSize: IntrinsicSize) = when (intrinsicSize) {
IntrinsicSize.Min -> this.then(PreferredMinIntrinsicWidthModifier)
IntrinsicSize.Max -> this.then(PreferredMaxIntrinsicWidthModifier)
}
@@ -54,8 +54,8 @@
* the content. The incoming measurement [Constraints] may override this value, forcing the content
* to be either smaller or larger.
*
- * See [preferredWidth] for other options of sizing to intrinsic width.
- * Also see [preferredHeight] and [preferredHeightIn] for other options to set the preferred height.
+ * See [width] for other options of sizing to intrinsic width.
+ * Also see [height] and [heightIn] for other options to set the preferred height.
*
* Example usage for min intrinsic:
* @sample androidx.compose.foundation.layout.samples.MatchParentDividerForText
@@ -65,13 +65,13 @@
*/
@ExperimentalLayout
@Stable
-fun Modifier.preferredHeight(intrinsicSize: IntrinsicSize) = when (intrinsicSize) {
+fun Modifier.height(intrinsicSize: IntrinsicSize) = when (intrinsicSize) {
IntrinsicSize.Min -> this.then(PreferredMinIntrinsicHeightModifier)
IntrinsicSize.Max -> this.then(PreferredMaxIntrinsicHeightModifier)
}
/**
- * Intrinsic size used in [preferredWidth] or [preferredHeight] which can refer to width or height.
+ * Intrinsic size used in [width] or [height] which can refer to width or height.
*/
enum class IntrinsicSize { Min, Max }
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Row.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Row.kt
index 7ff9676a..008b870c 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Row.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Row.kt
@@ -41,10 +41,10 @@
*
* When none of its children have weights, a [Row] will be as small as possible to fit its
* children one next to the other. In order to change the width of the [Row], use the
- * [Modifier.width] modifiers; e.g. to make it fill the available width [Modifier.fillMaxWidth]
+ * [Modifier.requiredWidth] modifiers; e.g. to make it fill the available width [Modifier.fillMaxWidth]
* can be used. If at least one child of a [Row] has a [weight][RowScope.weight], the [Row] will
* fill the available width, so there is no need for [Modifier.fillMaxWidth]. However, if [Row]'s
- * size should be limited, the [Modifier.width] or [Modifier.size] layout modifiers should be
+ * size should be limited, the [Modifier.requiredWidth] or [Modifier.requiredSize] layout modifiers should be
* applied.
*
* When the size of the [Row] is larger than the sum of its children sizes, a
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Size.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Size.kt
index 87a45f4..af08e02 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Size.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Size.kt
@@ -44,20 +44,20 @@
* [Constraints] may override this value, forcing the content to be either smaller or larger.
*
* For a modifier that sets the width of the content regardless of the incoming constraints see
- * [Modifier.width]. See [preferredHeight] or [preferredSize] to set other preferred dimensions.
- * See [preferredWidthIn], [preferredHeightIn] or [preferredSizeIn] to set a preferred size range.
+ * [Modifier.requiredWidth]. See [height] or [size] to set other preferred dimensions.
+ * See [widthIn], [heightIn] or [sizeIn] to set a preferred size range.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimplePreferredWidthModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleWidthModifier
*/
@Stable
-fun Modifier.preferredWidth(width: Dp) = this.then(
+fun Modifier.width(width: Dp) = this.then(
SizeModifier(
minWidth = width,
maxWidth = width,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredWidth"
+ name = "width"
value = width
}
)
@@ -68,20 +68,20 @@
* [Constraints] may override this value, forcing the content to be either smaller or larger.
*
* For a modifier that sets the height of the content regardless of the incoming constraints see
- * [Modifier.height]. See [preferredWidth] or [preferredSize] to set other preferred dimensions.
- * See [preferredWidthIn], [preferredHeightIn] or [preferredSizeIn] to set a preferred size range.
+ * [Modifier.requiredHeight]. See [width] or [size] to set other preferred dimensions.
+ * See [widthIn], [heightIn] or [sizeIn] to set a preferred size range.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimplePreferredHeightModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleHeightModifier
*/
@Stable
-fun Modifier.preferredHeight(height: Dp) = this.then(
+fun Modifier.height(height: Dp) = this.then(
SizeModifier(
minHeight = height,
maxHeight = height,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredHeight"
+ name = "height"
value = height
}
)
@@ -92,14 +92,14 @@
* [Constraints] may override this value, forcing the content to be either smaller or larger.
*
* For a modifier that sets the size of the content regardless of the incoming constraints, see
- * [Modifier.size]. See [preferredWidth] or [preferredHeight] to set width or height alone.
- * See [preferredWidthIn], [preferredHeightIn] or [preferredSizeIn] to set a preferred size range.
+ * [Modifier.requiredSize]. See [width] or [height] to set width or height alone.
+ * See [widthIn], [heightIn] or [sizeIn] to set a preferred size range.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimplePreferredSizeModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleSizeModifier
*/
@Stable
-fun Modifier.preferredSize(size: Dp) = this.then(
+fun Modifier.size(size: Dp) = this.then(
SizeModifier(
minWidth = size,
maxWidth = size,
@@ -107,7 +107,7 @@
maxHeight = size,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredSize"
+ name = "size"
value = size
}
)
@@ -119,14 +119,14 @@
* larger.
*
* For a modifier that sets the size of the content regardless of the incoming constraints, see
- * [Modifier.size]. See [preferredWidth] or [preferredHeight] to set width or height alone.
- * See [preferredWidthIn], [preferredHeightIn] or [preferredSizeIn] to set a preferred size range.
+ * [Modifier.requiredSize]. See [width] or [height] to set width or height alone.
+ * See [widthIn], [heightIn] or [sizeIn] to set a preferred size range.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimplePreferredSizeModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleSizeModifier
*/
@Stable
-fun Modifier.preferredSize(width: Dp, height: Dp) = this.then(
+fun Modifier.size(width: Dp, height: Dp) = this.then(
SizeModifier(
minWidth = width,
maxWidth = width,
@@ -134,7 +134,7 @@
maxHeight = height,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredSize"
+ name = "size"
properties["width"] = width
properties["height"] = height
}
@@ -148,7 +148,7 @@
* to the preferred size.
*/
@Stable
-fun Modifier.preferredWidthIn(
+fun Modifier.widthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
) = this.then(
@@ -157,7 +157,7 @@
maxWidth = max,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredWidthIn"
+ name = "widthIn"
properties["min"] = min
properties["max"] = max
}
@@ -171,7 +171,7 @@
* to the preferred size.
*/
@Stable
-fun Modifier.preferredHeightIn(
+fun Modifier.heightIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
) = this.then(
@@ -180,7 +180,7 @@
maxHeight = max,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredHeightIn"
+ name = "heightIn"
properties["min"] = min
properties["max"] = max
}
@@ -189,12 +189,12 @@
/**
* Constrain the width of the content to be between [minWidth]dp and [maxWidth]dp and the height
- * of the content to be between [minHeight] and [maxHeight] as permitted by the incoming
+ * of the content to be between [minHeight]dp and [maxHeight]dp as permitted by the incoming
* measurement [Constraints]. If the incoming constraints are more restrictive the requested size
* will obey the incoming constraints and attempt to be as close as possible to the preferred size.
*/
@Stable
-fun Modifier.preferredSizeIn(
+fun Modifier.sizeIn(
minWidth: Dp = Dp.Unspecified,
minHeight: Dp = Dp.Unspecified,
maxWidth: Dp = Dp.Unspecified,
@@ -207,7 +207,7 @@
maxHeight = maxHeight,
enforceIncoming = true,
inspectorInfo = debugInspectorInfo {
- name = "preferredSizeIn"
+ name = "sizeIn"
properties["minWidth"] = minWidth
properties["minHeight"] = minHeight
properties["maxWidth"] = maxWidth
@@ -224,21 +224,21 @@
* centered on the space assigned to the child by the parent layout under the assumption that
* [Constraints] were respected.
*
- * See [widthIn] and [sizeIn] to set a size range.
- * See [preferredWidth] to set a preferred width, which is only respected when the incoming
+ * See [requiredWidthIn] and [requiredSizeIn] to set a size range.
+ * See [width] to set a preferred width, which is only respected when the incoming
* constraints allow it.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimpleWidthModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleRequiredWidthModifier
*/
@Stable
-fun Modifier.width(width: Dp) = this.then(
+fun Modifier.requiredWidth(width: Dp) = this.then(
SizeModifier(
minWidth = width,
maxWidth = width,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "width"
+ name = "requiredWidth"
value = width
}
)
@@ -252,21 +252,21 @@
* centered on the space assigned to the child by the parent layout under the assumption that
* [Constraints] were respected.
*
- * See [heightIn] and [sizeIn] to set a size range.
- * See [preferredHeight] to set a preferred height, which is only respected when the incoming
+ * See [requiredHeightIn] and [requiredSizeIn] to set a size range.
+ * See [height] to set a preferred height, which is only respected when the incoming
* constraints allow it.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimpleHeightModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleRequiredHeightModifier
*/
@Stable
-fun Modifier.height(height: Dp) = this.then(
+fun Modifier.requiredHeight(height: Dp) = this.then(
SizeModifier(
minHeight = height,
maxHeight = height,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "height"
+ name = "requiredHeight"
value = height
}
)
@@ -280,15 +280,15 @@
* centered on the space assigned to the child by the parent layout under the assumption that
* [Constraints] were respected.
*
- * See [sizeIn] to set a size range.
- * See [preferredSize] to set a preferred size, which is only respected when the incoming
+ * See [requiredSizeIn] to set a size range.
+ * See [size] to set a preferred size, which is only respected when the incoming
* constraints allow it.
*
* Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimpleSizeModifier
+ * @sample androidx.compose.foundation.layout.samples.SimpleRequiredSizeModifier
*/
@Stable
-fun Modifier.size(size: Dp) = this.then(
+fun Modifier.requiredSize(size: Dp) = this.then(
SizeModifier(
minWidth = size,
maxWidth = size,
@@ -296,7 +296,7 @@
maxHeight = size,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "size"
+ name = "requiredSize"
value = size
}
)
@@ -310,15 +310,12 @@
* centered on the space assigned to the child by the parent layout under the assumption that
* [Constraints] were respected.
*
- * See [sizeIn] to set a size range.
- * See [preferredSize] to set a preferred size, which is only respected when the incoming
+ * See [requiredSizeIn] to set a size range.
+ * See [size] to set a preferred size, which is only respected when the incoming
* constraints allow it.
- *
- * Example usage:
- * @sample androidx.compose.foundation.layout.samples.SimpleWidthModifier
*/
@Stable
-fun Modifier.size(width: Dp, height: Dp) = this.then(
+fun Modifier.requiredSize(width: Dp, height: Dp) = this.then(
SizeModifier(
minWidth = width,
maxWidth = width,
@@ -326,7 +323,7 @@
maxHeight = height,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "size"
+ name = "requiredSize"
properties["width"] = width
properties["height"] = height
}
@@ -341,7 +338,7 @@
* the child by the parent layout under the assumption that [Constraints] were respected.
*/
@Stable
-fun Modifier.widthIn(
+fun Modifier.requiredWidthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
) = this.then(
@@ -350,7 +347,7 @@
maxWidth = max,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "widthIn"
+ name = "requiredWidthIn"
properties["min"] = min
properties["max"] = max
}
@@ -365,7 +362,7 @@
* the child by the parent layout under the assumption that [Constraints] were respected.
*/
@Stable
-fun Modifier.heightIn(
+fun Modifier.requiredHeightIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
) = this.then(
@@ -374,7 +371,7 @@
maxHeight = max,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "heightIn"
+ name = "requiredHeightIn"
properties["min"] = min
properties["max"] = max
}
@@ -390,7 +387,7 @@
* the child by the parent layout under the assumption that [Constraints] were respected.
*/
@Stable
-fun Modifier.sizeIn(
+fun Modifier.requiredSizeIn(
minWidth: Dp = Dp.Unspecified,
minHeight: Dp = Dp.Unspecified,
maxWidth: Dp = Dp.Unspecified,
@@ -403,7 +400,7 @@
maxHeight = maxHeight,
enforceIncoming = false,
inspectorInfo = debugInspectorInfo {
- name = "sizeIn"
+ name = "requiredSizeIn"
properties["minWidth"] = minWidth
properties["minHeight"] = minHeight
properties["maxWidth"] = maxWidth
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt
index 4bf16cd..bf46470 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt
@@ -21,8 +21,8 @@
import androidx.compose.ui.Modifier
/**
- * Component that represents an empty space layout, whose size can be defined using [Modifier.width],
- * [Modifier.height] and [Modifier.size] modifiers.
+ * Component that represents an empty space layout, whose size can be defined using
+ * [Modifier.width], [Modifier.height] and [Modifier.size] modifiers.
*
* @sample androidx.compose.foundation.layout.samples.SpacerExample
*
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/DrawModifiersDemo.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/DrawModifiersDemo.kt
index 639ca856..12d3471 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/DrawModifiersDemo.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/DrawModifiersDemo.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.samples.BorderSample
import androidx.compose.foundation.samples.BorderSampleWithBrush
import androidx.compose.foundation.samples.BorderSampleWithDataClass
@@ -35,14 +35,14 @@
Row {
Column(Modifier.weight(1f, true).padding(10.dp)) {
BorderSample()
- Spacer(Modifier.preferredHeight(30.dp))
+ Spacer(Modifier.height(30.dp))
BorderSampleWithBrush()
- Spacer(Modifier.preferredHeight(30.dp))
+ Spacer(Modifier.height(30.dp))
BorderSampleWithDataClass()
}
Column(Modifier.weight(1f).padding(10.dp)) {
DrawBackgroundColor()
- Spacer(Modifier.preferredHeight(30.dp))
+ Spacer(Modifier.height(30.dp))
DrawBackgroundShapedBrush()
}
}
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/HighLevelGesturesDemo.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/HighLevelGesturesDemo.kt
index 284fa92..6d9d2c3 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/HighLevelGesturesDemo.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/HighLevelGesturesDemo.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.samples.DraggableSample
import androidx.compose.foundation.samples.FocusableSample
import androidx.compose.foundation.samples.ScrollableSample
@@ -31,11 +31,11 @@
fun HighLevelGesturesDemo() {
Column {
DraggableSample()
- Spacer(Modifier.preferredHeight(50.dp))
+ Spacer(Modifier.height(50.dp))
ScrollableSample()
- Spacer(Modifier.preferredHeight(50.dp))
+ Spacer(Modifier.height(50.dp))
ZoomableSample()
- Spacer(Modifier.preferredHeight(50.dp))
+ Spacer(Modifier.height(50.dp))
FocusableSample()
}
}
\ No newline at end of file
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
index 13018675..c808c7f 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
@@ -29,10 +29,10 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredWidth
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.GridCells
import androidx.compose.foundation.lazy.LazyColumn
@@ -213,7 +213,7 @@
private fun Square(index: Int) {
val width = remember { Random.nextInt(50, 150).dp }
Box(
- Modifier.preferredWidth(width).fillMaxHeight().background(colors[index % colors.size]),
+ Modifier.width(width).fillMaxHeight().background(colors[index % colors.size]),
contentAlignment = Alignment.Center
) {
Text(index.toString())
@@ -245,7 +245,7 @@
Text(
"$it",
Modifier
- .size(100.dp)
+ .requiredSize(100.dp)
.background(if (it % 2 == 0) Color.LightGray else Color.Transparent)
.padding(16.dp)
)
@@ -304,7 +304,7 @@
val items = listOf(Color.Cyan, Color.Blue, Color.Magenta)
itemsIndexed(items) { index, item ->
Box(
- modifier = Modifier.background(item).size(40.dp),
+ modifier = Modifier.background(item).requiredSize(40.dp),
contentAlignment = Alignment.Center
) {
Text("$index", fontSize = 30.sp)
@@ -341,7 +341,7 @@
val item = @Composable {
Box(
Modifier
- .height(200.dp)
+ .requiredHeight(200.dp)
.fillMaxWidth()
.background(Color.Red)
.border(1.dp, Color.Cyan)
@@ -409,7 +409,7 @@
Text(
"$index",
Modifier
- .height(200.dp)
+ .requiredHeight(200.dp)
.fillMaxWidth()
.background(Color.Red)
.border(1.dp, Color.Cyan)
@@ -455,7 +455,7 @@
private fun NestedLazyDemo() {
val item = @Composable { index: Int ->
Box(
- Modifier.padding(16.dp).size(200.dp).background(Color.LightGray),
+ Modifier.padding(16.dp).requiredSize(200.dp).background(Color.LightGray),
contentAlignment = Alignment.Center
) {
var state by rememberSaveable { mutableStateOf(0) }
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/SuspendingGesturesDemo.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/SuspendingGesturesDemo.kt
index 7102e80..2490b34 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/SuspendingGesturesDemo.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/SuspendingGesturesDemo.kt
@@ -33,12 +33,12 @@
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.integration.demos.common.ComposableDemo
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -120,11 +120,11 @@
Column {
Text("The boxes change color when you tap the white box.")
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.pointerInput(Unit) {
detectTapGestures(
tapHue = anotherRandomHue(tapHue) },
@@ -145,65 +145,65 @@
) {
Text("Tap, double-tap, or long-press", Modifier.align(Alignment.Center))
}
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Row {
Box(
Modifier
- .preferredSize(50.dp)
+ .size(50.dp)
.background(hueToColor(tapHue))
.border(BorderStroke(2.dp, Color.Black))
)
Text("Changes color on tap", Modifier.align(Alignment.CenterVertically))
}
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Row {
Box(
Modifier
- .preferredSize(50.dp)
+ .size(50.dp)
.clipToBounds()
.background(hueToColor(doubleTapHue))
.border(BorderStroke(2.dp, Color.Black))
)
Text("Changes color on double-tap", Modifier.align(Alignment.CenterVertically))
}
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Row {
Box(
Modifier
- .preferredSize(50.dp)
+ .size(50.dp)
.clipToBounds()
.background(hueToColor(longPressHue))
.border(BorderStroke(2.dp, Color.Black))
)
Text("Changes color on long press", Modifier.align(Alignment.CenterVertically))
}
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Row {
Box(
Modifier
- .preferredSize(50.dp)
+ .size(50.dp)
.clipToBounds()
.background(hueToColor(pressHue))
.border(BorderStroke(2.dp, Color.Black))
)
Text("Changes color on press", Modifier.align(Alignment.CenterVertically))
}
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Row {
Box(
Modifier
- .preferredSize(50.dp)
+ .size(50.dp)
.clipToBounds()
.background(hueToColor(releaseHue))
.border(BorderStroke(2.dp, Color.Black))
)
Text("Changes color on release", Modifier.align(Alignment.CenterVertically))
}
- Spacer(Modifier.size(5.dp))
+ Spacer(Modifier.requiredSize(5.dp))
Row {
Box(
Modifier
- .preferredSize(50.dp)
+ .size(50.dp)
.clipToBounds()
.background(hueToColor(cancelHue))
.border(BorderStroke(2.dp, Color.Black))
@@ -225,7 +225,7 @@
var offset by remember { mutableStateOf(0.dp) }
Box(
Modifier.offset(offset, 0.dp)
- .size(50.dp)
+ .requiredSize(50.dp)
.background(Color.Blue)
.pointerInput(Unit) {
detectHorizontalDragGestures { change, dragDistance ->
@@ -253,7 +253,7 @@
var offset by remember { mutableStateOf(0.dp) }
Box(
Modifier.offset(0.dp, offset)
- .size(50.dp)
+ .requiredSize(50.dp)
.background(Color.Red)
.pointerInput(Unit) {
detectVerticalDragGestures { change, dragDistance ->
@@ -270,7 +270,7 @@
)
}
Box(
- Modifier.height(50.dp)
+ Modifier.requiredHeight(50.dp)
.fillMaxWidth()
.align(Alignment.TopStart)
.graphicsLayer(
@@ -307,7 +307,7 @@
Box(
Modifier.offset(offsetX, 0.dp)
.background(Color.Blue.copy(alpha = 0.5f))
- .width(50.dp)
+ .requiredWidth(50.dp)
.fillMaxHeight()
.pointerInput(Unit) {
detectHorizontalDragGestures { change, dragAmount ->
@@ -320,7 +320,7 @@
Box(
Modifier.offset(0.dp, offsetY)
.background(Color.Red.copy(alpha = 0.5f))
- .height(50.dp)
+ .requiredHeight(50.dp)
.fillMaxWidth()
)
@@ -344,7 +344,7 @@
Box(
Modifier.offset { IntOffset(offsetX.value.roundToInt(), offsetY.value.roundToInt()) }
.background(Color.Blue)
- .size(50.dp)
+ .requiredSize(50.dp)
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
change.consumeAllChanges()
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelectionSample.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelectionSample.kt
index 1dc2487..01670e0 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelectionSample.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeTextSelectionSample.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Text
@@ -103,7 +103,7 @@
style = commonStyle.merge(header)
)
Row {
- Box(Modifier.padding(8.dp).preferredSize(48.dp).background(rectColor))
+ Box(Modifier.padding(8.dp).size(48.dp).background(rectColor))
Text(
text = "Jetpack Compose is a modern toolkit for building native Android UI." +
" Jetpack Compose simplifies and accelerates UI development on Android " +
@@ -137,12 +137,12 @@
style = commonStyle
)
}
- Box(Modifier.padding(8.dp).preferredSize(48.dp).background(rectColor))
+ Box(Modifier.padding(8.dp).size(48.dp).background(rectColor))
}
Box(
Modifier
.padding(top = 20.dp, bottom = 20.dp)
- .preferredSize(200.dp, 60.dp)
+ .size(200.dp, 60.dp)
.background(rectColor)
)
Text(
@@ -208,7 +208,7 @@
style = commonStyle.merge(header)
)
Row {
- Box(Modifier.padding(8.dp).preferredSize(48.dp).background(rectColor))
+ Box(Modifier.padding(8.dp).size(48.dp).background(rectColor))
Text(
text = content,
modifier = Modifier.weight(1f),
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TailFollowingTextField.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TailFollowingTextField.kt
index f013764..480645b 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TailFollowingTextField.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TailFollowingTextField.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
@@ -56,7 +56,7 @@
modifier = Modifier
.then(demoTextFieldModifiers)
.fillMaxWidth()
- .height(120.dp)
+ .requiredHeight(120.dp)
.clipToBounds()
)
}
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextFieldWIthScroller.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextFieldWIthScroller.kt
index df07145..83170f1 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextFieldWIthScroller.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TextFieldWIthScroller.kt
@@ -16,8 +16,8 @@
package androidx.compose.foundation.demos.text
-import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.runtime.Composable
@@ -50,7 +50,7 @@
BasicTextField(
value = state.value,
state.value = it },
- modifier = demoTextFieldModifiers.size(200.dp),
+ modifier = demoTextFieldModifiers.requiredSize(200.dp),
singleLine = false,
textStyle = TextStyle(fontSize = fontSize8)
)
@@ -62,7 +62,7 @@
BasicTextField(
value = state.value,
state.value = it },
- modifier = demoTextFieldModifiers.width(200.dp),
+ modifier = demoTextFieldModifiers.requiredWidth(200.dp),
singleLine = true,
textStyle = TextStyle(fontSize = fontSize8)
)
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/CanvasSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/CanvasSamples.kt
index b53d859..327f3e1 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/CanvasSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/CanvasSamples.kt
@@ -18,7 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.Canvas
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
@@ -29,7 +29,7 @@
@Sampled
@Composable
fun CanvasSample() {
- Canvas(modifier = Modifier.preferredSize(100.dp)) {
+ Canvas(modifier = Modifier.size(100.dp)) {
drawRect(Color.Magenta)
inset(10.0f) {
drawLine(
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DarkThemeSample.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DarkThemeSample.kt
index e67a3f0..ac765ec 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DarkThemeSample.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DarkThemeSample.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -32,6 +32,6 @@
val dark = isSystemInDarkTheme()
val color = if (dark) Color.White else Color.Black
Box {
- Box(Modifier.preferredSize(50.dp).background(color = color))
+ Box(Modifier.size(50.dp).background(color = color))
}
}
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DraggableSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DraggableSamples.kt
index 7f57ff2..0d930bd 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DraggableSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/DraggableSamples.kt
@@ -23,8 +23,8 @@
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -49,7 +49,7 @@
// seekbar itself
Box(
modifier = Modifier
- .preferredWidth(max)
+ .width(max)
.draggable(
orientation = Orientation.Horizontal,
state = rememberDraggableState { delta ->
@@ -61,7 +61,7 @@
) {
Box(
Modifier.offset { IntOffset(offsetPosition.value.roundToInt(), 0) }
- .preferredSize(50.dp)
+ .size(50.dp)
.background(Color.Red)
)
}
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ImageSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ImageSamples.kt
index ba2d1d9..0210fd2 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ImageSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ImageSamples.kt
@@ -18,7 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.Image
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@@ -76,7 +76,7 @@
Image(
painter = customPainter,
contentDescription = "Localized description",
- modifier = Modifier.preferredSize(100.dp, 100.dp)
+ modifier = Modifier.size(100.dp, 100.dp)
)
}
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
index bf1a650..0b37029 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.indication
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material.Text
@@ -46,7 +46,7 @@
}
.padding(10.dp)
)
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Text(
text = "I'm neighbour and I indicate when you click the other one",
modifier = Modifier
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
index 04cc3e7..63cdd2d 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
@@ -31,7 +31,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
@@ -67,7 +67,7 @@
Modifier
.fillMaxSize()
.wrapContentSize()
- .preferredSize(width = 240.dp, height = 80.dp)
+ .size(width = 240.dp, height = 80.dp)
) {
Box(
Modifier
@@ -131,7 +131,7 @@
Row {
Box(
Modifier
- .preferredSize(width = 240.dp, height = 80.dp)
+ .size(width = 240.dp, height = 80.dp)
.then(clickable)
.border(BorderStroke(3.dp, Color.Blue))
.padding(3.dp)
@@ -145,7 +145,7 @@
}
Box(
Modifier
- .preferredSize(width = 240.dp, height = 80.dp)
+ .size(width = 240.dp, height = 80.dp)
.then(draggable)
.border(BorderStroke(3.dp, Color.Red))
.padding(3.dp)
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ProgressSemanticsSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ProgressSemanticsSamples.kt
index 2b926c8..1727eb8 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ProgressSemanticsSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ProgressSemanticsSamples.kt
@@ -19,7 +19,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.progressSemantics
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -34,7 +34,7 @@
Box(
Modifier
.progressSemantics(progress)
- .preferredSize((progress * 100).dp, 4.dp)
+ .size((progress * 100).dp, 4.dp)
.background(color = Color.Cyan)
)
}
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollableSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollableSamples.kt
index 5a43f9e..046e55d 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollableSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollableSamples.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.gestures.rememberScrollableState
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
@@ -42,7 +42,7 @@
val offset = remember { mutableStateOf(0f) }
Box(
Modifier
- .preferredSize(150.dp)
+ .size(150.dp)
.scrollable(
orientation = Orientation.Vertical,
// state for Scrollable, describes how consume scroll amount
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt
index 35e6b9f..0fddaa9 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ScrollerSamples.kt
@@ -26,9 +26,9 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@@ -77,7 +77,7 @@
Modifier
.verticalScroll(scrollState)
.fillMaxWidth()
- .height(10000.dp)
+ .requiredHeight(10000.dp)
.background(brush = gradient)
)
}
@@ -135,7 +135,7 @@
@Composable
private fun Square(index: Int) {
Box(
- Modifier.preferredSize(75.dp, 200.dp).background(colors[index % colors.size]),
+ Modifier.size(75.dp, 200.dp).background(colors[index % colors.size]),
contentAlignment = Alignment.Center
) {
Text(index.toString())
@@ -146,7 +146,7 @@
private fun Button(onClick: () -> Unit, content: @Composable () -> Unit) {
Box(
Modifier.padding(5.dp)
- .preferredSize(120.dp, 60.dp)
+ .size(120.dp, 60.dp)
.clickable(>
.background(color = Color.LightGray),
contentAlignment = Alignment.Center
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ZoomableSample.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ZoomableSample.kt
index 97be10b..fb273b8 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ZoomableSample.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/ZoomableSample.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.gestures.zoomable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -46,7 +46,7 @@
@Composable
fun ZoomableSample() {
Box(
- Modifier.preferredSize(200.dp).clipToBounds().background(Color.LightGray)
+ Modifier.size(200.dp).clipToBounds().background(Color.LightGray)
) {
var scale by remember { mutableStateOf(1f) }
val zoomableController = rememberZoomableController { scale *= it }
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt
index eabe70f..1bf2f65 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt
@@ -19,7 +19,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -90,10 +90,10 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40f.toDp()).background(Color.Magenta),
+ Modifier.size(40f.toDp()).background(Color.Magenta),
contentAlignment = Alignment.Center
) {
- Box(Modifier.preferredSize(20f.toDp()).background(Color.White))
+ Box(Modifier.size(20f.toDp()).background(Color.White))
}
}
}
@@ -113,11 +113,11 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40f.toDp()).background(Color.Magenta),
+ Modifier.size(40f.toDp()).background(Color.Magenta),
contentAlignment = Alignment.Center
) {
Box(
- Modifier.preferredSize(20f.toDp())
+ Modifier.size(20f.toDp())
.background(SolidColor(Color.White))
)
}
@@ -139,7 +139,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40f.toDp())
+ Modifier.size(40f.toDp())
.background(Color.Magenta)
.background(color = Color.White, shape = CircleShape)
)
@@ -160,7 +160,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40f.toDp())
+ Modifier.size(40f.toDp())
.background(Color.Magenta)
.background(
brush = SolidColor(Color.White),
@@ -185,7 +185,7 @@
SemanticParent {
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(
- Modifier.preferredSize(40f.toDp())
+ Modifier.size(40f.toDp())
.background(Color.Magenta)
.background(
brush = SolidColor(Color.White),
@@ -212,7 +212,7 @@
SemanticParent {
CompositionLocalProvider(LocalLayoutDirection provides direction.value) {
Box(
- Modifier.preferredSize(40f.toDp())
+ Modifier.size(40f.toDp())
.background(Color.Magenta)
.background(
brush = SolidColor(Color.White),
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt
index a11834c..9682c86 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt
@@ -18,8 +18,8 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -89,7 +89,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
+ Modifier.size(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
.border(BorderStroke(10.0f.toDp(), Color.Red), shape)
@@ -114,7 +114,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
+ Modifier.size(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
.border(
BorderStroke(10.0f.toDp(), SolidColor(Color.Red)),
@@ -141,7 +141,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
+ Modifier.size(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
.border(BorderStroke(1500.0f.toDp(), Color.Red), shape)
) {}
@@ -163,7 +163,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
+ Modifier.size(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
.border(BorderStroke(-5.0f.toDp(), Color.Red), shape)
) {}
@@ -185,10 +185,10 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp()).background(Color.White)
+ Modifier.size(40.0f.toDp(), 40.0f.toDp()).background(Color.White)
) {
Box(
- Modifier.preferredSize(0.0f.toDp(), 40.0f.toDp())
+ Modifier.size(0.0f.toDp(), 40.0f.toDp())
.border(BorderStroke(4.0f.toDp(), Color.Red), shape)
) {}
}
@@ -215,7 +215,7 @@
rule.setContent {
Box(
Modifier.testTag(testTag)
- .size(100.dp, 100.dp)
+ .requiredSize(100.dp, 100.dp)
.background(Color.White)
.border(BorderStroke(10.dp, Color.Red), triangle)
)
@@ -241,7 +241,7 @@
rule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
+ Modifier.size(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
.border(BorderStroke(10.0f.toDp(), Color.Red), rtlAwareShape)
) {}
@@ -266,7 +266,7 @@
SemanticParent {
CompositionLocalProvider(LocalLayoutDirection provides direction.value) {
Box(
- Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
+ Modifier.size(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
.border(BorderStroke(10.0f.toDp(), Color.Red), rtlAwareShape)
) {}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt
index cb59aaa..b66bee3 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt
@@ -18,7 +18,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.testutils.assertShape
@@ -67,11 +67,11 @@
val minWidth = (boxWidth / density).dp
val minHeight = (boxHeight / density).dp
Box(
- modifier = Modifier.preferredSize(containerSize)
+ modifier = Modifier.size(containerSize)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
- Canvas(modifier = Modifier.preferredSize(minWidth, minHeight)) {
+ Canvas(modifier = Modifier.size(minWidth, minHeight)) {
drawLine(
start = Offset.Zero,
end = Offset(size.width, size.height),
@@ -175,7 +175,7 @@
@LargeTest
fun canvas_exactSizes() {
rule.setContentForSizeAssertions {
- Canvas(Modifier.preferredSize(100.dp)) {
+ Canvas(Modifier.size(100.dp)) {
drawRect(Color.Red)
}
}
@@ -194,7 +194,7 @@
@LargeTest
fun canvas_exactSizes_drawCircle() {
rule.setContentForSizeAssertions {
- Canvas(Modifier.preferredSize(100.dp)) {
+ Canvas(Modifier.size(100.dp)) {
drawRect(Color.Red)
drawCircle(
Color.Blue,
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/DraggableTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/DraggableTest.kt
index 35b5448..0fb987b 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/DraggableTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/DraggableTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -292,14 +292,14 @@
contentAlignment = Alignment.Center,
modifier = Modifier
.testTag(draggableBoxTag)
- .preferredSize(300.dp)
+ .size(300.dp)
.draggable(Orientation.Horizontal) {
outerDrag += it
}
) {
Box(
modifier = Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.draggable(Orientation.Horizontal) { delta ->
innerDrag += delta / 2
}
@@ -367,7 +367,7 @@
Box(
modifier = Modifier
.testTag(draggableBoxTag)
- .preferredSize(100.dp)
+ .size(100.dp)
.draggable(
orientation = Orientation.Horizontal,
interactionState = interactionState
@@ -430,7 +430,7 @@
Box(
modifier = Modifier
.testTag(draggableBoxTag)
- .preferredSize(100.dp)
+ .size(100.dp)
.then(draggable)
)
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/FoundationTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/FoundationTest.kt
index f78c860..2b7ab2b 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/FoundationTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/FoundationTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSizeIn
+import androidx.compose.foundation.layout.sizeIn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
@@ -41,7 +41,7 @@
setContent {
Box {
Box(
- Modifier.preferredSizeIn(maxWidth = parentMaxWidth, maxHeight = parentMaxHeight)
+ Modifier.sizeIn(maxWidth = parentMaxWidth, maxHeight = parentMaxHeight)
.testTag("containerForSizeAssertion")
) {
content()
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
index ec15702..7213320 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
@@ -18,10 +18,10 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredHeightIn
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredSizeIn
+import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.sizeIn
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.test.R
import androidx.compose.runtime.mutableStateOf
@@ -112,7 +112,7 @@
rule.setContent {
val size = (containerSize / LocalDensity.current.density).dp
Box(
- Modifier.preferredSize(size)
+ Modifier.size(size)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
@@ -157,7 +157,7 @@
rule.setContent {
val size = (containerSize / LocalDensity.current.density).dp
Box(
- Modifier.preferredSize(size)
+ Modifier.size(size)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
@@ -257,7 +257,7 @@
val density = LocalDensity.current.density
val size = (containerSize * 2 / density).dp
Box(
- Modifier.preferredSize(size)
+ Modifier.size(size)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
@@ -269,7 +269,7 @@
contentDescription = null,
modifier = Modifier
.testTag(contentTag)
- .preferredSize(
+ .size(
(imageComposableWidth / density).dp,
(imageComposableHeight / density).dp
)
@@ -328,7 +328,7 @@
drawRect(color = Color.Blue)
}
Box(
- Modifier.preferredSize(size)
+ Modifier.size(size)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
@@ -337,7 +337,7 @@
contentDescription = null,
modifier = Modifier
.testTag(contentTag)
- .preferredSize(
+ .size(
(imageComposableWidth / density.density).dp,
(imageComposableHeight / density.density).dp
),
@@ -359,7 +359,7 @@
val density = LocalDensity.current.density
val size = (containerSize * 2 / density).dp
Box(
- Modifier.preferredSize(size)
+ Modifier.size(size)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
@@ -370,7 +370,7 @@
contentDescription = null,
modifier = Modifier
.testTag(contentTag)
- .preferredSize(
+ .size(
(imageComposableWidth / density).dp,
(imageComposableHeight / density).dp
),
@@ -421,14 +421,14 @@
val minWidth = (boxWidth / density).dp
val minHeight = (boxHeight / density).dp
Box(
- Modifier.preferredSize(size)
+ Modifier.size(size)
.background(color = Color.White)
.wrapContentSize(Alignment.Center)
) {
Image(
painterResource(R.drawable.ic_vector_asset_test),
null,
- modifier = Modifier.preferredSizeIn(
+ modifier = Modifier.sizeIn(
minWidth = minWidth,
minHeight = minHeight
)
@@ -516,7 +516,7 @@
modifier = Modifier
.testTag(testTag)
.background(Color.Green)
- .preferredHeightIn(max = (heightDp / 2f).dp),
+ .heightIn(max = (heightDp / 2f).dp),
contentScale = ContentScale.Crop
)
}
@@ -584,7 +584,7 @@
val testTag = "testTag"
rule.setContent {
val sizeDp = with(LocalDensity.current) { 50 / density }
- Box(modifier = Modifier.size(sizeDp.dp)) {
+ Box(modifier = Modifier.requiredSize(sizeDp.dp)) {
Image(
painter = ColorPainter(Color.Red),
modifier = Modifier.testTag(testTag),
@@ -599,7 +599,7 @@
fun testImageZeroSizeDoesNotCrash() {
rule.setContent {
// Intentionally force a size of zero to ensure we do not crash
- Box(modifier = Modifier.size(0.dp)) {
+ Box(modifier = Modifier.requiredSize(0.dp)) {
Image(
painter = ColorPainter(Color.Red),
contentDescription = null
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt
index 3b15690..80071b3 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -76,7 +76,7 @@
}
}
rule.setContent {
- Box(Modifier.testTag(testTag).preferredSize(100.dp).indication(state, indication))
+ Box(Modifier.testTag(testTag).size(100.dp).indication(state, indication))
}
assertThat(countDownLatch.await(1000, TimeUnit.MILLISECONDS)).isTrue()
}
@@ -93,7 +93,7 @@
Box(
Modifier
.testTag(testTag)
- .preferredSize(100.dp)
+ .size(100.dp)
.clickable(
interactionState = remember { InteractionState() },
indication = indication,
@@ -129,7 +129,7 @@
rule.setContent {
val switchableIndication =
if (switchState.value) Modifier.indication(state, indication) else Modifier
- Box(Modifier.testTag(testTag).preferredSize(100.dp).then(switchableIndication))
+ Box(Modifier.testTag(testTag).size(100.dp).then(switchableIndication))
}
assertThat(countDownLatch.count).isEqualTo(1)
rule.runOnIdle {
@@ -152,7 +152,7 @@
Box(
Modifier
.testTag(testTag)
- .preferredSize(100.dp)
+ .size(100.dp)
.clickable(
interactionState = remember { InteractionState() },
indication = indication
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ProgressSemanticsTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ProgressSemanticsTest.kt
index 10ba7c1..9efb2b6 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ProgressSemanticsTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ProgressSemanticsTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -55,7 +55,7 @@
Modifier
.testTag(tag)
.progressSemantics(progress.value)
- .preferredSize(50.dp)
+ .size(50.dp)
.background(color = Color.Cyan)
)
}
@@ -90,7 +90,7 @@
Modifier
.testTag(tag)
.progressSemantics()
- .preferredSize(50.dp)
+ .size(50.dp)
.background(color = Color.Cyan)
)
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
index c0a6aa6..bca265d 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
@@ -27,8 +27,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -499,7 +499,7 @@
Box {
Column(
Modifier
- .preferredSize(100.dp)
+ .size(100.dp)
.testTag(scrollerTag)
.verticalScroll(scrollState)
) {
@@ -584,7 +584,7 @@
scrollState = rememberScrollState()
Column(Modifier.verticalScroll(scrollState!!)) {
repeat(50) {
- Box(Modifier.preferredHeight(100.dp))
+ Box(Modifier.height(100.dp))
}
}
}
@@ -658,7 +658,7 @@
Box {
Column(
modifier = Modifier
- .preferredSize(width.toDp(), height.toDp())
+ .size(width.toDp(), height.toDp())
.testTag(scrollerTag)
.verticalScroll(
resolvedState,
@@ -669,7 +669,7 @@
colors.forEach { color ->
Box(
Modifier
- .preferredSize(width.toDp(), rowHeight.toDp())
+ .size(width.toDp(), rowHeight.toDp())
.background(color)
)
}
@@ -695,7 +695,7 @@
Box {
Row(
modifier = Modifier
- .preferredSize(width.toDp(), height.toDp())
+ .size(width.toDp(), height.toDp())
.testTag(scrollerTag)
.horizontalScroll(
resolvedState,
@@ -706,7 +706,7 @@
colors.forEach { color ->
Box(
Modifier
- .preferredSize(defaultCellSize.toDp(), height.toDp())
+ .size(defaultCellSize.toDp(), height.toDp())
.background(color)
)
}
@@ -767,7 +767,7 @@
}
Box {
Box(
- Modifier.preferredSize(width, height).background(Color.White)
+ Modifier.size(width, height).background(Color.White)
) {
if (isVertical) {
Column(
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
index 73e0e5a..988b49d 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.gestures.ScrollableState
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -385,7 +385,7 @@
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.scrollable(
flingSpec = decayAnimationSpec,
state = outerState,
@@ -394,7 +394,7 @@
) {
Box(
modifier = Modifier.testTag(scrollableBoxTag)
- .preferredSize(300.dp)
+ .size(300.dp)
.scrollable(
flingSpec = FloatExponentialDecaySpec()
.generateDecayAnimationSpec(),
@@ -452,7 +452,7 @@
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.scrollable(
state = outerState,
flingSpec = decayAnimationSpec,
@@ -462,7 +462,7 @@
Box(
modifier = Modifier
.testTag(scrollableBoxTag)
- .preferredSize(300.dp)
+ .size(300.dp)
.scrollable(
state = innerState,
flingSpec = FloatExponentialDecaySpec()
@@ -527,11 +527,11 @@
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.nestedScroll(preConsumingParent)
) {
Box(
- modifier = Modifier.preferredSize(300.dp)
+ modifier = Modifier.size(300.dp)
.testTag(scrollableBoxTag)
.scrollable(
flingSpec = FloatExponentialDecaySpec()
@@ -603,11 +603,11 @@
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.nestedScroll(parent)
) {
Box(
- modifier = Modifier.preferredSize(300.dp)
+ modifier = Modifier.size(300.dp)
.testTag(scrollableBoxTag)
.scrollable(
flingSpec = decayAnimationSpec,
@@ -652,7 +652,7 @@
rule.setContent {
Box {
Box(
- modifier = Modifier.preferredSize(300.dp)
+ modifier = Modifier.size(300.dp)
.scrollable(
flingSpec = decayAnimationSpec,
@@ -661,7 +661,7 @@
)
) {
Box(
- Modifier.preferredSize(200.dp)
+ Modifier.size(200.dp)
.testTag(scrollableBoxTag)
.nestedScroll(child, dispatcher)
)
@@ -724,7 +724,7 @@
rule.setContent {
Box {
Box(
- modifier = Modifier.preferredSize(300.dp)
+ modifier = Modifier.size(300.dp)
.scrollable(
flingSpec = decayAnimationSpec,
state = parentController,
@@ -732,7 +732,7 @@
)
) {
Box(
- Modifier.preferredSize(200.dp)
+ Modifier.size(200.dp)
.testTag(scrollableBoxTag)
.scrollable(
flingSpec = decayAnimationSpec,
@@ -828,7 +828,7 @@
Box(
modifier = Modifier
.testTag(scrollableBoxTag)
- .preferredSize(100.dp)
+ .size(100.dp)
.scrollable(
interactionState = interactionState,
flingSpec = decayAnimationSpec,
@@ -891,7 +891,7 @@
Box(
modifier = Modifier
.testTag(scrollableBoxTag)
- .preferredSize(100.dp).then(scrollable)
+ .size(100.dp).then(scrollable)
)
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ZoomableTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ZoomableTest.kt
index 30ebb0e..17cbe30 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ZoomableTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ZoomableTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.gestures.rememberZoomableController
import androidx.compose.foundation.gestures.zoomable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberCoroutineScope
@@ -344,7 +344,7 @@
private fun setZoomableContent(getModifier: @Composable () -> Modifier) {
rule.setContent {
- Box(Modifier.preferredSize(600.dp).testTag(TEST_TAG).then(getModifier()))
+ Box(Modifier.size(600.dp).testTag(TEST_TAG).then(getModifier()))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt
index 23a5834..12eeeb0 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLayoutDirection
@@ -60,10 +60,10 @@
fun column_defaultArrangementIsTop() {
rule.setContent {
LazyColumn(
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
) {
items(2) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -94,10 +94,10 @@
fun row_defaultArrangementIsStart() {
rule.setContent {
LazyRow(
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
) {
items(2) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -153,7 +153,7 @@
modifier = Modifier.testTag(ContainerTag)
) {
items(2) {
- Box(Modifier.size(itemSize))
+ Box(Modifier.requiredSize(itemSize))
}
}
}
@@ -171,7 +171,7 @@
modifier = Modifier.testTag(ContainerTag)
) {
items(2) {
- Box(Modifier.size(itemSize))
+ Box(Modifier.requiredSize(itemSize))
}
}
}
@@ -188,10 +188,10 @@
rule.setContent {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(itemSize),
- modifier = Modifier.size(itemSize * 3.5f)
+ modifier = Modifier.requiredSize(itemSize * 3.5f)
) {
items(3) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -208,10 +208,10 @@
rule.setContentWithTestViewConfiguration {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(itemSize),
- modifier = Modifier.size(itemSize * 3.5f).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 3.5f).testTag(ContainerTag)
) {
items(3) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -231,10 +231,10 @@
rule.setContent {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(itemSize),
- modifier = Modifier.size(itemSize * 3.5f)
+ modifier = Modifier.requiredSize(itemSize * 3.5f)
) {
items(3) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -251,10 +251,10 @@
rule.setContentWithTestViewConfiguration {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(itemSize),
- modifier = Modifier.size(itemSize * 3.5f).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 3.5f).testTag(ContainerTag)
) {
items(3) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -276,10 +276,10 @@
rule.setContent {
LazyColumn(
reverseLayout = true,
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
) {
items(2) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -292,10 +292,10 @@
rule.setContent {
LazyRow(
reverseLayout = true,
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
) {
items(2) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -309,10 +309,10 @@
rule.setContent {
LazyColumn(
verticalArrangement = arrangement,
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
) {
items(2) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -323,10 +323,10 @@
CompositionLocalProvider(LocalLayoutDirection provides layoutDirection) {
LazyRow(
horizontalArrangement = arrangement,
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
) {
items(2) {
- Box(Modifier.size(itemSize).testTag(it.toString()))
+ Box(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
index 1ee7478..bea2a29 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
@@ -25,12 +25,12 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.sizeIn
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredSizeIn
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
@@ -104,18 +104,18 @@
val indexedItems = listOf(3, 4, 5)
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.preferredHeight(200.dp)) {
+ LazyColumn(Modifier.height(200.dp)) {
item {
Spacer(
- Modifier.preferredHeight(40.dp).fillParentMaxWidth().testTag(itemTestTag)
+ Modifier.height(40.dp).fillParentMaxWidth().testTag(itemTestTag)
)
}
items(items) {
- Spacer(Modifier.preferredHeight(40.dp).fillParentMaxWidth().testTag(it))
+ Spacer(Modifier.height(40.dp).fillParentMaxWidth().testTag(it))
}
itemsIndexed(indexedItems) { index, item ->
Spacer(
- Modifier.preferredHeight(41.dp).fillParentMaxWidth()
+ Modifier.height(41.dp).fillParentMaxWidth()
.testTag("$index-$item")
)
}
@@ -149,7 +149,7 @@
LazyColumn {
items(emptyList<Any>()) { }
item {
- Spacer(Modifier.preferredSize(10.dp).testTag(itemTag))
+ Spacer(Modifier.size(10.dp).testTag(itemTag))
}
}
}
@@ -164,13 +164,13 @@
val nullTestTag = "nullTestTag"
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.preferredHeight(200.dp)) {
+ LazyColumn(Modifier.height(200.dp)) {
items(items) {
if (it != null) {
- Spacer(Modifier.preferredHeight(101.dp).fillParentMaxWidth().testTag(it))
+ Spacer(Modifier.height(101.dp).fillParentMaxWidth().testTag(it))
} else {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(nullTestTag)
)
}
@@ -197,7 +197,7 @@
rule.setContentWithTestViewConfiguration {
// Fixed height to eliminate device size as a factor
- Box(Modifier.testTag(LazyListTag).preferredHeight(300.dp)) {
+ Box(Modifier.testTag(LazyListTag).height(300.dp)) {
LazyColumn(Modifier.fillMaxSize()) {
items(50) {
DisposableEffect(NeverEqualObject) {
@@ -210,7 +210,7 @@
}
// There will be 10 of these in the 300dp box
- Spacer(Modifier.preferredHeight(31.dp))
+ Spacer(Modifier.height(31.dp))
}
}
}
@@ -259,7 +259,7 @@
}
}
- Spacer(Modifier.height(50.dp))
+ Spacer(Modifier.requiredHeight(50.dp))
}
}
}
@@ -294,7 +294,7 @@
if (emitAdapterList) {
LazyColumn(Modifier.fillMaxSize()) {
items(2) {
- Box(Modifier.size(100.dp))
+ Box(Modifier.requiredSize(100.dp))
DisposableEffect(Unit) {
onDispose {
if (it == 1) {
@@ -405,7 +405,7 @@
rule.setContentWithTestViewConfiguration {
LazyColumn(
Modifier.fillMaxWidth()
- .preferredHeight(100.dp)
+ .height(100.dp)
.testTag(LazyListTag)
) {
items(items) {
@@ -413,10 +413,10 @@
Spacer(
Modifier.testTag(thirdTag)
.fillParentMaxWidth()
- .preferredHeight(if (thirdHasSize) 60.dp else 0.dp)
+ .height(if (thirdHasSize) 60.dp else 0.dp)
)
} else {
- Spacer(Modifier.fillParentMaxWidth().preferredHeight(60.dp))
+ Spacer(Modifier.fillParentMaxWidth().height(60.dp))
}
}
}
@@ -453,13 +453,13 @@
LazyColumn(Modifier.testTag(LazyListTag)) {
items(listOf(1, 2)) {
if (it == 1) {
- Spacer(Modifier.preferredSize(50.dp).testTag(itemInsideLazyColumn))
+ Spacer(Modifier.size(50.dp).testTag(itemInsideLazyColumn))
} else {
- Spacer(Modifier.preferredSize(if (sameSizeItems) 50.dp else 70.dp))
+ Spacer(Modifier.size(if (sameSizeItems) 50.dp else 70.dp))
}
}
}
- Spacer(Modifier.preferredSize(50.dp).testTag(itemOutsideLazyColumn))
+ Spacer(Modifier.size(50.dp).testTag(itemOutsideLazyColumn))
}
}
@@ -504,14 +504,14 @@
private fun prepareLazyColumnsItemsAlignment(horizontalGravity: Alignment.Horizontal) {
rule.setContentWithTestViewConfiguration {
LazyColumn(
- Modifier.testTag(LazyListTag).width(100.dp),
+ Modifier.testTag(LazyListTag).requiredWidth(100.dp),
horizontalAlignment = horizontalGravity
) {
items(listOf(1, 2)) {
if (it == 1) {
- Spacer(Modifier.preferredSize(50.dp).testTag(firstItemTag))
+ Spacer(Modifier.size(50.dp).testTag(firstItemTag))
} else {
- Spacer(Modifier.preferredSize(70.dp).testTag(secondItemTag))
+ Spacer(Modifier.size(70.dp).testTag(secondItemTag))
}
}
}
@@ -569,9 +569,11 @@
@Test
fun itemFillingParentWidth() {
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyColumn(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.fillParentMaxWidth().height(50.dp).testTag(firstItemTag))
+ Spacer(
+ Modifier.fillParentMaxWidth().requiredHeight(50.dp).testTag(firstItemTag)
+ )
}
}
}
@@ -584,9 +586,11 @@
@Test
fun itemFillingParentHeight() {
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyColumn(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.width(50.dp).fillParentMaxHeight().testTag(firstItemTag))
+ Spacer(
+ Modifier.requiredWidth(50.dp).fillParentMaxHeight().testTag(firstItemTag)
+ )
}
}
}
@@ -599,7 +603,7 @@
@Test
fun itemFillingParentSize() {
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyColumn(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
Spacer(Modifier.fillParentMaxSize().testTag(firstItemTag))
}
@@ -614,9 +618,13 @@
@Test
fun itemFillingParentWidthFraction() {
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyColumn(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.fillParentMaxWidth(0.6f).height(50.dp).testTag(firstItemTag))
+ Spacer(
+ Modifier.fillParentMaxWidth(0.6f)
+ .requiredHeight(50.dp)
+ .testTag(firstItemTag)
+ )
}
}
}
@@ -629,9 +637,13 @@
@Test
fun itemFillingParentHeightFraction() {
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyColumn(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.width(50.dp).fillParentMaxHeight(0.2f).testTag(firstItemTag))
+ Spacer(
+ Modifier.requiredWidth(50.dp)
+ .fillParentMaxHeight(0.2f)
+ .testTag(firstItemTag)
+ )
}
}
}
@@ -644,7 +656,7 @@
@Test
fun itemFillingParentSizeFraction() {
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyColumn(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
Spacer(Modifier.fillParentMaxSize(0.1f).testTag(firstItemTag))
}
@@ -660,7 +672,7 @@
fun itemFillingParentSizeParentResized() {
var parentSize by mutableStateOf(100.dp)
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(parentSize)) {
+ LazyColumn(Modifier.requiredSize(parentSize)) {
items(listOf(0)) {
Spacer(Modifier.fillParentMaxSize().testTag(firstItemTag))
}
@@ -680,9 +692,9 @@
fun whenNotAnymoreAvailableItemWasDisplayed() {
var items by mutableStateOf((1..30).toList())
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -704,9 +716,9 @@
fun whenFewDisplayedItemsWereRemoved() {
var items by mutableStateOf((1..10).toList())
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -728,9 +740,9 @@
fun whenItemsBecameEmpty() {
var items by mutableStateOf((1..10).toList())
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.sizeIn(maxHeight = 100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSizeIn(maxHeight = 100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -759,9 +771,9 @@
fun scrollBackAndForth() {
val items by mutableStateOf((1..20).toList())
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -782,9 +794,9 @@
fun tryToScrollBackwardWhenAlreadyOnTop() {
val items by mutableStateOf((1..20).toList())
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -805,14 +817,14 @@
var firstItemRecomposed = 0
var secondItemRecomposed = 0
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
if (it.count == 1) {
firstItemRecomposed++
} else {
secondItemRecomposed++
}
- Spacer(Modifier.size(75.dp))
+ Spacer(Modifier.requiredSize(75.dp))
}
}
}
@@ -838,11 +850,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -867,11 +879,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -904,12 +916,12 @@
val state = LazyListState()
rule.setContentWithTestViewConfiguration {
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
flingSpec = exponentialDecay(),
state = state
) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -940,11 +952,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -971,11 +983,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState(2, expectedOffset)
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -996,11 +1008,11 @@
restorationTester.setContent {
state = rememberLazyListState()
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state!!
) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -1026,9 +1038,9 @@
fun scroll_makeListSmaller_scroll() {
var items by mutableStateOf((1..100).toList())
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(10.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(10.dp).testTag("$it"))
}
}
}
@@ -1054,11 +1066,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyColumn(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -1077,10 +1089,10 @@
val items = (0..20).toList()
val redrawCount = Array(6) { 0 }
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
Spacer(
- Modifier.size(20.dp)
+ Modifier.requiredSize(20.dp)
.drawBehind { redrawCount[it]++ }
)
}
@@ -1103,10 +1115,10 @@
val redrawCount = Array(2) { 0 }
var stateUsedInDrawScope by mutableStateOf(false)
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(2) {
Spacer(
- Modifier.size(50.dp)
+ Modifier.requiredSize(50.dp)
.drawBehind {
redrawCount[it]++
if (it == 1) {
@@ -1137,15 +1149,15 @@
lateinit var state: LazyListState
rule.setContentWithTestViewConfiguration {
LazyColumn(
- Modifier.height(itemSizeMinusOne).testTag(LazyListTag),
+ Modifier.requiredHeight(itemSizeMinusOne).testTag(LazyListTag),
state = rememberLazyListState().also { state = it }
) {
items(2) {
Spacer(
if (it == 0) {
- Modifier.width(30.dp).height(itemSizeMinusOne)
+ Modifier.requiredWidth(30.dp).requiredHeight(itemSizeMinusOne)
} else {
- Modifier.width(20.dp).height(itemSize)
+ Modifier.requiredWidth(20.dp).requiredHeight(itemSize)
}
)
}
@@ -1165,17 +1177,17 @@
lateinit var state: LazyListState
rule.setContentWithTestViewConfiguration {
LazyColumn(
- Modifier.height(itemSize * 1.75f).testTag(LazyListTag),
+ Modifier.requiredHeight(itemSize * 1.75f).testTag(LazyListTag),
state = rememberLazyListState().also { state = it }
) {
items(items) {
Spacer(
if (it == 0) {
- Modifier.width(30.dp).height(itemSize / 2)
+ Modifier.requiredWidth(30.dp).requiredHeight(itemSize / 2)
} else if (it == 1) {
- Modifier.width(20.dp).height(itemSize / 2)
+ Modifier.requiredWidth(20.dp).requiredHeight(itemSize / 2)
} else {
- Modifier.width(20.dp).height(itemSize)
+ Modifier.requiredWidth(20.dp).requiredHeight(itemSize)
}
)
}
@@ -1197,7 +1209,7 @@
rule.setContentWithTestViewConfiguration {
LazyColumn {
items(items) {
- Spacer(Modifier.size(itemSize).testTag(it))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it))
}
}
}
@@ -1221,7 +1233,7 @@
rule.setContentWithTestViewConfiguration {
LazyColumn {
itemsIndexed(items) { index, item ->
- Spacer(Modifier.size(itemSize).testTag("$index*$item"))
+ Spacer(Modifier.requiredSize(itemSize).testTag("$index*$item"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyGridTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyGridTest.kt
index fffb294..4788ab8 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyGridTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyGridTest.kt
@@ -18,11 +18,11 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertIsDisplayed
@@ -56,7 +56,7 @@
) {
item {
Spacer(
- Modifier.preferredSize(10.dp).testTag(itemTestTag)
+ Modifier.size(10.dp).testTag(itemTestTag)
)
}
}
@@ -73,10 +73,10 @@
rule.setContent {
LazyVerticalGrid(
cells = GridCells.Fixed(3),
- modifier = Modifier.preferredHeight(100.dp).preferredWidth(300.dp)
+ modifier = Modifier.height(100.dp).width(300.dp)
) {
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).testTag(it))
+ Spacer(Modifier.height(101.dp).testTag(it))
}
}
}
@@ -104,10 +104,10 @@
rule.setContentWithTestViewConfiguration {
LazyVerticalGrid(
cells = GridCells.Fixed(3),
- modifier = Modifier.preferredHeight(100.dp).testTag(LazyGridTag)
+ modifier = Modifier.height(100.dp).testTag(LazyGridTag)
) {
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).testTag(it))
+ Spacer(Modifier.height(101.dp).testTag(it))
}
}
}
@@ -141,10 +141,10 @@
rule.setContentWithTestViewConfiguration {
LazyVerticalGrid(
cells = GridCells.Fixed(3),
- modifier = Modifier.preferredHeight(200.dp).testTag(LazyGridTag)
+ modifier = Modifier.height(200.dp).testTag(LazyGridTag)
) {
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).testTag(it))
+ Spacer(Modifier.height(101.dp).testTag(it))
}
}
}
@@ -187,10 +187,10 @@
rule.setContent {
LazyVerticalGrid(
cells = GridCells.Adaptive(130.dp),
- modifier = Modifier.preferredHeight(100.dp).preferredWidth(300.dp)
+ modifier = Modifier.height(100.dp).width(300.dp)
) {
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).testTag(it))
+ Spacer(Modifier.height(101.dp).testTag(it))
}
}
}
@@ -218,10 +218,10 @@
rule.setContent {
LazyVerticalGrid(
cells = GridCells.Adaptive(301.dp),
- modifier = Modifier.preferredHeight(100.dp).preferredWidth(300.dp)
+ modifier = Modifier.height(100.dp).width(300.dp)
) {
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).testTag(it))
+ Spacer(Modifier.height(101.dp).testTag(it))
}
}
}
@@ -245,10 +245,10 @@
rule.setContent {
LazyVerticalGrid(
GridCells.Fixed(2),
- Modifier.width(itemSize * 2)
+ Modifier.requiredWidth(itemSize * 2)
) {
items(items) {
- Spacer(Modifier.height(itemSize).testTag(it))
+ Spacer(Modifier.requiredHeight(itemSize).testTag(it))
}
}
}
@@ -279,10 +279,10 @@
rule.setContent {
LazyVerticalGrid(
GridCells.Fixed(2),
- Modifier.width(itemSize * 2)
+ Modifier.requiredWidth(itemSize * 2)
) {
itemsIndexed(items) { index, item ->
- Spacer(Modifier.height(itemSize).testTag("$index*$item"))
+ Spacer(Modifier.requiredHeight(itemSize).testTag("$index*$item"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyItemStateRestoration.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyItemStateRestoration.kt
index f86a9e7..f1d18d8 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyItemStateRestoration.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyItemStateRestoration.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation.lazy
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -48,7 +48,7 @@
LazyColumn {
item {
realState[0] = rememberSaveable { counter0++ }
- Box(Modifier.size(1.dp))
+ Box(Modifier.requiredSize(1.dp))
}
items((1..2).toList()) {
if (it == 1) {
@@ -56,7 +56,7 @@
} else {
realState[2] = rememberSaveable { counter2++ }
}
- Box(Modifier.size(1.dp))
+ Box(Modifier.requiredSize(1.dp))
}
}
}
@@ -86,7 +86,7 @@
var realState = 0
restorationTester.setContent {
LazyColumn(
- Modifier.size(20.dp),
+ Modifier.requiredSize(20.dp),
state = rememberLazyListState().also { state = it }
) {
items((0..1).toList()) {
@@ -98,7 +98,7 @@
}
}
}
- Box(Modifier.size(30.dp))
+ Box(Modifier.requiredSize(30.dp))
}
}
}
@@ -132,7 +132,7 @@
var realState = arrayOf(0, 0)
restorationTester.setContent {
LazyColumn(
- Modifier.size(20.dp),
+ Modifier.requiredSize(20.dp),
state = rememberLazyListState().also { state = it }
) {
items((0..1).toList()) {
@@ -141,7 +141,7 @@
} else {
realState[1] = rememberSaveable { counter1++ }
}
- Box(Modifier.size(30.dp))
+ Box(Modifier.requiredSize(30.dp))
}
}
}
@@ -181,7 +181,7 @@
var realState = 0
restorationTester.setContent {
LazyColumn(
- Modifier.size(20.dp),
+ Modifier.requiredSize(20.dp),
state = rememberLazyListState().also { state = it }
) {
items((0..1).toList()) {
@@ -194,11 +194,11 @@
itemDisposed = true
}
}
- Box(Modifier.size(30.dp))
+ Box(Modifier.requiredSize(30.dp))
}
}
} else {
- Box(Modifier.size(30.dp))
+ Box(Modifier.requiredSize(30.dp))
}
}
}
@@ -241,7 +241,7 @@
} else {
realState[2] = rememberSaveable { counter2++ }
}
- Box(Modifier.size(1.dp))
+ Box(Modifier.requiredSize(1.dp))
}
}
}
@@ -280,7 +280,7 @@
} else {
realState[2] = rememberSaveable { counter2++ }
}
- Box(Modifier.size(1.dp))
+ Box(Modifier.requiredSize(1.dp))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListHeadersTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListHeadersTest.kt
index 51278ca..b4ed987 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListHeadersTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListHeadersTest.kt
@@ -19,9 +19,9 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertIsDisplayed
@@ -54,21 +54,21 @@
val secondHeaderTag = "secondHeaderTag"
rule.setContent {
- LazyColumn(Modifier.preferredHeight(300.dp)) {
+ LazyColumn(Modifier.height(300.dp)) {
stickyHeader {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(firstHeaderTag)
)
}
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).fillParentMaxWidth().testTag(it))
+ Spacer(Modifier.height(101.dp).fillParentMaxWidth().testTag(it))
}
stickyHeader {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(secondHeaderTag)
)
}
@@ -95,21 +95,21 @@
val secondHeaderTag = "secondHeaderTag"
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.preferredHeight(300.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.height(300.dp).testTag(LazyListTag)) {
stickyHeader {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(firstHeaderTag)
)
}
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).fillParentMaxWidth().testTag(it))
+ Spacer(Modifier.height(101.dp).fillParentMaxWidth().testTag(it))
}
stickyHeader {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(secondHeaderTag)
)
}
@@ -137,23 +137,23 @@
val secondHeaderTag = "secondHeaderTag"
rule.setContentWithTestViewConfiguration {
- LazyColumn(Modifier.preferredHeight(300.dp).testTag(LazyListTag)) {
+ LazyColumn(Modifier.height(300.dp).testTag(LazyListTag)) {
stickyHeader {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(firstHeaderTag)
)
}
stickyHeader {
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag(secondHeaderTag)
)
}
items(items) {
- Spacer(Modifier.preferredHeight(101.dp).fillParentMaxWidth().testTag(it))
+ Spacer(Modifier.height(101.dp).fillParentMaxWidth().testTag(it))
}
}
}
@@ -181,21 +181,21 @@
val secondHeaderTag = "secondHeaderTag"
rule.setContent {
- LazyRow(Modifier.preferredWidth(300.dp)) {
+ LazyRow(Modifier.width(300.dp)) {
stickyHeader {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(firstHeaderTag)
)
}
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
stickyHeader {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(secondHeaderTag)
)
}
@@ -222,21 +222,21 @@
val secondHeaderTag = "secondHeaderTag"
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.preferredWidth(300.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.width(300.dp).testTag(LazyListTag)) {
stickyHeader {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(firstHeaderTag)
)
}
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
stickyHeader {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(secondHeaderTag)
)
}
@@ -264,23 +264,23 @@
val secondHeaderTag = "secondHeaderTag"
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.preferredWidth(300.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.width(300.dp).testTag(LazyListTag)) {
stickyHeader {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(firstHeaderTag)
)
}
stickyHeader {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(secondHeaderTag)
)
}
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
}
}
@@ -310,16 +310,16 @@
rule.setContent {
LazyColumn(
- Modifier.size(itemIndexDp * 4),
+ Modifier.requiredSize(itemIndexDp * 4),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(top = itemIndexDp * 2)
) {
stickyHeader {
- Spacer(Modifier.size(itemIndexDp).testTag(headerTag))
+ Spacer(Modifier.requiredSize(itemIndexDp).testTag(headerTag))
}
items((0..4).toList()) {
- Spacer(Modifier.size(itemIndexDp).testTag("$it"))
+ Spacer(Modifier.requiredSize(itemIndexDp).testTag("$it"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfoTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfoTest.kt
index c5d040e..ab025ff 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfoTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfoTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -60,10 +60,10 @@
rule.setContent {
LazyColumn(
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSizeDp * 3.5f)
+ modifier = Modifier.requiredSize(itemSizeDp * 3.5f)
) {
items((0..5).toList()) {
- Box(Modifier.size(itemSizeDp))
+ Box(Modifier.requiredSize(itemSizeDp))
}
}
}
@@ -79,10 +79,10 @@
rule.setContent {
LazyColumn(
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSizeDp * 3.5f)
+ modifier = Modifier.requiredSize(itemSizeDp * 3.5f)
) {
items((0..5).toList()) {
- Box(Modifier.size(itemSizeDp))
+ Box(Modifier.requiredSize(itemSizeDp))
}
}
}
@@ -102,10 +102,10 @@
LazyColumn(
state = rememberLazyListState().also { state = it },
verticalArrangement = Arrangement.spacedBy(itemSizeDp),
- modifier = Modifier.size(itemSizeDp * 3.5f)
+ modifier = Modifier.requiredSize(itemSizeDp * 3.5f)
) {
items((0..5).toList()) {
- Box(Modifier.size(itemSizeDp))
+ Box(Modifier.requiredSize(itemSizeDp))
}
}
}
@@ -126,10 +126,10 @@
rule.setContent {
LazyColumn(
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSizeDp * 3.5f)
+ modifier = Modifier.requiredSize(itemSizeDp * 3.5f)
) {
items((0..5).toList()) {
- Box(Modifier.size(itemSizeDp))
+ Box(Modifier.requiredSize(itemSizeDp))
}
}
observingFun()
@@ -163,7 +163,7 @@
state = rememberLazyListState().also { state = it }
) {
item {
- Box(Modifier.size(size))
+ Box(Modifier.requiredSize(size))
}
}
observingFun()
@@ -191,7 +191,7 @@
state = rememberLazyListState().also { state = it }
) {
items((0 until count).toList()) {
- Box(Modifier.size(10.dp))
+ Box(Modifier.requiredSize(10.dp))
}
}
}
@@ -213,11 +213,11 @@
lateinit var state: LazyListState
rule.setContent {
LazyColumn(
- Modifier.size(sizeDp),
+ Modifier.requiredSize(sizeDp),
state = rememberLazyListState().also { state = it }
) {
items((0..3).toList()) {
- Box(Modifier.size(sizeDp))
+ Box(Modifier.requiredSize(sizeDp))
}
}
}
@@ -239,12 +239,12 @@
lateinit var state: LazyListState
rule.setContent {
LazyColumn(
- Modifier.size(sizeDp),
+ Modifier.requiredSize(sizeDp),
contentPadding = PaddingValues(top = topPaddingDp, bottom = bottomPaddingDp),
state = rememberLazyListState().also { state = it }
) {
items((0..3).toList()) {
- Box(Modifier.size(sizeDp))
+ Box(Modifier.requiredSize(sizeDp))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsContentPaddingTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsContentPaddingTest.kt
index 559960e..4d0dc1f 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsContentPaddingTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsContentPaddingTest.kt
@@ -21,9 +21,9 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertHeightIsEqualTo
@@ -70,7 +70,7 @@
val largePaddingSize = itemSize
rule.setContent {
LazyColumn(
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -81,7 +81,7 @@
)
) {
items(listOf(1)) {
- Spacer(Modifier.fillParentMaxWidth().preferredHeight(itemSize).testTag(ItemTag))
+ Spacer(Modifier.fillParentMaxWidth().height(itemSize).testTag(ItemTag))
}
}
}
@@ -104,7 +104,7 @@
lateinit var state: LazyListState
rule.setContent {
LazyColumn(
- modifier = Modifier.size(itemSize * 2)
+ modifier = Modifier.requiredSize(itemSize * 2)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -113,7 +113,7 @@
)
) {
items(listOf(1)) {
- Spacer(Modifier.fillParentMaxWidth().preferredHeight(itemSize).testTag(ItemTag))
+ Spacer(Modifier.fillParentMaxWidth().height(itemSize).testTag(ItemTag))
}
}
}
@@ -131,7 +131,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyColumn(
- modifier = Modifier.size(padding * 2 + itemSize)
+ modifier = Modifier.requiredSize(padding * 2 + itemSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -140,7 +140,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -172,7 +172,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyColumn(
- modifier = Modifier.size(itemSize + padding * 2)
+ modifier = Modifier.requiredSize(itemSize + padding * 2)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -181,7 +181,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -207,7 +207,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyColumn(
- modifier = Modifier.size(padding * 2 + itemSize)
+ modifier = Modifier.requiredSize(padding * 2 + itemSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -216,7 +216,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -251,7 +251,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyColumn(
- modifier = Modifier.size(padding * 2 + itemSize)
+ modifier = Modifier.requiredSize(padding * 2 + itemSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -260,7 +260,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -291,7 +291,7 @@
)
) {
items(listOf(1)) {
- Spacer(Modifier.size(itemSize).testTag(ItemTag))
+ Spacer(Modifier.requiredSize(itemSize).testTag(ItemTag))
}
}
}
@@ -343,7 +343,7 @@
val largePaddingSize = itemSize
rule.setContent {
LazyRow(
- modifier = Modifier.size(containerSize)
+ modifier = Modifier.requiredSize(containerSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -354,7 +354,7 @@
)
) {
items(listOf(1)) {
- Spacer(Modifier.fillParentMaxHeight().preferredWidth(itemSize).testTag(ItemTag))
+ Spacer(Modifier.fillParentMaxHeight().width(itemSize).testTag(ItemTag))
}
}
}
@@ -380,7 +380,7 @@
}
rule.setContent {
LazyRow(
- modifier = Modifier.size(itemSize * 2)
+ modifier = Modifier.requiredSize(itemSize * 2)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -389,7 +389,7 @@
)
) {
items(listOf(1)) {
- Spacer(Modifier.fillParentMaxHeight().preferredWidth(itemSize).testTag(ItemTag))
+ Spacer(Modifier.fillParentMaxHeight().width(itemSize).testTag(ItemTag))
}
}
}
@@ -407,7 +407,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyRow(
- modifier = Modifier.size(padding * 2 + itemSize)
+ modifier = Modifier.requiredSize(padding * 2 + itemSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -416,7 +416,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -448,7 +448,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyRow(
- modifier = Modifier.size(itemSize + padding * 2)
+ modifier = Modifier.requiredSize(itemSize + padding * 2)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -457,7 +457,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -483,7 +483,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyRow(
- modifier = Modifier.size(padding * 2 + itemSize)
+ modifier = Modifier.requiredSize(padding * 2 + itemSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -492,7 +492,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -527,7 +527,7 @@
val padding = itemSize * 1.5f
rule.setContent {
LazyRow(
- modifier = Modifier.size(padding * 2 + itemSize)
+ modifier = Modifier.requiredSize(padding * 2 + itemSize)
.testTag(LazyListTag),
state = rememberLazyListState().also { state = it },
contentPadding = PaddingValues(
@@ -536,7 +536,7 @@
)
) {
items((0..3).toList()) {
- Spacer(Modifier.size(itemSize).testTag(it.toString()))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it.toString()))
}
}
}
@@ -567,7 +567,7 @@
)
) {
items(listOf(1)) {
- Spacer(Modifier.size(itemSize).testTag(ItemTag))
+ Spacer(Modifier.requiredSize(itemSize).testTag(ItemTag))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsIndexedTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsIndexedTest.kt
index 16bb089..78ad549 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsIndexedTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsIndexedTest.kt
@@ -17,10 +17,10 @@
package androidx.compose.foundation.lazy
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
@@ -44,10 +44,10 @@
val items = (1..4).map { it.toString() }
rule.setContent {
- LazyColumn(Modifier.preferredHeight(200.dp)) {
+ LazyColumn(Modifier.height(200.dp)) {
itemsIndexed(items) { index, item ->
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag("$index-$item")
)
}
@@ -72,9 +72,11 @@
val items = (0..1).map { it.toString() }
rule.setContent {
- LazyColumn(Modifier.preferredHeight(200.dp)) {
+ LazyColumn(Modifier.height(200.dp)) {
itemsIndexed(items) { index, item ->
- BasicText("${index}x$item", Modifier.fillParentMaxWidth().height(100.dp))
+ BasicText(
+ "${index}x$item", Modifier.fillParentMaxWidth().requiredHeight(100.dp)
+ )
}
}
}
@@ -91,10 +93,10 @@
val items = (1..4).map { it.toString() }
rule.setContent {
- LazyRow(Modifier.preferredWidth(200.dp)) {
+ LazyRow(Modifier.width(200.dp)) {
itemsIndexed(items) { index, item ->
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag("$index-$item")
)
}
@@ -119,9 +121,11 @@
val items = (0..1).map { it.toString() }
rule.setContent {
- LazyRow(Modifier.preferredWidth(200.dp)) {
+ LazyRow(Modifier.width(200.dp)) {
itemsIndexed(items) { index, item ->
- BasicText("${index}x$item", Modifier.fillParentMaxHeight().width(100.dp))
+ BasicText(
+ "${index}x$item", Modifier.fillParentMaxHeight().requiredWidth(100.dp)
+ )
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt
index 4ce9bbf..e7e1ae7 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation.lazy
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLayoutDirection
@@ -57,8 +57,8 @@
reverseLayout = true
) {
item {
- Box(Modifier.size(itemSize).testTag("0"))
- Box(Modifier.size(itemSize).testTag("1"))
+ Box(Modifier.requiredSize(itemSize).testTag("0"))
+ Box(Modifier.requiredSize(itemSize).testTag("1"))
}
}
}
@@ -76,10 +76,10 @@
reverseLayout = true
) {
item {
- Box(Modifier.size(itemSize).testTag("0"))
+ Box(Modifier.requiredSize(itemSize).testTag("0"))
}
item {
- Box(Modifier.size(itemSize).testTag("1"))
+ Box(Modifier.requiredSize(itemSize).testTag("1"))
}
}
}
@@ -97,10 +97,10 @@
LazyColumn(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -118,10 +118,10 @@
LazyColumn(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -148,10 +148,10 @@
LazyColumn(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -180,10 +180,10 @@
LazyColumn(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..3).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -213,8 +213,8 @@
reverseLayout = true
) {
item {
- Box(Modifier.size(itemSize).testTag("0"))
- Box(Modifier.size(itemSize).testTag("1"))
+ Box(Modifier.requiredSize(itemSize).testTag("0"))
+ Box(Modifier.requiredSize(itemSize).testTag("1"))
}
}
}
@@ -232,10 +232,10 @@
reverseLayout = true
) {
item {
- Box(Modifier.size(itemSize).testTag("0"))
+ Box(Modifier.requiredSize(itemSize).testTag("0"))
}
item {
- Box(Modifier.size(itemSize).testTag("1"))
+ Box(Modifier.requiredSize(itemSize).testTag("1"))
}
}
}
@@ -253,10 +253,10 @@
LazyRow(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -274,10 +274,10 @@
LazyRow(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -304,10 +304,10 @@
LazyRow(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -336,10 +336,10 @@
LazyRow(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..3).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
@@ -370,8 +370,8 @@
reverseLayout = true
) {
item {
- Box(Modifier.size(itemSize).testTag("0"))
- Box(Modifier.size(itemSize).testTag("1"))
+ Box(Modifier.requiredSize(itemSize).testTag("0"))
+ Box(Modifier.requiredSize(itemSize).testTag("1"))
}
}
}
@@ -391,10 +391,10 @@
reverseLayout = true
) {
item {
- Box(Modifier.size(itemSize).testTag("0"))
+ Box(Modifier.requiredSize(itemSize).testTag("0"))
}
item {
- Box(Modifier.size(itemSize).testTag("1"))
+ Box(Modifier.requiredSize(itemSize).testTag("1"))
}
}
}
@@ -414,10 +414,10 @@
LazyRow(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
- modifier = Modifier.size(itemSize * 2).testTag(ContainerTag)
+ modifier = Modifier.requiredSize(itemSize * 2).testTag(ContainerTag)
) {
items((0..2).toList()) {
- Box(Modifier.size(itemSize).testTag("$it"))
+ Box(Modifier.requiredSize(itemSize).testTag("$it"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyNestedScrollingTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyNestedScrollingTest.kt
index 8968ee7..9341128 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyNestedScrollingTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyNestedScrollingTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.foundation.gestures.Orientation
@@ -66,9 +66,9 @@
state = scrollable
)
) {
- LazyColumn(Modifier.size(100.dp).testTag(LazyTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyTag)) {
items(items) {
- Spacer(Modifier.size(50.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(50.dp).testTag("$it"))
}
}
}
@@ -101,9 +101,9 @@
state = scrollable
)
) {
- LazyColumn(Modifier.size(100.dp).testTag(LazyTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyTag)) {
items(items) {
- Spacer(Modifier.size(50.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(50.dp).testTag("$it"))
}
}
}
@@ -146,9 +146,9 @@
state = scrollable
)
) {
- LazyColumn(Modifier.size(100.dp).testTag(LazyTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyTag)) {
items(items) {
- Spacer(Modifier.size(40.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(40.dp).testTag("$it"))
}
}
}
@@ -181,9 +181,9 @@
state = scrollable
)
) {
- LazyColumn(Modifier.size(100.dp).testTag(LazyTag)) {
+ LazyColumn(Modifier.requiredSize(100.dp).testTag(LazyTag)) {
items(items) {
- Spacer(Modifier.size(50.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(50.dp).testTag("$it"))
}
}
}
@@ -222,10 +222,10 @@
)
) {
LazyRow(
- modifier = Modifier.size(100.dp).testTag(LazyTag)
+ modifier = Modifier.requiredSize(100.dp).testTag(LazyTag)
) {
items(items) {
- Spacer(Modifier.size(50.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(50.dp).testTag("$it"))
}
}
}
@@ -259,10 +259,10 @@
)
) {
LazyRow(
- modifier = Modifier.size(100.dp).testTag(LazyTag)
+ modifier = Modifier.requiredSize(100.dp).testTag(LazyTag)
) {
items(items) {
- Spacer(Modifier.size(50.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(50.dp).testTag("$it"))
}
}
}
@@ -306,10 +306,10 @@
)
) {
LazyRow(
- modifier = Modifier.size(100.dp).testTag(LazyTag)
+ modifier = Modifier.requiredSize(100.dp).testTag(LazyTag)
) {
items(items) {
- Spacer(Modifier.size(40.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(40.dp).testTag("$it"))
}
}
}
@@ -343,10 +343,10 @@
)
) {
LazyRow(
- modifier = Modifier.size(100.dp).testTag(LazyTag)
+ modifier = Modifier.requiredSize(100.dp).testTag(LazyTag)
) {
items(items) {
- Spacer(Modifier.size(50.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(50.dp).testTag("$it"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
index 0e2e3e5..645b66a 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
@@ -21,13 +21,13 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredSizeIn
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -74,18 +74,18 @@
val indexedItems = listOf(3, 4, 5)
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.preferredWidth(200.dp)) {
+ LazyRow(Modifier.width(200.dp)) {
item {
Spacer(
- Modifier.preferredWidth(40.dp).fillParentMaxHeight().testTag(itemTestTag)
+ Modifier.width(40.dp).fillParentMaxHeight().testTag(itemTestTag)
)
}
items(items) {
- Spacer(Modifier.preferredWidth(40.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(40.dp).fillParentMaxHeight().testTag(it))
}
itemsIndexed(indexedItems) { index, item ->
Spacer(
- Modifier.preferredWidth(41.dp).fillParentMaxHeight()
+ Modifier.width(41.dp).fillParentMaxHeight()
.testTag("$index-$item")
)
}
@@ -119,7 +119,7 @@
LazyRow {
items(emptyList<Any>()) { }
item {
- Spacer(Modifier.preferredSize(10.dp).testTag(itemTag))
+ Spacer(Modifier.size(10.dp).testTag(itemTag))
}
}
}
@@ -134,13 +134,13 @@
val nullTestTag = "nullTestTag"
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.preferredWidth(200.dp)) {
+ LazyRow(Modifier.width(200.dp)) {
items(items) {
if (it != null) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
} else {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag(nullTestTag)
)
}
@@ -163,10 +163,10 @@
val items = (1..4).map { it.toString() }
rule.setContentWithTestViewConfiguration {
- Box(Modifier.preferredWidth(200.dp)) {
+ Box(Modifier.width(200.dp)) {
LazyRow {
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
}
}
@@ -190,10 +190,10 @@
val items = (1..4).map { it.toString() }
rule.setContentWithTestViewConfiguration {
- Box(Modifier.preferredWidth(200.dp)) {
+ Box(Modifier.width(200.dp)) {
LazyRow(Modifier.testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
}
}
@@ -220,10 +220,10 @@
val items = (1..4).map { it.toString() }
rule.setContentWithTestViewConfiguration {
- Box(Modifier.preferredWidth(200.dp)) {
+ Box(Modifier.width(200.dp)) {
LazyRow(Modifier.testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
}
}
@@ -247,10 +247,10 @@
val items = (1..4).map { it.toString() }
rule.setContentWithTestViewConfiguration {
- Box(Modifier.preferredWidth(200.dp)) {
+ Box(Modifier.width(200.dp)) {
LazyRow(Modifier.testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag(it))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag(it))
}
}
}
@@ -283,13 +283,13 @@
LazyRow(Modifier.testTag(LazyListTag)) {
items(listOf(1, 2)) {
if (it == 1) {
- Spacer(Modifier.preferredSize(50.dp).testTag(itemInsideLazyRow))
+ Spacer(Modifier.size(50.dp).testTag(itemInsideLazyRow))
} else {
- Spacer(Modifier.preferredSize(if (sameSizeItems) 50.dp else 70.dp))
+ Spacer(Modifier.size(if (sameSizeItems) 50.dp else 70.dp))
}
}
}
- Spacer(Modifier.preferredSize(50.dp).testTag(itemOutsideLazyRow))
+ Spacer(Modifier.size(50.dp).testTag(itemOutsideLazyRow))
}
}
@@ -334,14 +334,14 @@
private fun prepareLazyRowForAlignment(verticalGravity: Alignment.Vertical) {
rule.setContentWithTestViewConfiguration {
LazyRow(
- Modifier.testTag(LazyListTag).height(100.dp),
+ Modifier.testTag(LazyListTag).requiredHeight(100.dp),
verticalAlignment = verticalGravity
) {
items(listOf(1, 2)) {
if (it == 1) {
- Spacer(Modifier.preferredSize(50.dp).testTag(firstItemTag))
+ Spacer(Modifier.size(50.dp).testTag(firstItemTag))
} else {
- Spacer(Modifier.preferredSize(70.dp).testTag(secondItemTag))
+ Spacer(Modifier.size(70.dp).testTag(secondItemTag))
}
}
}
@@ -399,9 +399,11 @@
@Test
fun itemFillingParentWidth() {
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyRow(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.fillParentMaxWidth().height(50.dp).testTag(firstItemTag))
+ Spacer(
+ Modifier.fillParentMaxWidth().requiredHeight(50.dp).testTag(firstItemTag)
+ )
}
}
}
@@ -414,9 +416,11 @@
@Test
fun itemFillingParentHeight() {
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyRow(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.width(50.dp).fillParentMaxHeight().testTag(firstItemTag))
+ Spacer(
+ Modifier.requiredWidth(50.dp).fillParentMaxHeight().testTag(firstItemTag)
+ )
}
}
}
@@ -429,7 +433,7 @@
@Test
fun itemFillingParentSize() {
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyRow(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
Spacer(Modifier.fillParentMaxSize().testTag(firstItemTag))
}
@@ -444,9 +448,13 @@
@Test
fun itemFillingParentWidthFraction() {
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyRow(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.fillParentMaxWidth(0.7f).height(50.dp).testTag(firstItemTag))
+ Spacer(
+ Modifier.fillParentMaxWidth(0.7f)
+ .requiredHeight(50.dp)
+ .testTag(firstItemTag)
+ )
}
}
}
@@ -459,9 +467,13 @@
@Test
fun itemFillingParentHeightFraction() {
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyRow(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
- Spacer(Modifier.width(50.dp).fillParentMaxHeight(0.3f).testTag(firstItemTag))
+ Spacer(
+ Modifier.requiredWidth(50.dp)
+ .fillParentMaxHeight(0.3f)
+ .testTag(firstItemTag)
+ )
}
}
}
@@ -474,7 +486,7 @@
@Test
fun itemFillingParentSizeFraction() {
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(width = 100.dp, height = 150.dp)) {
+ LazyRow(Modifier.requiredSize(width = 100.dp, height = 150.dp)) {
items(listOf(0)) {
Spacer(Modifier.fillParentMaxSize(0.5f).testTag(firstItemTag))
}
@@ -490,7 +502,7 @@
fun itemFillingParentSizeParentResized() {
var parentSize by mutableStateOf(100.dp)
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(parentSize)) {
+ LazyRow(Modifier.requiredSize(parentSize)) {
items(listOf(0)) {
Spacer(Modifier.fillParentMaxSize().testTag(firstItemTag))
}
@@ -510,11 +522,11 @@
fun scrollsLeftInRtl() {
rule.setContentWithTestViewConfiguration {
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
- Box(Modifier.preferredWidth(100.dp)) {
+ Box(Modifier.width(100.dp)) {
LazyRow(Modifier.testTag(LazyListTag)) {
items(4) {
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag("$it")
+ Modifier.width(101.dp).fillParentMaxHeight().testTag("$it")
)
}
}
@@ -536,9 +548,9 @@
fun whenNotAnymoreAvailableItemWasDisplayed() {
var items by mutableStateOf((1..30).toList())
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -560,9 +572,9 @@
fun whenFewDisplayedItemsWereRemoved() {
var items by mutableStateOf((1..10).toList())
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -584,9 +596,9 @@
fun whenItemsBecameEmpty() {
var items by mutableStateOf((1..10).toList())
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.sizeIn(maxHeight = 100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSizeIn(maxHeight = 100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -615,9 +627,9 @@
fun scrollBackAndForth() {
val items by mutableStateOf((1..20).toList())
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -638,9 +650,9 @@
fun tryToScrollBackwardWhenAlreadyOnTop() {
val items by mutableStateOf((1..20).toList())
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -665,14 +677,14 @@
var firstItemRecomposed = 0
var secondItemRecomposed = 0
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(items) {
if (it.count == 1) {
firstItemRecomposed++
} else {
secondItemRecomposed++
}
- Spacer(Modifier.size(75.dp))
+ Spacer(Modifier.requiredSize(75.dp))
}
}
}
@@ -697,9 +709,9 @@
lateinit var state: LazyListState
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
- LazyRow(Modifier.size(100.dp), state = state) {
+ LazyRow(Modifier.requiredSize(100.dp), state = state) {
items(items) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -723,11 +735,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyRow(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -759,11 +771,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyRow(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -788,9 +800,9 @@
val expectedOffset = with(rule.density) { 10.dp.roundToPx() }
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState(2, expectedOffset)
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag), state = state) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag), state = state) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -811,11 +823,11 @@
restorationTester.setContent {
state = rememberLazyListState()
LazyRow(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state!!
) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -843,11 +855,11 @@
rule.setContentWithTestViewConfiguration {
state = rememberLazyListState()
LazyRow(
- Modifier.size(100.dp).testTag(LazyListTag),
+ Modifier.requiredSize(100.dp).testTag(LazyListTag),
state = state
) {
items(20) {
- Spacer(Modifier.size(20.dp).testTag("$it"))
+ Spacer(Modifier.requiredSize(20.dp).testTag("$it"))
}
}
}
@@ -865,10 +877,10 @@
fun itemsAreNotRedrawnDuringScroll() {
val redrawCount = Array(6) { 0 }
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(21) {
Spacer(
- Modifier.size(20.dp)
+ Modifier.requiredSize(20.dp)
.drawBehind { redrawCount[it]++ }
)
}
@@ -891,10 +903,10 @@
val redrawCount = Array(2) { 0 }
var stateUsedInDrawScope by mutableStateOf(false)
rule.setContentWithTestViewConfiguration {
- LazyRow(Modifier.size(100.dp).testTag(LazyListTag)) {
+ LazyRow(Modifier.requiredSize(100.dp).testTag(LazyListTag)) {
items(2) {
Spacer(
- Modifier.size(50.dp)
+ Modifier.requiredSize(50.dp)
.drawBehind {
redrawCount[it]++
if (it == 1) {
@@ -926,15 +938,15 @@
lateinit var state: LazyListState
rule.setContentWithTestViewConfiguration {
LazyRow(
- Modifier.width(itemSizeMinusOne).testTag(LazyListTag),
+ Modifier.requiredWidth(itemSizeMinusOne).testTag(LazyListTag),
state = rememberLazyListState().also { state = it }
) {
items(items) {
Spacer(
if (it == 0) {
- Modifier.height(30.dp).width(itemSizeMinusOne)
+ Modifier.requiredHeight(30.dp).requiredWidth(itemSizeMinusOne)
} else {
- Modifier.height(20.dp).width(itemSize)
+ Modifier.requiredHeight(20.dp).requiredWidth(itemSize)
}
)
}
@@ -954,17 +966,17 @@
lateinit var state: LazyListState
rule.setContentWithTestViewConfiguration {
LazyRow(
- Modifier.width(itemSize * 1.75f).testTag(LazyListTag),
+ Modifier.requiredWidth(itemSize * 1.75f).testTag(LazyListTag),
state = rememberLazyListState().also { state = it }
) {
items(items) {
Spacer(
if (it == 0) {
- Modifier.height(30.dp).width(itemSize / 2)
+ Modifier.requiredHeight(30.dp).requiredWidth(itemSize / 2)
} else if (it == 1) {
- Modifier.height(20.dp).width(itemSize / 2)
+ Modifier.requiredHeight(20.dp).requiredWidth(itemSize / 2)
} else {
- Modifier.height(20.dp).width(itemSize)
+ Modifier.requiredHeight(20.dp).requiredWidth(itemSize)
}
)
}
@@ -986,7 +998,7 @@
rule.setContentWithTestViewConfiguration {
LazyRow {
items(items) {
- Spacer(Modifier.size(itemSize).testTag(it))
+ Spacer(Modifier.requiredSize(itemSize).testTag(it))
}
}
}
@@ -1010,7 +1022,7 @@
rule.setContentWithTestViewConfiguration {
LazyRow {
itemsIndexed(items) { index, item ->
- Spacer(Modifier.size(itemSize).testTag("$index*$item"))
+ Spacer(Modifier.requiredSize(itemSize).testTag("$index*$item"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyScrollTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyScrollTest.kt
index 15c7779..4f54427 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyScrollTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyScrollTest.kt
@@ -19,8 +19,8 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.animation.smoothScrollBy
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.foundation.gestures.Orientation
@@ -93,13 +93,13 @@
@Composable
private fun TestContent() {
if (vertical) {
- LazyColumn(Modifier.preferredHeight(300.dp), state) {
+ LazyColumn(Modifier.height(300.dp), state) {
items(items) {
ItemContent()
}
}
} else {
- LazyRow(Modifier.preferredWidth(300.dp), state) {
+ LazyRow(Modifier.width(300.dp), state) {
items(items) {
ItemContent()
}
@@ -110,9 +110,9 @@
@Composable
private fun ItemContent() {
val modifier = if (vertical) {
- Modifier.preferredHeight(101.dp)
+ Modifier.height(101.dp)
} else {
- Modifier.preferredWidth(101.dp)
+ Modifier.width(101.dp)
}
Spacer(modifier)
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
index de41f49..f6910c7 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
@@ -16,8 +16,8 @@
package androidx.compose.foundation.text
-import androidx.compose.foundation.layout.width
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
@@ -72,7 +72,7 @@
textStyle = textStyle,
softWrap = false,
textLayout = it },
- modifier = Modifier.width(composableWidth)
+ modifier = Modifier.requiredWidth(composableWidth)
.onGloballyPositioned {
width = it.size.width
}
@@ -109,7 +109,7 @@
textStyle = textStyle,
softWrap = true,
textLayout = it },
- modifier = Modifier.width(composableWidth)
+ modifier = Modifier.requiredWidth(composableWidth)
.onGloballyPositioned {
width = it.size.width
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldInteractionsTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldInteractionsTest.kt
index 6f6eae8..afd2fa4 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldInteractionsTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldInteractionsTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.focusable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
@@ -117,7 +117,7 @@
interactionState = interactionState
)
Box(
- modifier = Modifier.size(10.dp).focusRequester(focusRequester).focusable(),
+ modifier = Modifier.requiredSize(10.dp).focusRequester(focusRequester).focusable(),
)
}
assertThat(interactionState.value).doesNotContain(Interaction.Focused)
@@ -191,7 +191,7 @@
val interactionState = InteractionState()
rule.setContent {
BasicTextField(
- modifier = Modifier.size(50.dp).testTag(testTag),
+ modifier = Modifier.requiredSize(50.dp).testTag(testTag),
value = state.value,
maxLines = 3,
state.value = it },
@@ -218,7 +218,7 @@
val interactionState = InteractionState()
rule.setContent {
BasicTextField(
- modifier = Modifier.size(50.dp).testTag(testTag),
+ modifier = Modifier.requiredSize(50.dp).testTag(testTag),
value = state.value,
maxLines = 3,
state.value = it },
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerFocusTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerFocusTest.kt
index dd11d29..b6c2a5c 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerFocusTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerFocusTest.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.CoreText
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
@@ -204,7 +204,7 @@
)
}
- Box(Modifier.preferredSize(boxSize, boxSize).testTag("box"))
+ Box(Modifier.size(boxSize, boxSize).testTag("box"))
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/InactiveTextFieldTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/InactiveTextFieldTest.kt
index eb4cf5d..98a2f91 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/InactiveTextFieldTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/InactiveTextFieldTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.Interaction
import androidx.compose.foundation.InteractionState
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.InactiveTextField
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
@@ -101,7 +101,7 @@
rule.setContent {
InactiveTextField(
value = text,
- modifier = Modifier.testTag(tag).width(100.dp).composed {
+ modifier = Modifier.testTag(tag).requiredWidth(100.dp).composed {
assertThat(LocalSelectionRegistrar.current).isNull()
Modifier
},
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/MaxLinesHeightModifierTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/MaxLinesHeightModifierTest.kt
index 883f3f3..4632d48 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/MaxLinesHeightModifierTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/MaxLinesHeightModifierTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation.textfield
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.CoreTextField
import androidx.compose.foundation.text.maxLinesHeight
import androidx.compose.ui.Modifier
@@ -137,7 +137,7 @@
>
textStyle = TextStyle.Default,
modifier = Modifier
- .width(100.dp)
+ .requiredWidth(100.dp)
.maxLinesHeight(maxLines, TextStyle.Default),
textLayoutResult = it }
)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldCursorTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldCursorTest.kt
index 540de28..a27fa75 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldCursorTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldCursorTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -71,7 +71,7 @@
>
textStyle = TextStyle(color = Color.White, background = Color.White),
modifier = Modifier
- .preferredSize(width, height)
+ .size(width, height)
.background(Color.White)
.onFocusChanged { if (it.isFocused) isFocused = true },
cursorBrush = SolidColor(Color.Red)
@@ -102,7 +102,7 @@
>
textStyle = TextStyle(color = Color.White, background = Color.White),
modifier = Modifier
- .preferredSize(width, height)
+ .size(width, height)
.background(Color.White)
.onFocusChanged { if (it.isFocused) isFocused = true },
cursorBrush = Brush.verticalGradient(
@@ -145,7 +145,7 @@
>
textStyle = TextStyle(color = Color.White, background = Color.White),
modifier = Modifier
- .preferredSize(width, height)
+ .size(width, height)
.background(Color.White)
.onFocusChanged { if (it.isFocused) isFocused = true },
cursorBrush = SolidColor(Color.Red)
@@ -193,7 +193,7 @@
>
textStyle = TextStyle(color = Color.White, background = Color.White),
modifier = Modifier
- .preferredSize(width, height)
+ .size(width, height)
.background(Color.White)
.onFocusChanged { if (it.isFocused) isFocused = true },
cursorBrush = SolidColor(Color.Unspecified)
@@ -245,7 +245,7 @@
text.value = it },
textStyle = TextStyle(color = Color.White, background = Color.White),
modifier = Modifier
- .preferredSize(width, height)
+ .size(width, height)
.background(Color.White)
.onFocusChanged { if (it.isFocused) isFocused = true },
cursorBrush = SolidColor(Color.Red)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt
index c635d26..c10ed13 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt
@@ -18,8 +18,8 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.defaultMinSize
-import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -105,7 +105,7 @@
fontSize = fontSize,
modifier = Modifier
.onGloballyPositioned { size = it.size.width }
- .width(width),
+ .requiredWidth(width),
density = density
)
}
@@ -161,7 +161,7 @@
text = "abc",
fontSize = fontSize,
modifier = Modifier
- .preferredWidth(textFieldWidth)
+ .width(textFieldWidth)
.onGloballyPositioned { size = it.size.width },
density = density
)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldFocusTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldFocusTest.kt
index 3441d8b..4d585f2 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldFocusTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldFocusTest.kt
@@ -16,7 +16,7 @@
package androidx.compose.foundation.textfield
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.CoreTextField
import androidx.compose.runtime.Composable
@@ -55,7 +55,7 @@
modifier = Modifier
.focusRequester(data.focusRequester)
.onFocusChanged { data.focused = it.isFocused }
- .width(10.dp),
+ .requiredWidth(10.dp),
>
editor.value = it
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
index 1edb801..3ac1c3b 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
@@ -24,8 +24,8 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.TextFieldScrollerPosition
import androidx.compose.foundation.text.TextLayoutResultProxy
@@ -118,7 +118,7 @@
val scrollerPosition = TextFieldScrollerPosition(Orientation.Horizontal)
rule.setupHorizontallyScrollableContent(
- scrollerPosition, longText, Modifier.preferredSize(width = 300.dp, height = 50.dp)
+ scrollerPosition, longText, Modifier.size(width = 300.dp, height = 50.dp)
)
rule.runOnIdle {
@@ -134,7 +134,7 @@
rule.setupVerticallyScrollableContent(
scrollerPosition = scrollerPosition,
text = longText,
- modifier = Modifier.preferredSize(width = 300.dp, height = 50.dp)
+ modifier = Modifier.size(width = 300.dp, height = 50.dp)
)
rule.runOnIdle {
@@ -148,7 +148,7 @@
val scrollerPosition = TextFieldScrollerPosition()
rule.setupVerticallyScrollableContent(
- modifier = Modifier.preferredWidth(100.dp),
+ modifier = Modifier.width(100.dp),
scrollerPosition = scrollerPosition,
text = longText,
maxLines = 3
@@ -167,7 +167,7 @@
rule.setupHorizontallyScrollableContent(
scrollerPosition = scrollerPosition,
text = "text",
- modifier = Modifier.preferredSize(width = 300.dp, height = 50.dp)
+ modifier = Modifier.size(width = 300.dp, height = 50.dp)
)
rule.runOnIdle {
@@ -182,7 +182,7 @@
rule.setupVerticallyScrollableContent(
scrollerPosition = scrollerPosition,
text = "text",
- modifier = Modifier.preferredSize(width = 300.dp, height = 100.dp)
+ modifier = Modifier.size(width = 300.dp, height = 100.dp)
)
rule.runOnIdle {
@@ -202,12 +202,12 @@
rule.setContent {
Box(
Modifier
- .preferredSize(parentSize.toDp())
+ .size(parentSize.toDp())
.background(color = Color.White)
.testTag(tag)
) {
ScrollableContent(
- modifier = Modifier.preferredSize(textFieldSize.toDp()),
+ modifier = Modifier.size(textFieldSize.toDp()),
scrollerPosition = TextFieldScrollerPosition(Orientation.Horizontal),
text = longText,
isVertical = false
@@ -237,12 +237,12 @@
rule.setContent {
Box(
Modifier
- .preferredSize(parentSize.toDp())
+ .size(parentSize.toDp())
.background(color = Color.White)
.testTag(tag)
) {
ScrollableContent(
- modifier = Modifier.preferredSize(textFieldSize.toDp()),
+ modifier = Modifier.size(textFieldSize.toDp()),
scrollerPosition = TextFieldScrollerPosition(),
text = longText,
isVertical = true
@@ -267,7 +267,7 @@
rule.setupHorizontallyScrollableContent(
scrollerPosition = scrollerPosition,
text = longText,
- modifier = Modifier.preferredSize(width = 300.dp, height = 50.dp)
+ modifier = Modifier.size(width = 300.dp, height = 50.dp)
)
rule.runOnIdle {
@@ -296,7 +296,7 @@
rule.setupVerticallyScrollableContent(
scrollerPosition = scrollerPosition,
text = longText,
- modifier = Modifier.preferredSize(width = 300.dp, height = 50.dp)
+ modifier = Modifier.size(width = 300.dp, height = 50.dp)
)
rule.runOnIdle {
@@ -330,7 +330,7 @@
TextFieldScrollerPosition(Orientation.Horizontal)
}
ScrollableContent(
- modifier = Modifier.preferredSize(width = 300.dp, height = 50.dp),
+ modifier = Modifier.size(width = 300.dp, height = 50.dp),
scrollerPosition = scrollerPosition!!,
text = longText,
isVertical = false
@@ -393,17 +393,17 @@
touchSlop = LocalViewConfiguration.current.touchSlop
Column(
Modifier
- .preferredSize(size)
+ .size(size)
.verticalScroll(scrollerPosition)
) {
ScrollableContent(
- modifier = Modifier.preferredSize(size, height),
+ modifier = Modifier.size(size, height),
scrollerPosition = textFieldScrollPosition,
text = text,
isVertical = true
)
- Box(Modifier.preferredSize(size))
- Box(Modifier.preferredSize(size))
+ Box(Modifier.size(size))
+ Box(Modifier.size(size))
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
index 8129296..b379df0 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
@@ -30,8 +30,8 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
@@ -353,7 +353,7 @@
val boxSize = 50.dp
var size: Int? = null
rule.setContent {
- Box(Modifier.preferredSize(parentSize)) {
+ Box(Modifier.size(parentSize)) {
Row {
BasicTextField(
value = "",
@@ -364,7 +364,7 @@
size = it.size.width
}
)
- Box(Modifier.preferredSize(boxSize))
+ Box(Modifier.size(boxSize))
}
}
}
@@ -407,7 +407,7 @@
value = "",
>
textStyle = TextStyle(color = Color.White),
- modifier = Modifier.preferredSize(10.dp, 20.dp).background(color = Color.White),
+ modifier = Modifier.size(10.dp, 20.dp).background(color = Color.White),
cursorBrush = SolidColor(Color.Blue)
)
}
@@ -684,7 +684,7 @@
value = "test",
>
textStyle = TextStyle(fontSize = 2.sp),
- modifier = Modifier.height(100.dp).fillMaxWidth(),
+ modifier = Modifier.requiredHeight(100.dp).fillMaxWidth(),
decorationBox = {
// the core text field is at the very bottom
Column {
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/CachingItemContentFactory.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/CachingItemContentFactory.kt
index 86e1e7a..1f4f5e4 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/CachingItemContentFactory.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/CachingItemContentFactory.kt
@@ -16,9 +16,9 @@
package androidx.compose.foundation.lazy
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
@@ -92,14 +92,14 @@
val maxWidth: Dp,
val maxHeight: Dp
) : LazyItemScope {
- override fun Modifier.fillParentMaxSize(fraction: Float) = preferredSize(
+ override fun Modifier.fillParentMaxSize(fraction: Float) = size(
maxWidth * fraction,
maxHeight * fraction
)
override fun Modifier.fillParentMaxWidth(fraction: Float) =
- preferredWidth(maxWidth * fraction)
+ width(maxWidth * fraction)
override fun Modifier.fillParentMaxHeight(fraction: Float) =
- preferredHeight(maxHeight * fraction)
+ height(maxHeight * fraction)
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
index f23a824..e8aa158 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
@@ -16,7 +16,7 @@
package androidx.compose.foundation.text
-import androidx.compose.foundation.layout.preferredHeightIn
+import androidx.compose.foundation.layout.heightIn
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
@@ -75,7 +75,7 @@
val lineHeight = firstTwoLinesHeight - firstLineHeight
val precomputedMaxLinesHeight = firstLineHeight + lineHeight * (maxLines - 1)
- Modifier.preferredHeightIn(
+ Modifier.heightIn(
max = with(density) { precomputedMaxLinesHeight.toDp() }
)
}
\ No newline at end of file
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/OnPositionedBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/OnPositionedBenchmark.kt
index 24a98f9..b14c52c 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/OnPositionedBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/OnPositionedBenchmark.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
@@ -60,7 +60,7 @@
val size = remember { mutableStateOf(200.dp) }
this.state = size
Box {
- Box(Modifier.preferredSize(size.value), contentAlignment = Alignment.Center) {
+ Box(Modifier.size(size.value), contentAlignment = Alignment.Center) {
StaticChildren(100)
}
}
@@ -75,7 +75,7 @@
Modifier
}
Box(
- Modifier.preferredSize(100.dp).then(modifier),
+ Modifier.size(100.dp).then(modifier),
contentAlignment = Alignment.Center
) {
StaticChildren(count - 1)
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/WithConstraintsBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/WithConstraintsBenchmark.kt
index 4c0bcbd..b57c79a 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/WithConstraintsBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/WithConstraintsBenchmark.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.State
@@ -74,8 +74,8 @@
override fun Content() {
val size = remember { mutableStateOf(200.dp) }
this.state = size
- Box(Modifier.preferredSize(300.dp), contentAlignment = Alignment.Center) {
- Spacer(Modifier.preferredSize(width = size.value, height = size.value))
+ Box(Modifier.size(300.dp), contentAlignment = Alignment.Center) {
+ Spacer(Modifier.size(width = size.value, height = size.value))
}
}
@@ -93,8 +93,8 @@
val size = remember { mutableStateOf(200.dp) }
this.state = size
BoxWithConstraints {
- Box(Modifier.preferredSize(300.dp), contentAlignment = Alignment.Center) {
- Spacer(Modifier.preferredSize(width = size.value, height = size.value))
+ Box(Modifier.size(300.dp), contentAlignment = Alignment.Center) {
+ Spacer(Modifier.size(width = size.value, height = size.value))
}
}
}
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt
index e552c40..3e1e792 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt
@@ -20,9 +20,9 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
@@ -106,7 +106,7 @@
}
private val LazyColumnWithItemAndItems = LazyListScrollingTestCase("LazyColumnWithItemAndItems") {
- LazyColumn(modifier = Modifier.height(400.dp).fillMaxWidth()) {
+ LazyColumn(modifier = Modifier.requiredHeight(400.dp).fillMaxWidth()) {
item {
RemeasurableItem()
}
@@ -117,7 +117,7 @@
}
private val LazyColumnWithItems = LazyListScrollingTestCase("LazyColumnWithItems") {
- LazyColumn(modifier = Modifier.height(400.dp).fillMaxWidth()) {
+ LazyColumn(modifier = Modifier.requiredHeight(400.dp).fillMaxWidth()) {
items(items) {
if (it.index == 0) {
RemeasurableItem()
@@ -129,7 +129,7 @@
}
private val LazyColumnWithItemsIndexed = LazyListScrollingTestCase("LazyColumnWithItemsIndexed") {
- LazyColumn(modifier = Modifier.height(400.dp).fillMaxWidth()) {
+ LazyColumn(modifier = Modifier.requiredHeight(400.dp).fillMaxWidth()) {
itemsIndexed(items) { index, _ ->
if (index == 0) {
RemeasurableItem()
@@ -141,7 +141,7 @@
}
private val LazyRowWithItemAndItems = LazyListScrollingTestCase("LazyRowWithItemAndItems") {
- LazyRow(modifier = Modifier.width(400.dp).fillMaxHeight()) {
+ LazyRow(modifier = Modifier.requiredWidth(400.dp).fillMaxHeight()) {
item {
RemeasurableItem()
}
@@ -152,7 +152,7 @@
}
private val LazyRowWithItems = LazyListScrollingTestCase("LazyRowWithItems") {
- LazyRow(modifier = Modifier.width(400.dp).fillMaxHeight()) {
+ LazyRow(modifier = Modifier.requiredWidth(400.dp).fillMaxHeight()) {
items(items) {
if (it.index == 0) {
RemeasurableItem()
@@ -164,7 +164,7 @@
}
private val LazyRowWithItemsIndexed = LazyListScrollingTestCase("LazyRowWithItemsIndexed") {
- LazyRow(modifier = Modifier.width(400.dp).fillMaxHeight()) {
+ LazyRow(modifier = Modifier.requiredWidth(400.dp).fillMaxHeight()) {
itemsIndexed(items) { index, _ ->
if (index == 0) {
RemeasurableItem()
@@ -255,7 +255,7 @@
@Composable
fun RegularItem() {
- Box(Modifier.size(20.dp).background(Color.Red, RoundedCornerShape(8.dp)))
+ Box(Modifier.requiredSize(20.dp).background(Color.Red, RoundedCornerShape(8.dp)))
}
fun prepareForToggle() {
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/TrailingLambdaBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/TrailingLambdaBenchmark.kt
index 0c5451b..cfa8133 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/TrailingLambdaBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/TrailingLambdaBenchmark.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
@@ -73,7 +73,7 @@
numberState = number
val content = @Composable {
- Box(Modifier.preferredWidth(10.dp))
+ Box(Modifier.width(10.dp))
}
Column {
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt
index 5b723d0..b551802 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@@ -184,7 +184,7 @@
}
}
.fillMaxWidth()
- .height(itemHeightDp)
+ .requiredHeight(itemHeightDp)
)
}
}
diff --git a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
index d60c8fc..fdfbc3e 100644
--- a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
+++ b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@@ -134,7 +134,7 @@
ListItem(
text = {
Text(
- modifier = Modifier.preferredHeight(56.dp)
+ modifier = Modifier.height(56.dp)
.wrapContentSize(Alignment.Center),
text = demo.title
)
diff --git a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt
index e669332..7ec052c 100644
--- a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt
+++ b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicTextField
@@ -160,7 +160,7 @@
ListItem(
text = {
Text(
- modifier = Modifier.preferredHeight(56.dp).wrapContentSize(Alignment.Center),
+ modifier = Modifier.height(56.dp).wrapContentSize(Alignment.Center),
text = annotatedString
)
},
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/accessibility/Accessibility.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/accessibility/Accessibility.kt
index 0f72d12..23d4a24 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/accessibility/Accessibility.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/accessibility/Accessibility.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.toggleable
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
@@ -82,7 +82,7 @@
// Specify that this image has no semantic meaning
contentDescription = null,
modifier = modifier
- .preferredSize(40.dp, 40.dp)
+ .size(40.dp, 40.dp)
.clip(MaterialTheme.shapes.small)
)
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt
index 8f96531..e6186af 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/layout/Layout.kt
@@ -27,7 +27,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
@@ -100,7 +100,7 @@
.fillMaxWidth()
) {
Row(verticalAlignment = Alignment.CenterVertically) { /*...*/ }
- Spacer(Modifier.preferredSize(padding))
+ Spacer(Modifier.size(padding))
Card(elevation = 4.dp) { /*...*/ }
}
}
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt
index 44b997a..da8c1bc 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/tutorial/Tutorial.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
@@ -176,7 +176,7 @@
modifier = Modifier.padding(16.dp)
) {
val imageModifier = Modifier
- .preferredHeight(180.dp)
+ .height(180.dp)
.fillMaxWidth()
Image(
@@ -204,7 +204,7 @@
modifier = Modifier.padding(16.dp)
) {
val imageModifier = Modifier
- .preferredHeight(180.dp)
+ .height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
@@ -214,7 +214,7 @@
modifier = imageModifier,
contentScale = ContentScale.Crop
)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Text("A day in Shark Fin Cove")
Text("Davenport, California")
@@ -232,7 +232,7 @@
modifier = Modifier.padding(16.dp)
) {
val imageModifier = Modifier
- .preferredHeight(180.dp)
+ .height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
@@ -242,7 +242,7 @@
modifier = imageModifier,
contentScale = ContentScale.Crop
)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Text("A day in Shark Fin Cove")
Text("Davenport, California")
@@ -262,7 +262,7 @@
modifier = Modifier.padding(16.dp)
) {
val imageModifier = Modifier
- .preferredHeight(180.dp)
+ .height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
@@ -272,7 +272,7 @@
modifier = imageModifier,
contentScale = ContentScale.Crop
)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Text("A day in Shark Fin Cove",
style = typography.h6)
@@ -295,7 +295,7 @@
modifier = Modifier.padding(16.dp)
) {
val imageModifier = Modifier
- .preferredHeight(180.dp)
+ .height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
@@ -305,7 +305,7 @@
modifier = imageModifier,
contentScale = ContentScale.Crop
)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Text(
"A day wandering through the sandhills " +
@@ -332,7 +332,7 @@
modifier = Modifier.padding(16.dp)
) {
val imageModifier = Modifier
- .preferredHeight(180.dp)
+ .height(180.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(4.dp))
@@ -341,7 +341,7 @@
modifier = imageModifier,
contentScale = ContentScale.Crop
)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Text(
"A day wandering through the sandhills " +
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithModifiersTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithModifiersTestCase.kt
index 0b8eec1e..dbf4fed 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithModifiersTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithModifiersTestCase.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@@ -33,7 +33,7 @@
override fun Content() {
val innerSize = getInnerSize()
Box(
- Modifier.preferredSize(48.dp)
+ Modifier.size(48.dp)
.background(color = Color.Cyan)
.padding(innerSize.value)
.border(
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithRedrawTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithRedrawTestCase.kt
index 723d756..149ee4a 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithRedrawTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithRedrawTestCase.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.Canvas
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.dp
class ComponentWithRedrawTestCase : SimpleComponentImplenentationTestCase() {
@@ -30,7 +30,7 @@
override fun Content() {
val innerSize = getInnerSize()
val stroke = Stroke()
- Canvas(Modifier.preferredSize(48.dp)) {
+ Canvas(Modifier.size(48.dp)) {
drawCircle(Color.Black, size.minDimension, style = stroke)
drawCircle(Color.Black, innerSize.value.value / 2f, center)
}
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithTwoLayoutNodesTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithTwoLayoutNodesTestCase.kt
index dbf855e..b0482eb 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithTwoLayoutNodesTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/ComponentWithTwoLayoutNodesTestCase.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -35,13 +35,13 @@
override fun Content() {
Box(
modifier = Modifier
- .preferredSize(48.dp)
+ .size(48.dp)
.border(BorderStroke(1.dp, Color.Cyan), CircleShape)
.padding(1.dp),
contentAlignment = Alignment.Center
) {
val innerSize = getInnerSize().value
- Canvas(Modifier.preferredSize(innerSize)) {
+ Canvas(Modifier.size(innerSize)) {
drawOutline(
CircleShape.createOutline(size, layoutDirection, this),
Color.Cyan
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextFieldToggleTextTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextFieldToggleTextTestCase.kt
index aafa6ad..7f6addc 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextFieldToggleTextTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextFieldToggleTextTestCase.kt
@@ -20,8 +20,8 @@
import androidx.compose.foundation.InternalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
@@ -65,7 +65,7 @@
value = text.value,
>
textStyle = TextStyle(color = Color.Black, fontSize = fontSize),
- modifier = Modifier.background(color = Color.Cyan).width(width)
+ modifier = Modifier.background(color = Color.Cyan).requiredWidth(width)
)
}
}
@@ -81,7 +81,7 @@
textInputService
}
Column(
- modifier = Modifier.preferredWidth(width)
+ modifier = Modifier.width(width)
) {
content()
}
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt
index 822e6ff..2e0f264 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt
@@ -17,7 +17,7 @@
package androidx.ui.integration.test.core.text
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -52,7 +52,7 @@
@Composable
override fun ContentWrappers(content: @Composable () -> Unit) {
Column(
- modifier = Modifier.wrapContentSize(Alignment.Center).preferredWidth(width)
+ modifier = Modifier.wrapContentSize(Alignment.Center).width(width)
) {
content()
}
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt
index 21985bf..76f3cfc 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt
@@ -17,7 +17,7 @@
package androidx.ui.integration.test.core.text
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -46,7 +46,7 @@
@Composable
override fun Content() {
Column(
- modifier = Modifier.wrapContentSize(Alignment.Center).preferredWidth(width)
+ modifier = Modifier.wrapContentSize(Alignment.Center).width(width)
) {
for (text in texts) {
Text(text = text.value, color = Color.Black, fontSize = fontSize)
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
index ee62674..b733461 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.MaterialTheme
@@ -80,7 +80,7 @@
val blue = Random.nextInt(256)
Color(red = red, green = green, blue = blue)
}
- Box(Modifier.preferredSize(350f.toDp()).background(color = color))
+ Box(Modifier.size(350f.toDp()).background(color = color))
Text(
text = "Some title",
color = Color.Black,
@@ -95,7 +95,7 @@
Box(
Modifier
.align(Alignment.CenterVertically)
- .preferredSize(40f.toDp())
+ .size(40f.toDp())
.background(color = playStoreColor)
)
}
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnSharedModelTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnSharedModelTestCase.kt
index 5acfb27..4c390a3 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnSharedModelTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnSharedModelTestCase.kt
@@ -25,7 +25,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.foundation.layout.Column
import androidx.compose.material.MaterialTheme
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.testutils.ComposeTestCase
import androidx.compose.testutils.ToggleableTestCase
@@ -48,9 +48,9 @@
Column {
repeat(amountOfRectangles) { i ->
if (i == 0) {
- Box(Modifier.preferredSize(100.dp, 50.dp).background(color = color.value))
+ Box(Modifier.size(100.dp, 50.dp).background(color = color.value))
} else {
- Box(Modifier.preferredSize(100.dp, 50.dp).background(color = Color.Green))
+ Box(Modifier.size(100.dp, 50.dp).background(color = Color.Green))
}
}
}
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnTestCase.kt
index f6d2021..88287ef 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/RectsInColumnTestCase.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
@@ -70,6 +70,6 @@
fun ColoredRectWithModel() {
val state = remember { mutableStateOf(Color.Black) }
states.add(state)
- Box(Modifier.preferredSize(100.dp, 50.dp).background(color = state.value))
+ Box(Modifier.size(100.dp, 50.dp).background(color = state.value))
}
}
\ No newline at end of file
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/ScrollerTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/ScrollerTestCase.kt
index 60e317a..ebb4aff 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/ScrollerTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/ScrollerTestCase.kt
@@ -24,7 +24,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.verticalScroll
import androidx.compose.testutils.ComposeTestCase
import androidx.compose.testutils.ToggleableTestCase
@@ -70,7 +70,7 @@
@Composable
fun ColorStripe(red: Int, green: Int, blue: Int) {
- Canvas(Modifier.preferredSize(45.dp, 5.dp)) {
+ Canvas(Modifier.size(45.dp, 5.dp)) {
drawRect(Color(red = red, green = green, blue = blue))
}
}
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/framework/ImageVectorTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/framework/ImageVectorTestCase.kt
index e5e797a..b2240f1 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/framework/ImageVectorTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/framework/ImageVectorTestCase.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.PathData
import androidx.compose.ui.graphics.vector.ImageVector
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.testutils.ComposeTestCase
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.res.painterResource
@@ -47,7 +47,7 @@
Box {
Box(
Modifier.testTag(testTag)
- .preferredSize(24.dp)
+ .size(24.dp)
.paint(getPainter())
)
}
diff --git a/compose/internal-lint-checks/src/main/java/androidx/compose/lint/ModifierInspectorInfoDetector.kt b/compose/internal-lint-checks/src/main/java/androidx/compose/lint/ModifierInspectorInfoDetector.kt
index e385acc..c863270 100644
--- a/compose/internal-lint-checks/src/main/java/androidx/compose/lint/ModifierInspectorInfoDetector.kt
+++ b/compose/internal-lint-checks/src/main/java/androidx/compose/lint/ModifierInspectorInfoDetector.kt
@@ -84,19 +84,19 @@
* Lint [Detector] to ensure that we are creating debug information for the layout inspector on
* all modifiers. For example in:
* ```
- * fun Modifier.preferredWidth(width: Dp) = this.then(SizeModifier(width))
+ * fun Modifier.width(width: Dp) = this.then(SizeModifier(width))
* ```
*
- * The layout inspector will not know that the name is `preferredWidth` and the `width` member
+ * The layout inspector will not know that the name is `width` and the `width` member
* may not be a field in SizeModifier that we can see via reflection.
*
* To supply debug information to the layout inspector include an InspectorInfo lambda like this:
* ```
- * fun Modifier.preferredWidth(width: Dp) = this.then(
+ * fun Modifier.width(width: Dp) = this.then(
* SizeModifier(
* width = width,
* inspectorInfo = debugInspectorInfo {
- * name = "preferredWidth",
+ * name = "width",
* value = width,
* )
* )
@@ -107,11 +107,11 @@
*
* If the modifier has multiple parameters use the `properties` specifier instead:
* ```
- * fun Modifier.preferredSize(width: Dp, height: Dp) = this.then(
+ * fun Modifier.size(width: Dp, height: Dp) = this.then(
* SizeModifier(
* width = width,
* inspectorInfo = debugInspectorInfo {
- * name = "preferredWidth",
+ * name = "width",
* properties["width"] = width
* properties["height"] = height
* )
@@ -351,7 +351,7 @@
* Return the name of the variable that the [expr] represents.
*
* This can be a simple parameter variable from the modifier.\
- * Example: `width` from `fun Modifier.preferredWidth(width: Int)`
+ * Example: `width` from `fun Modifier.width(width: Int)`
*
* Or it can be a selector from a data class parameter variable from the modifier.\
* Example: `values.start` from `fun Modifier.border(values: Borders)`
diff --git a/compose/internal-lint-checks/src/test/java/androidx/compose/lint/ModifierInspectorInfoDetectorTest.kt b/compose/internal-lint-checks/src/test/java/androidx/compose/lint/ModifierInspectorInfoDetectorTest.kt
index 1bc855c3..5e95ed8 100644
--- a/compose/internal-lint-checks/src/test/java/androidx/compose/lint/ModifierInspectorInfoDetectorTest.kt
+++ b/compose/internal-lint-checks/src/test/java/androidx/compose/lint/ModifierInspectorInfoDetectorTest.kt
@@ -162,9 +162,9 @@
inline class Dp(val value: Float)
- fun Modifier.preferredWidth1(width: Dp) =
+ fun Modifier.width1(width: Dp) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
properties["width"] = width
}))
@@ -203,7 +203,7 @@
}
}
- fun Modifier.preferredWidth1(width: Dp): Modifier {
+ fun Modifier.width1(width: Dp): Modifier {
require(width.value > 0.0f) { return "sds" }
val x = width.value.toInt() * 2
@@ -212,7 +212,7 @@
}
return this.then(SizeModifier1(x, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
properties["width"] = width
}))
}
@@ -243,9 +243,9 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth2(width: Int) =
+ fun Modifier.width2(width: Int) =
this.then(SizeModifier2(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth2"
+ name = "width2"
value = width
}))
@@ -278,21 +278,21 @@
inline class Dp(val value: Float)
- fun Modifier.preferredWidth1(width: Dp) =
+ fun Modifier.width1(width: Dp) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
properties["width"] = width
}))
- fun Modifier.preferredWidth2(width: Dp) = preferredWidth1(width)
+ fun Modifier.width2(width: Dp) = width1(width)
- fun Modifier.preferredWidth20() = preferredWidth1(Dp(20.0f))
+ fun Modifier.width20() = width1(Dp(20.0f))
fun Modifier.preferredIconWidth(x: Int) = this.then(
if (x == 7) DefaultIconSizeModifier else Modifier
)
- private val DefaultIconSizeModifier = Modifier.preferredWidth1(Dp(24.0f))
+ private val DefaultIconSizeModifier = Modifier.width1(Dp(24.0f))
private class SizeModifier1(
val width: Int,
@@ -598,10 +598,10 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int) = this.then(
+ fun Modifier.width1(width: Int) = this.then(
remember {
SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
properties["width"] = width
})
}
@@ -630,7 +630,7 @@
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
- internal actual fun Modifier.preferredWidth1(width: Int): Modifier = this
+ internal actual fun Modifier.width1(width: Int): Modifier = this
"""
).indented()
)
@@ -652,7 +652,7 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth2(width: Int) = this.then(SizeModifier2(width))
+ fun Modifier.width2(width: Int) = this.then(SizeModifier2(width))
private data class SizeModifier2(
val width: Int,
@@ -750,7 +750,7 @@
/**
* Documentation
*/
- fun Modifier.preferredSize(width: Int) =
+ fun Modifier.size(width: Int) =
this.then(SizeModifier.WithOption(width))
internal sealed class SizeModifier : Modifier.Element {
@@ -786,7 +786,7 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int) =
+ fun Modifier.width1(width: Int) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
name = "otherName"
value = width
@@ -804,7 +804,7 @@
.run()
.expect(
"""
- src/androidx/compose/ui/SizeModifier1.kt:10: Error: Expected name of the modifier: "name" = "preferredWidth1" [ModifierInspectorInfo]
+ src/androidx/compose/ui/SizeModifier1.kt:10: Error: Expected name of the modifier: "name" = "width1" [ModifierInspectorInfo]
name = "otherName"
~~~~~~~~~
1 errors, 0 warnings
@@ -826,9 +826,9 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int) =
+ fun Modifier.width1(width: Int) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
value = 3.4
}))
@@ -866,9 +866,9 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int, height: Int) =
+ fun Modifier.width1(width: Int, height: Int) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
value = "oldWidth"
}))
@@ -906,9 +906,9 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int, height: Int) =
+ fun Modifier.width1(width: Int, height: Int) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
properties["width"] = width
properties["other"] = height
}))
@@ -947,9 +947,9 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int, height: Int) =
+ fun Modifier.width1(width: Int, height: Int) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
- name = "preferredWidth1"
+ name = "width1"
properties["height"] = width
properties["width"] = height
}))
@@ -986,9 +986,9 @@
import androidx.compose.ui.platform.InspectorInfo
import androidx.compose.ui.platform.InspectorValueInfo
- fun Modifier.preferredWidth1(width: Int, height: Int) =
+ fun Modifier.width1(width: Int, height: Int) =
this.then(SizeModifier1(width, height, inspectorInfo = {
- name = "preferredWidth1"
+ name = "width1"
properties["width"] = width
properties["height"] = height
}))
@@ -1028,7 +1028,7 @@
import androidx.compose.ui.platform.InspectorValueInfo
import androidx.compose.ui.platform.debugInspectorInfo
- fun Modifier.preferredWidth1(width: Int) =
+ fun Modifier.width1(width: Int) =
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
value = width
}))
@@ -1045,7 +1045,7 @@
.run()
.expect(
"""
- src/androidx/compose/ui/SizeModifier1.kt:9: Error: Expected name of the modifier: "name" = "preferredWidth1" [ModifierInspectorInfo]
+ src/androidx/compose/ui/SizeModifier1.kt:9: Error: Expected name of the modifier: "name" = "width1" [ModifierInspectorInfo]
this.then(SizeModifier1(width, inspectorInfo = debugInspectorInfo {
^
1 errors, 0 warnings
diff --git a/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt b/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
index 722c2f2..c2ccb55 100644
--- a/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
+++ b/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
@@ -25,7 +25,7 @@
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -284,7 +284,7 @@
// Using ipx directly ensures that we will always have a consistent layout / drawing
// story, so anti-aliasing should be identical.
val layoutSize = with(LocalDensity.current) {
- Modifier.preferredSize(72.toDp())
+ Modifier.size(72.toDp())
}
Row(Modifier.align(Alignment.Center)) {
Box(
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/BottomNavigationDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/BottomNavigationDemo.kt
index d60bc4c4..8889140 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/BottomNavigationDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/BottomNavigationDemo.kt
@@ -22,8 +22,8 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.RadioButton
import androidx.compose.material.Text
@@ -45,7 +45,7 @@
Row(
modifier = Modifier
.fillMaxWidth()
- .preferredHeight(56.dp)
+ .height(56.dp)
.selectable(
selected = !alwaysShowLabels,
alwaysShowLabels = false }
@@ -56,13 +56,13 @@
selected = !alwaysShowLabels,
alwaysShowLabels = false }
)
- Spacer(Modifier.width(16.dp))
+ Spacer(Modifier.requiredWidth(16.dp))
Text("Only show labels when selected")
}
Row(
modifier = Modifier
.fillMaxWidth()
- .preferredHeight(56.dp)
+ .height(56.dp)
.selectable(
selected = alwaysShowLabels,
alwaysShowLabels = true }
@@ -73,11 +73,11 @@
selected = alwaysShowLabels,
alwaysShowLabels = true }
)
- Spacer(Modifier.width(16.dp))
+ Spacer(Modifier.requiredWidth(16.dp))
Text("Always show labels")
}
- Spacer(Modifier.preferredHeight(50.dp))
+ Spacer(Modifier.height(50.dp))
if (alwaysShowLabels) {
BottomNavigationSample()
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ButtonDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ButtonDemo.kt
index 8e16dc1..54dc11a 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ButtonDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ButtonDemo.kt
@@ -24,8 +24,8 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.material.Button
@@ -83,14 +83,14 @@
@Composable
private fun Buttons() {
Text("Buttons")
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
ButtonSample()
OutlinedButtonSample()
TextButtonSample()
}
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
Button(
@@ -104,7 +104,7 @@
ButtonWithIconSample()
}
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
Button( enabled = false) {
@@ -122,21 +122,21 @@
@Composable
private fun Fabs() {
Text("Floating action buttons")
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
SimpleFab()
SimpleExtendedFabNoIcon()
SimpleExtendedFabWithIcon()
}
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
FluidExtendedFab()
}
@Composable
private fun IconButtons() {
Text("Icon buttons")
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
Row {
IconButtonSample()
@@ -148,10 +148,10 @@
@Composable
private fun CustomShapeButton() {
Text("Custom shape button")
- Spacer(Modifier.preferredHeight(DefaultSpace))
+ Spacer(Modifier.height(DefaultSpace))
OutlinedButton(
>
- modifier = Modifier.preferredSize(110.dp),
+ modifier = Modifier.size(110.dp),
shape = TriangleShape,
colors = ButtonDefaults.outlinedButtonColors(
backgroundColor = Color.Yellow
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
index 3138d49..dd73b2e 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
@@ -36,8 +36,8 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.material.LocalTextStyle
@@ -142,18 +142,18 @@
) { labelWidth: Dp, selectionDiameter: Dp,
alpha: Float ->
Column(
- offset.preferredSize(width = MagnifierWidth, height = MagnifierHeight)
+ offset.size(width = MagnifierWidth, height = MagnifierHeight)
.alpha(alpha)
) {
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
- MagnifierLabel(Modifier.preferredSize(labelWidth, MagnifierLabelHeight), color)
+ MagnifierLabel(Modifier.size(labelWidth, MagnifierLabelHeight), color)
}
Spacer(Modifier.weight(1f))
Box(
- Modifier.fillMaxWidth().preferredHeight(SelectionCircleDiameter),
+ Modifier.fillMaxWidth().height(SelectionCircleDiameter),
contentAlignment = Alignment.Center
) {
- MagnifierSelectionCircle(Modifier.preferredSize(selectionDiameter), color)
+ MagnifierSelectionCircle(Modifier.size(selectionDiameter), color)
}
}
}
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/DynamicThemeActivity.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/DynamicThemeActivity.kt
index d398e04..aaddae0 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/DynamicThemeActivity.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/DynamicThemeActivity.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
@@ -142,7 +142,7 @@
// colour from the Material theme to work out text colour, so we end up doing a
// large amount of work here when the top level theme changes
Box(
- Modifier.padding(25.dp).fillMaxWidth().preferredHeight(150.dp)
+ Modifier.padding(25.dp).fillMaxWidth().height(150.dp)
.background(shapeColor, RoundedCornerShape(10.dp)),
contentAlignment = Alignment.Center
) {
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ElevationDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ElevationDemo.kt
index 4f3a52d..3af520f 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ElevationDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ElevationDemo.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -67,7 +67,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(150.dp)
+ .height(150.dp)
.clickable(>
contentAlignment = Alignment.Center
) {
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/MaterialTextField.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/MaterialTextField.kt
index 275d7b4..2440c91 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/MaterialTextField.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/MaterialTextField.kt
@@ -24,12 +24,12 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.selectable
@@ -111,7 +111,7 @@
val label = remember { mutableStateOf(false) }
val text = remember { mutableStateOf("") }
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
OptionRow(
title = "Single line",
checked = singleLine.value,
@@ -123,12 +123,12 @@
label.value = it }
)
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
val textFieldModifier = Modifier
.align(Alignment.CenterHorizontally)
- .width(300.dp)
- .heightIn(max = 200.dp)
- .then(if (singleLine.value) Modifier else Modifier.heightIn(min = 100.dp))
+ .requiredWidth(300.dp)
+ .requiredHeightIn(max = 200.dp)
+ .then(if (singleLine.value) Modifier else Modifier.requiredHeightIn(min = 100.dp))
TextField(
value = text.value,
text.value = it },
@@ -136,7 +136,7 @@
singleLine = singleLine.value,
modifier = textFieldModifier
)
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
OutlinedTextField(
value = text.value,
text.value = it },
@@ -181,7 +181,7 @@
if (trailingChecked) Icon(Icons.Filled.Info, "Info")
},
isErrorValue = selectedOption == Option.Error,
- modifier = Modifier.width(300.dp)
+ modifier = Modifier.requiredWidth(300.dp)
)
TextFieldType.Outlined ->
OutlinedTextField(
@@ -202,12 +202,12 @@
if (trailingChecked) Icon(Icons.Filled.Info, "Info")
},
isErrorValue = selectedOption == Option.Error,
- modifier = Modifier.width(300.dp)
+ modifier = Modifier.requiredWidth(300.dp)
)
}
}
- Box(Modifier.preferredHeight(150.dp).align(Alignment.CenterHorizontally)) {
+ Box(Modifier.height(150.dp).align(Alignment.CenterHorizontally)) {
if (selectedOption == Option.None) {
textField()
} else {
@@ -264,7 +264,7 @@
/* TODO */ }
)
- Spacer(Modifier.preferredHeight(20.dp))
+ Spacer(Modifier.height(20.dp))
Title("Assistive text")
Option.values().map { it.name }.forEach { text ->
@@ -339,7 +339,7 @@
style = MaterialTheme.typography.body1,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
}
@Composable
@@ -351,7 +351,7 @@
) {
Row(Modifier.padding(start = 10.dp, top = 10.dp)) {
Checkbox(checked = checked, enabled = enabled)
- Spacer(Modifier.preferredWidth(20.dp))
+ Spacer(Modifier.width(20.dp))
Text(text = title, style = MaterialTheme.typography.body1)
}
}
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/SliderDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/SliderDemo.kt
index 8ad912b..8e974cf9 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/SliderDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/SliderDemo.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
@@ -33,11 +33,11 @@
val headerStyle = MaterialTheme.typography.h6
Column(Modifier.padding(10.dp)) {
Text(text = "Continuous Slider", style = headerStyle)
- Spacer(Modifier.height(16.dp))
+ Spacer(Modifier.requiredHeight(16.dp))
SliderSample()
- Spacer(Modifier.height(16.dp))
+ Spacer(Modifier.requiredHeight(16.dp))
Text(text = "Discrete Slider with custom color", style = headerStyle)
- Spacer(Modifier.height(16.dp))
+ Spacer(Modifier.requiredHeight(16.dp))
StepsSliderSample()
}
}
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/TabDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/TabDemo.kt
index 916dfbc..1981844 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/TabDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/TabDemo.kt
@@ -18,8 +18,8 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
@@ -47,25 +47,25 @@
val showingSimple = remember { mutableStateOf(true) }
val buttonText = "Show ${if (showingSimple.value) "custom" else "simple"} tabs"
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
if (showingSimple.value) {
TextTabs()
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
IconTabs()
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
TextAndIconTabs()
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
ScrollingTextTabs()
} else {
FancyTabs()
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
FancyIndicatorTabs()
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
FancyIndicatorContainerTabs()
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
ScrollingFancyIndicatorContainerTabs()
}
- Spacer(Modifier.height(24.dp))
+ Spacer(Modifier.requiredHeight(24.dp))
Button(
modifier = Modifier.align(Alignment.CenterHorizontally),
>
@@ -75,6 +75,6 @@
) {
Text(buttonText)
}
- Spacer(Modifier.preferredHeight(50.dp))
+ Spacer(Modifier.height(50.dp))
}
}
diff --git a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/AccountsScreen.kt b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/AccountsScreen.kt
index 6f0048e..aaaa83e 100644
--- a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/AccountsScreen.kt
+++ b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/AccountsScreen.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card
@@ -42,7 +42,7 @@
val accountsProportion = accounts.extractProportions { it.balance }
val colors = accounts.map { it.color }
AnimatedCircle(
- Modifier.preferredHeight(300.dp).align(Alignment.Center).fillMaxWidth(),
+ Modifier.height(300.dp).align(Alignment.Center).fillMaxWidth(),
accountsProportion,
colors
)
@@ -59,7 +59,7 @@
)
}
}
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
Card {
Column(modifier = Modifier.padding(12.dp)) {
accounts.forEach { account ->
diff --git a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/BillsScreen.kt b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/BillsScreen.kt
index dc5d5b9..90c7b13 100644
--- a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/BillsScreen.kt
+++ b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/BillsScreen.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card
@@ -41,7 +41,7 @@
val accountsProportion = bills.extractProportions { it.amount }
val colors = bills.map { it.color }
AnimatedCircle(
- Modifier.align(Alignment.Center).preferredHeight(300.dp).fillMaxWidth(),
+ Modifier.align(Alignment.Center).height(300.dp).fillMaxWidth(),
accountsProportion,
colors
)
@@ -58,7 +58,7 @@
)
}
}
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
Card {
Column(modifier = Modifier.padding(12.dp)) {
bills.forEach { bill ->
diff --git a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/CommonUi.kt b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/CommonUi.kt
index 423fcc4..d260582 100644
--- a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/CommonUi.kt
+++ b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/CommonUi.kt
@@ -22,9 +22,9 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
@@ -73,17 +73,17 @@
amount: Float,
negative: Boolean
) {
- Row(Modifier.preferredHeight(68.dp)) {
+ Row(Modifier.height(68.dp)) {
val typography = MaterialTheme.typography
AccountIndicator(color = color, modifier = Modifier.align(Alignment.CenterVertically))
- Spacer(Modifier.preferredWidth(8.dp))
+ Spacer(Modifier.width(8.dp))
Column(Modifier.align(Alignment.CenterVertically)) {
Text(text = title, style = typography.body1)
Text(text = subtitle, style = typography.subtitle1)
}
Spacer(Modifier.weight(1f))
Row(
- modifier = Modifier.align(Alignment.CenterVertically).preferredWidth(113.dp),
+ modifier = Modifier.align(Alignment.CenterVertically).width(113.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
@@ -97,11 +97,11 @@
modifier = Modifier.align(Alignment.CenterVertically)
)
}
- Spacer(Modifier.preferredWidth(16.dp))
+ Spacer(Modifier.width(16.dp))
Icon(
Icons.Filled.ArrowForwardIos,
contentDescription = null,
- modifier = Modifier.preferredSize(12.dp).align(Alignment.CenterVertically),
+ modifier = Modifier.size(12.dp).align(Alignment.CenterVertically),
tint = Color.White.copy(alpha = 0.6f)
)
}
@@ -113,7 +113,7 @@
*/
@Composable
private fun AccountIndicator(color: Color, modifier: Modifier = Modifier) {
- Box(modifier.preferredSize(4.dp, 36.dp).background(color = color))
+ Box(modifier.size(4.dp, 36.dp).background(color = color))
}
@Composable
diff --git a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/OverviewScreen.kt b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/OverviewScreen.kt
index 8773f93..bbd968b 100644
--- a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/OverviewScreen.kt
+++ b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/OverviewScreen.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Card
import androidx.compose.material.Divider
@@ -211,7 +211,7 @@
private fun SeeAllButton(onClick: () -> Unit) {
TextButton(
>
- modifier = Modifier.preferredHeight(44.dp).fillMaxWidth()
+ modifier = Modifier.height(44.dp).fillMaxWidth()
) {
Text("SEE ALL")
}
diff --git a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/TopAppBar.kt b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/TopAppBar.kt
index b49e23f..df0166c 100644
--- a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/TopAppBar.kt
+++ b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/TopAppBar.kt
@@ -25,8 +25,8 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
@@ -48,7 +48,7 @@
onTabSelected: (RallyScreenState) -> Unit,
currentScreen: RallyScreenState
) {
- Surface(Modifier.preferredHeight(TabHeight).fillMaxWidth()) {
+ Surface(Modifier.height(TabHeight).fillMaxWidth()) {
Row {
allScreens.forEachIndexed { index, screen ->
RallyTab(
@@ -73,7 +73,7 @@
Row(
modifier = Modifier
.padding(16.dp)
- .preferredHeight(TabHeight)
+ .height(TabHeight)
.selectable(
selected = selected,
>
@@ -87,7 +87,7 @@
tint = tabTintColor
)
if (selected) {
- Spacer(Modifier.preferredWidth(12.dp))
+ Spacer(Modifier.width(12.dp))
Text(text, color = tabTintColor)
}
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomSheetScaffoldSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomSheetScaffoldSamples.kt
index b098242..85a3567 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomSheetScaffoldSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/BottomSheetScaffoldSamples.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.BottomSheetScaffold
import androidx.compose.material.Button
@@ -67,7 +67,7 @@
BottomSheetScaffold(
sheetContent = {
Box(
- Modifier.fillMaxWidth().preferredHeight(128.dp),
+ Modifier.fillMaxWidth().height(128.dp),
contentAlignment = Alignment.Center
) {
Text("Swipe up to expand sheet")
@@ -77,7 +77,7 @@
horizontalAlignment = Alignment.CenterHorizontally
) {
Text("Sheet content")
- Spacer(Modifier.preferredHeight(20.dp))
+ Spacer(Modifier.height(20.dp))
Button(
>
scope.launch { scaffoldState.bottomSheetState.collapse() }
@@ -119,7 +119,7 @@
horizontalAlignment = Alignment.CenterHorizontally
) {
Text("Drawer content")
- Spacer(Modifier.preferredHeight(20.dp))
+ Spacer(Modifier.height(20.dp))
Button( scope.launch { scaffoldState.drawerState.close() } }) {
Text("Click to close drawer")
}
@@ -131,7 +131,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(colors[it % colors.size])
)
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/DrawerSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/DrawerSamples.kt
index 7808501..7175e72 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/DrawerSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/DrawerSamples.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.material.BottomDrawer
import androidx.compose.material.BottomDrawerValue
import androidx.compose.material.Button
@@ -58,7 +58,7 @@
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = if (drawerState.isClosed) ">>> Swipe >>>" else "<<< Swipe <<<")
- Spacer(Modifier.preferredHeight(20.dp))
+ Spacer(Modifier.height(20.dp))
Button( scope.launch { drawerState.open() } }) {
Text("Click to open")
}
@@ -88,7 +88,7 @@
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = if (drawerState.isClosed) "▲▲▲ Pull up ▲▲▲" else "▼▼▼ Drag down ▼▼▼")
- Spacer(Modifier.preferredHeight(20.dp))
+ Spacer(Modifier.height(20.dp))
Button( scope.launch { drawerState.open() } }) {
Text("Click to open")
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ModalBottomSheetSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ModalBottomSheetSamples.kt
index 7de30f6..f754340 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ModalBottomSheetSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ModalBottomSheetSamples.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Button
import androidx.compose.material.ExperimentalMaterialApi
@@ -69,7 +69,7 @@
horizontalAlignment = Alignment.CenterHorizontally
) {
Text("Rest of the UI")
- Spacer(Modifier.preferredHeight(20.dp))
+ Spacer(Modifier.height(20.dp))
Button( scope.launch { state.show() } }) {
Text("Click to show sheet")
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ProgressIndicatorSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ProgressIndicatorSamples.kt
index b7bcac5..cc72981 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ProgressIndicatorSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ProgressIndicatorSamples.kt
@@ -20,7 +20,7 @@
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material.OutlinedButton
@@ -46,7 +46,7 @@
Column(horizontalAlignment = Alignment.CenterHorizontally) {
LinearProgressIndicator(progress = animatedProgress)
- Spacer(Modifier.height(30.dp))
+ Spacer(Modifier.requiredHeight(30.dp))
OutlinedButton(
>
if (progress < 1f) progress += 0.1f
@@ -68,7 +68,7 @@
Column(horizontalAlignment = Alignment.CenterHorizontally) {
CircularProgressIndicator(progress = animatedProgress)
- Spacer(Modifier.height(30.dp))
+ Spacer(Modifier.requiredHeight(30.dp))
OutlinedButton(
>
if (progress < 1f) progress += 0.1f
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ScaffoldSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ScaffoldSamples.kt
index a254072..8b6a2df4 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ScaffoldSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ScaffoldSamples.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
@@ -110,7 +110,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(colors[it % colors.size])
)
}
@@ -185,7 +185,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(colors[it % colors.size])
)
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SelectionControlsSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SelectionControlsSamples.kt
index 1befa0d..692020b 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SelectionControlsSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SelectionControlsSamples.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.Checkbox
import androidx.compose.material.CheckboxDefaults
@@ -123,7 +123,7 @@
Row(
Modifier
.fillMaxWidth()
- .preferredHeight(56.dp)
+ .height(56.dp)
.selectable(
selected = (text == selectedOption),
onOptionSelected(text) }
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt
index 4f886a1..e38cd70 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt
@@ -20,8 +20,8 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FractionalThreshold
import androidx.compose.material.Text
@@ -53,7 +53,7 @@
Box(
modifier = Modifier
- .preferredWidth(width)
+ .width(width)
.swipeable(
state = swipeableState,
anchors = anchors,
@@ -65,7 +65,7 @@
Box(
Modifier
.offset { IntOffset(swipeableState.offset.value.roundToInt(), 0) }
- .preferredSize(squareSize)
+ .size(squareSize)
.background(Color.Red),
contentAlignment = Alignment.Center
) {
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/TabSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/TabSamples.kt
index cf45aa0..e0d0fdd 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/TabSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/TabSamples.kt
@@ -31,9 +31,9 @@
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
@@ -288,11 +288,11 @@
fun FancyTab(title: String, onClick: () -> Unit, selected: Boolean) {
Tab(selected, onClick) {
Column(
- Modifier.padding(10.dp).preferredHeight(50.dp).fillMaxWidth(),
+ Modifier.padding(10.dp).height(50.dp).fillMaxWidth(),
verticalArrangement = Arrangement.SpaceBetween
) {
Box(
- Modifier.preferredSize(10.dp)
+ Modifier.size(10.dp)
.align(Alignment.CenterHorizontally)
.background(color = if (selected) Color.Red else Color.White)
)
@@ -367,6 +367,6 @@
// Apply an offset from the start to correctly position the indicator around the tab
.offset(x = indicatorStart)
// Make the width of the indicator follow the animated width as we move between tabs
- .preferredWidth(indicatorEnd - indicatorStart)
+ .width(indicatorEnd - indicatorStart)
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogScreenshotTest.kt
index d8b241b..c950827 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogScreenshotTest.kt
@@ -19,7 +19,7 @@
import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.captureToImage
@@ -157,7 +157,9 @@
AlertDialog(
>
title = {
- Box(Modifier.size(75.dp, 25.dp).background(MaterialTheme.colors.primary))
+ Box(
+ Modifier.requiredSize(75.dp, 25.dp).background(MaterialTheme.colors.primary)
+ )
},
text = { Text("Text") },
confirmButton = {
@@ -180,7 +182,10 @@
>
title = { Text("Title") },
text = {
- Box(Modifier.size(300.dp, 50.dp).background(MaterialTheme.colors.primary))
+ Box(
+ Modifier.requiredSize(300.dp, 50.dp)
+ .background(MaterialTheme.colors.primary)
+ )
},
confirmButton = {
TextButton( {
@@ -201,10 +206,16 @@
AlertDialog(
>
title = {
- Box(Modifier.size(75.dp, 25.dp).background(MaterialTheme.colors.primary))
+ Box(
+ Modifier.requiredSize(75.dp, 25.dp)
+ .background(MaterialTheme.colors.primary)
+ )
},
text = {
- Box(Modifier.size(300.dp, 50.dp).background(MaterialTheme.colors.primary))
+ Box(
+ Modifier.requiredSize(300.dp, 50.dp)
+ .background(MaterialTheme.colors.primary)
+ )
},
confirmButton = {
TextButton( {
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BackdropScaffoldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BackdropScaffoldTest.kt
index fa3500a..12b0e86 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BackdropScaffoldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BackdropScaffoldTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.material.BackdropValue.Concealed
import androidx.compose.material.BackdropValue.Revealed
import androidx.compose.ui.Modifier
@@ -72,8 +72,8 @@
scaffoldState = rememberBackdropScaffoldState(Concealed),
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -90,8 +90,8 @@
scaffoldState = rememberBackdropScaffoldState(Concealed),
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -114,8 +114,8 @@
scaffoldState = rememberBackdropScaffoldState(Revealed),
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -132,8 +132,8 @@
scaffoldState = rememberBackdropScaffoldState(Revealed),
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -156,7 +156,7 @@
scaffoldState = rememberBackdropScaffoldState(Revealed),
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
backLayerContent = { Box(Modifier.fillMaxHeight()) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
@@ -174,8 +174,8 @@
peekHeight = peekHeight,
headerHeight = headerHeight,
persistentAppBar = false,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -192,8 +192,8 @@
peekHeight = peekHeight,
headerHeight = headerHeight,
stickyFrontLayer = false,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -212,8 +212,8 @@
scaffoldState = scaffoldState,
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -245,8 +245,8 @@
scaffoldState = scaffoldState,
peekHeight = peekHeight,
headerHeight = headerHeight,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -275,8 +275,8 @@
peekHeight = peekHeight,
headerHeight = headerHeight,
frontLayerScrimColor = Color.Red,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = { Box(Modifier.fillMaxSize().testTag(frontLayer)) }
)
}
@@ -306,8 +306,8 @@
peekHeight = peekHeight,
headerHeight = headerHeight,
frontLayerScrimColor = Color.Transparent,
- appBar = { Box(Modifier.preferredHeight(peekHeight)) },
- backLayerContent = { Box(Modifier.preferredHeight(contentHeight)) },
+ appBar = { Box(Modifier.height(peekHeight)) },
+ backLayerContent = { Box(Modifier.height(contentHeight)) },
frontLayerContent = {
Box(
Modifier.fillMaxSize().testTag(frontLayer).clickable {
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomSheetScaffoldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomSheetScaffoldTest.kt
index 89bc57d..06883ab 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomSheetScaffoldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomSheetScaffoldTest.kt
@@ -22,9 +22,9 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.ui.Modifier
@@ -103,7 +103,7 @@
bottomSheetState = rememberBottomSheetState(BottomSheetValue.Expanded)
),
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetPeekHeight = peekHeight
) {
@@ -123,7 +123,7 @@
bottomSheetState = rememberBottomSheetState(BottomSheetValue.Collapsed)
),
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetPeekHeight = peekHeight
) {
@@ -150,7 +150,7 @@
bottomSheetState = rememberBottomSheetState(BottomSheetValue.Expanded)
),
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetPeekHeight = peekHeight
) {
@@ -179,7 +179,7 @@
bottomSheetState = bottomSheetState
),
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetPeekHeight = peekHeight,
content = { Text("Content") }
@@ -214,7 +214,7 @@
bottomSheetState = bottomSheetState
),
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetPeekHeight = peekHeight,
content = { Text("Content") }
@@ -254,7 +254,7 @@
bottomSheetState = bottomSheetState
),
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetGesturesEnabled = false,
sheetPeekHeight = peekHeight,
@@ -287,7 +287,7 @@
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
- Box(Modifier.fillMaxWidth().height(100.dp))
+ Box(Modifier.fillMaxWidth().requiredHeight(100.dp))
},
drawerContent = {
Box(
@@ -296,7 +296,7 @@
drawerChildPosition = positioned.positionInParent
}
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
}
@@ -304,7 +304,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
}
@@ -332,19 +332,19 @@
appbarSize = positioned.size
}
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Red)
)
},
sheetContent = {
- Box(Modifier.size(10.dp))
+ Box(Modifier.requiredSize(10.dp))
}
) {
Box(
Modifier
.onGloballyPositioned { contentPosition = it.localToWindow(Offset.Zero) }
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(Color.Blue)
)
}
@@ -363,7 +363,7 @@
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
- Box(Modifier.fillMaxWidth().height(300.dp).testTag(sheetContent))
+ Box(Modifier.fillMaxWidth().requiredHeight(300.dp).testTag(sheetContent))
},
sheetGesturesEnabled = false,
sheetPeekHeight = peekHeight,
@@ -402,25 +402,25 @@
rule.setContent {
Box(
Modifier
- .size(10.dp, 20.dp)
+ .requiredSize(10.dp, 20.dp)
.semantics(mergeDescendants = true) {}
.testTag("Scaffold")
) {
BottomSheetScaffold(
topBar = {
Box(
- Modifier.size(10.dp)
+ Modifier.requiredSize(10.dp)
.shadow(4.dp)
.zIndex(4f)
.background(color = Color.White)
)
},
sheetContent = {
- Box(Modifier.size(0.dp))
+ Box(Modifier.requiredSize(0.dp))
}
) {
Box(
- Modifier.size(10.dp)
+ Modifier.requiredSize(10.dp)
.background(color = Color.White)
)
}
@@ -444,7 +444,7 @@
rule.setContent {
BottomSheetScaffold(
sheetContent = {
- Box(Modifier.fillMaxWidth().height(100.dp))
+ Box(Modifier.fillMaxWidth().requiredHeight(100.dp))
},
sheetPeekHeight = peekHeight
) {
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
index 432b33d..6ab9a4b 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
@@ -17,7 +17,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
@@ -80,7 +80,7 @@
@Test
fun ripple() {
rule.setMaterialContent {
- Box(Modifier.size(200.dp, 100.dp).wrapContentSize()) {
+ Box(Modifier.requiredSize(200.dp, 100.dp).wrapContentSize()) {
Button( }) { }
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
index bdd4db0..b5a8122 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
@@ -21,13 +21,13 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.layout.widthIn
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredWidth
+import androidx.compose.foundation.layout.requiredWidthIn
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -291,7 +291,7 @@
primary = MaterialTheme.colors.primary
CompositionLocalProvider(LocalShapes provides Shapes(small = shape)) {
Button(modifier = Modifier.testTag("myButton"), elevation = null) {
- Box(Modifier.preferredSize(10.dp, 10.dp))
+ Box(Modifier.size(10.dp, 10.dp))
}
}
}
@@ -532,7 +532,7 @@
Box {
Button({}, Modifier.onGloballyPositioned { buttonCoordinates = it }) {
Box(
- Modifier.preferredSize(2.dp)
+ Modifier.size(2.dp)
.onGloballyPositioned { contentCoordinates = it }
)
}
@@ -558,9 +558,9 @@
Button(
>
contentPadding = PaddingValues(),
- modifier = Modifier.widthIn(20.dp).heightIn(15.dp).testTag("button")
+ modifier = Modifier.requiredWidthIn(20.dp).requiredHeightIn(15.dp).testTag("button")
) {
- Spacer(Modifier.size(10.dp))
+ Spacer(Modifier.requiredSize(10.dp))
}
}
@@ -576,7 +576,7 @@
rule.setMaterialContent {
Column {
Spacer(
- Modifier.size(10.dp).weight(1f).onGloballyPositioned {
+ Modifier.requiredSize(10.dp).weight(1f).onGloballyPositioned {
item1Bounds = it.boundsInRoot()
}
)
@@ -590,7 +590,7 @@
Text("Button")
}
- Spacer(Modifier.size(10.dp).weight(1f))
+ Spacer(Modifier.requiredSize(10.dp).weight(1f))
}
}
@@ -611,12 +611,12 @@
}
) {
Spacer(
- Modifier.size(10.dp).onGloballyPositioned {
+ Modifier.requiredSize(10.dp).onGloballyPositioned {
item1Bounds = it.boundsInRoot()
}
)
Spacer(
- Modifier.width(10.dp).height(5.dp).onGloballyPositioned {
+ Modifier.requiredWidth(10.dp).requiredHeight(5.dp).onGloballyPositioned {
item2Bounds = it.boundsInRoot()
}
)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CardTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CardTest.kt
index c27157d..92d82443 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CardTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CardTest.kt
@@ -18,7 +18,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.testutils.assertShape
@@ -63,7 +63,7 @@
.testTag("card"),
elevation = 0.dp
) {
- Box(Modifier.preferredSize(50.dp, 50.dp))
+ Box(Modifier.size(50.dp, 50.dp))
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerScreenshotTest.kt
index 0790af2..07777ec 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerScreenshotTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -53,7 +53,7 @@
private fun ComposeContentTestRule.setBottomDrawer(drawerValue: BottomDrawerValue) {
setMaterialContent {
- Box(Modifier.size(10.dp, 100.dp).testTag("container")) {
+ Box(Modifier.requiredSize(10.dp, 100.dp).testTag("container")) {
BottomDrawer(
drawerState = rememberBottomDrawerState(drawerValue),
drawerContent = { Box(Modifier.fillMaxSize().background(Color.Red)) },
@@ -65,7 +65,7 @@
private fun ComposeContentTestRule.setModalDrawer(drawerValue: DrawerValue) {
setMaterialContent {
- Box(Modifier.size(100.dp, 10.dp).testTag("container")) {
+ Box(Modifier.requiredSize(100.dp, 10.dp).testTag("container")) {
ModalDrawer(
drawerState = rememberDrawerState(drawerValue),
drawerContent = { Box(Modifier.fillMaxSize().background(Color.Red)) },
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt
index 885dc7c..4897512 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt
@@ -18,7 +18,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.testutils.assertPixels
@@ -213,7 +213,7 @@
with(LocalDensity.current) {
// Make the surface size small so we compare less pixels
Box(
- Modifier.preferredSize(
+ Modifier.size(
SurfaceSize.width.toDp(),
SurfaceSize.height.toDp()
).testTag(Tag)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt
index a679c2b..b9bdd17 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonTest.kt
@@ -20,8 +20,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
@@ -143,7 +143,7 @@
rule.setMaterialContent {
Column {
Spacer(
- Modifier.size(10.dp).weight(1f).onGloballyPositioned {
+ Modifier.requiredSize(10.dp).weight(1f).onGloballyPositioned {
item1Bounds = it.boundsInRoot()
}
)
@@ -158,7 +158,7 @@
Text("Button")
}
- Spacer(Modifier.size(10.dp).weight(1f))
+ Spacer(Modifier.requiredSize(10.dp).weight(1f))
}
}
@@ -186,7 +186,7 @@
defaultElevation = 0.dp
)
) {
- Box(Modifier.preferredSize(10.dp, 10.dp))
+ Box(Modifier.size(10.dp, 10.dp))
}
}
}
@@ -222,7 +222,7 @@
elevation = FloatingActionButtonDefaults.elevation(
defaultElevation = 0.dp
),
- text = { Box(Modifier.preferredSize(10.dp, 50.dp)) }
+ text = { Box(Modifier.size(10.dp, 50.dp)) }
)
}
}
@@ -252,7 +252,7 @@
}
) {
Box(
- Modifier.preferredSize(2.dp)
+ Modifier.size(2.dp)
.onGloballyPositioned { contentCoordinates = it }
)
}
@@ -281,7 +281,7 @@
ExtendedFloatingActionButton(
text = {
Box(
- Modifier.preferredSize(2.dp)
+ Modifier.size(2.dp)
.onGloballyPositioned { contentCoordinates = it }
)
},
@@ -314,13 +314,13 @@
ExtendedFloatingActionButton(
text = {
Box(
- Modifier.preferredSize(2.dp)
+ Modifier.size(2.dp)
.onGloballyPositioned { textCoordinates = it }
)
},
icon = {
Box(
- Modifier.preferredSize(10.dp)
+ Modifier.size(10.dp)
.onGloballyPositioned { iconCoordinates = it }
)
},
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconButtonTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconButtonTest.kt
index 01a2fe9..7ece304 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconButtonTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconButtonTest.kt
@@ -16,7 +16,7 @@
package androidx.compose.material
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.samples.IconButtonSample
import androidx.compose.material.samples.IconToggleButtonSample
import androidx.compose.ui.Modifier
@@ -65,7 +65,7 @@
rule.setMaterialContent {
Box {
IconButton( {
- Box(Modifier.preferredSize(diameter).testTag("icon"))
+ Box(Modifier.size(diameter).testTag("icon"))
}
}
}
@@ -83,7 +83,7 @@
rule.setMaterialContent {
Box {
IconButton( {
- Box(Modifier.preferredSize(width, height).testTag("icon"))
+ Box(Modifier.size(width, height).testTag("icon"))
}
}
}
@@ -112,7 +112,7 @@
rule.setMaterialContent {
Box {
IconToggleButton(checked = false, {
- Box(Modifier.preferredSize(diameter).testTag("icon"))
+ Box(Modifier.size(diameter).testTag("icon"))
}
}
}
@@ -130,7 +130,7 @@
rule.setMaterialContent {
Box {
IconToggleButton(checked = false, {
- Box(Modifier.preferredSize(width, height).testTag("icon"))
+ Box(Modifier.size(width, height).testTag("icon"))
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt
index 4c7ad9a..5285f60 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt
@@ -16,7 +16,7 @@
package androidx.compose.material
import android.os.Build
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.testutils.assertPixels
@@ -172,7 +172,7 @@
image,
null,
// Force Icon to be 50dp
- modifier = Modifier.size(50.dp).testTag(testTag),
+ modifier = Modifier.requiredSize(50.dp).testTag(testTag),
tint = Color.Unspecified
)
with(LocalDensity.current) {
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
index e7bc989..d9c2ca1 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
@@ -24,8 +24,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ripple.ExperimentalRippleApi
import androidx.compose.material.ripple.LocalRippleTheme
@@ -686,7 +686,7 @@
color = RippleBoxBackgroundColor, shape = RoundedCornerShape(20)
) {
Box(
- Modifier.preferredWidth(80.dp).preferredHeight(50.dp).indication(
+ Modifier.width(80.dp).height(50.dp).indication(
interactionState = interactionState,
indication = ripple
)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTest.kt
index ae01da3..40f3ac6 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.material
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSizeIn
+import androidx.compose.foundation.layout.sizeIn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.FirstBaseline
@@ -83,7 +83,7 @@
Surface {
Box {
Box(
- Modifier.preferredSizeIn(
+ Modifier.sizeIn(
maxWidth = parentMaxWidth,
maxHeight = parentMaxHeight
).testTag("containerForSizeAssertion")
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt
index d545fa5..97d55b4 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialTextSelectionColorsScreenshotTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.material
import android.os.Build
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.runtime.Composable
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
@@ -255,7 +255,7 @@
private fun FilledTextFieldTestContent(colors: Colors) {
MaterialTheme(colors) {
Surface(Modifier.testTag(Tag)) {
- TextField(value = Text, modifier = Modifier.width(280.dp))
+ TextField(value = Text, modifier = Modifier.requiredWidth(280.dp))
}
}
}
@@ -264,7 +264,11 @@
private fun OutlinedTextFieldTestContent(colors: Colors) {
MaterialTheme(colors) {
Surface(Modifier.testTag(Tag)) {
- OutlinedTextField(value = Text, modifier = Modifier.width(280.dp))
+ OutlinedTextField(
+ value = Text,
+ >
+ modifier = Modifier.requiredWidth(280.dp)
+ )
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt
index 701d676..b964bee 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt
@@ -19,8 +19,8 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -61,7 +61,7 @@
var expanded by mutableStateOf(false)
rule.setContent {
- Box(Modifier.size(20.dp).background(color = Color.Blue)) {
+ Box(Modifier.requiredSize(20.dp).background(color = Color.Blue)) {
DropdownMenu(
expanded = expanded,
>
@@ -102,13 +102,13 @@
fun menu_hasExpectedSize() {
rule.setContent {
with(LocalDensity.current) {
- Box(Modifier.size(20.toDp()).background(color = Color.Blue)) {
+ Box(Modifier.requiredSize(20.toDp()).background(color = Color.Blue)) {
DropdownMenu(
expanded = true,
>
) {
- Box(Modifier.testTag("MenuContent1").preferredSize(70.toDp()))
- Box(Modifier.testTag("MenuContent2").preferredSize(130.toDp()))
+ Box(Modifier.testTag("MenuContent1").size(70.toDp()))
+ Box(Modifier.testTag("MenuContent2").size(130.toDp()))
}
}
}
@@ -301,7 +301,7 @@
>
enabledContentAlpha = ContentAlpha.high
disabledContentAlpha = ContentAlpha.disabled
- Box(Modifier.size(20.dp)) {
+ Box(Modifier.requiredSize(20.dp)) {
DropdownMenu(
>
expanded = true
@@ -332,7 +332,7 @@
onClick,
modifier = Modifier.testTag("MenuItem").clickable(>
) {
- Box(Modifier.size(40.dp))
+ Box(Modifier.requiredSize(40.dp))
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt
index 4bba9c1..e41fd75 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.SemanticsActions
@@ -67,7 +67,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(sheetHeight)
+ .height(sheetHeight)
.testTag(sheetTag)
)
}
@@ -89,7 +89,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(sheetHeight)
+ .height(sheetHeight)
.testTag(sheetTag)
)
}
@@ -111,7 +111,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(sheetHeight)
+ .height(sheetHeight)
.testTag(sheetTag)
)
}
@@ -320,7 +320,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(sheetHeight)
+ .height(sheetHeight)
.testTag(sheetTag)
)
}
@@ -397,7 +397,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(sheetHeight)
+ .height(sheetHeight)
.testTag(sheetTag)
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
index d64284b..ed44892 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldTest.kt
@@ -22,8 +22,8 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.Composable
@@ -119,7 +119,7 @@
appbarSize = positioned.size
}
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Red)
)
}
@@ -128,7 +128,7 @@
Modifier
.onGloballyPositioned { contentPosition = it.localToWindow(Offset.Zero) }
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(Color.Blue)
)
}
@@ -153,7 +153,7 @@
appbarSize = positioned.size
}
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Red)
)
}
@@ -165,7 +165,7 @@
contentSize = positioned.size
}
.fillMaxSize()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
}
@@ -190,7 +190,7 @@
drawerChildPosition = positioned.positionInParent
}
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
},
@@ -199,7 +199,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
}
@@ -246,7 +246,7 @@
drawerChildPosition = positioned.positionInParent
}
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
}
@@ -254,7 +254,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(50.dp)
+ .height(50.dp)
.background(color = Color.Blue)
)
}
@@ -345,14 +345,14 @@
rule.setContent {
Box(
Modifier
- .size(10.dp, 20.dp)
+ .requiredSize(10.dp, 20.dp)
.semantics(mergeDescendants = true) {}
.testTag("Scaffold")
) {
Scaffold(
topBar = {
Box(
- Modifier.size(10.dp)
+ Modifier.requiredSize(10.dp)
.shadow(4.dp)
.zIndex(4f)
.background(color = Color.White)
@@ -360,7 +360,7 @@
}
) {
Box(
- Modifier.size(10.dp)
+ Modifier.requiredSize(10.dp)
.background(color = Color.White)
)
}
@@ -434,7 +434,7 @@
bottomBarSize = positioned.size
}
.fillMaxWidth()
- .preferredHeight(100.dp)
+ .height(100.dp)
.background(color = Color.Red)
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt
index 9bc7687..2487b7d 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderScreenshotTest.kt
@@ -18,7 +18,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -52,7 +52,7 @@
@get:Rule
val screenshotRule = AndroidXScreenshotTestRule(GOLDEN_MATERIAL)
- val wrap = Modifier.width(70.dp).wrapContentSize(Alignment.TopStart)
+ val wrap = Modifier.requiredWidth(70.dp).wrapContentSize(Alignment.TopStart)
private val wrapperTestTag = "sliderWrapper"
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
index 60fb15a..1b8613a 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.testutils.assertPixels
import androidx.compose.testutils.assertShape
@@ -58,7 +58,7 @@
rule.setMaterialContent {
Box(
Modifier
- .preferredSize(10.dp, 10.dp)
+ .size(10.dp, 10.dp)
.semantics(mergeDescendants = true) {}
.testTag("box")
) {
@@ -108,7 +108,7 @@
Box(
Modifier
.padding(10.dp)
- .preferredSize(10.dp, 10.dp)
+ .size(10.dp, 10.dp)
.semantics(mergeDescendants = true) {}
.testTag("top level")
) {
@@ -125,7 +125,7 @@
Box(
Modifier
.padding(10.dp)
- .preferredSize(10.dp, 10.dp)
+ .size(10.dp, 10.dp)
.semantics(mergeDescendants = true) {}
.testTag("nested")
) {
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt
index 75dc421..3a7ad8e 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLayoutDirection
@@ -106,7 +106,7 @@
SwipeToDismiss(
state = rememberDismissState(DismissValue.Default),
background = { Box(Modifier.fillMaxSize().testTag(backgroundTag)) },
- dismissContent = { Box(Modifier.preferredSize(100.dp)) }
+ dismissContent = { Box(Modifier.size(100.dp)) }
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
index d32b150..86aa79b 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
@@ -23,8 +23,8 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
@@ -1572,7 +1572,7 @@
scrollState = rememberScrollState()
Box(
Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.nestedScroll(swipeableState.PreUpPostDownNestedScrollConnection)
.swipeable(
state = swipeableState,
@@ -1585,7 +1585,7 @@
Modifier.fillMaxWidth().testTag(swipeableTag).verticalScroll(scrollState)
) {
repeat(100) {
- Text(text = it.toString(), modifier = Modifier.height(50.dp))
+ Text(text = it.toString(), modifier = Modifier.requiredHeight(50.dp))
}
}
}
@@ -1629,7 +1629,7 @@
scrollState = rememberScrollState()
Box(
Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.nestedScroll(swipeableState.PreUpPostDownNestedScrollConnection)
.swipeable(
state = swipeableState,
@@ -1642,7 +1642,7 @@
Modifier.fillMaxWidth().testTag(swipeableTag).verticalScroll(scrollState)
) {
repeat(100) {
- Text(text = it.toString(), modifier = Modifier.height(50.dp))
+ Text(text = it.toString(), modifier = Modifier.requiredHeight(50.dp))
}
}
}
@@ -1695,7 +1695,7 @@
scrollState = rememberScrollState(initial = 5000f)
Box(
Modifier
- .preferredSize(300.dp)
+ .size(300.dp)
.nestedScroll(swipeableState.PreUpPostDownNestedScrollConnection)
.swipeable(
state = swipeableState,
@@ -1708,7 +1708,7 @@
Modifier.fillMaxWidth().testTag(swipeableTag).verticalScroll(scrollState)
) {
repeat(100) {
- Text(text = it.toString(), modifier = Modifier.height(50.dp))
+ Text(text = it.toString(), modifier = Modifier.requiredHeight(50.dp))
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
index c62072b..64f19f0 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
@@ -18,7 +18,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
@@ -131,7 +131,7 @@
@Test
fun switchTest_bigSizeSpecified() {
rule.setMaterialContent {
- Box(wrapperModifier.size(50.dp)) {
+ Box(wrapperModifier.requiredSize(50.dp)) {
Switch(checked = true, })
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabTest.kt
index 2da0b66..725f4d6 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
@@ -174,7 +174,7 @@
Modifier
.tabIndicatorOffset(tabPositions[state])
.fillMaxWidth()
- .preferredHeight(indicatorHeight)
+ .height(indicatorHeight)
.background(color = Color.Red)
.testTag("indicator")
)
@@ -349,7 +349,7 @@
Modifier
.tabIndicatorOffset(tabPositions[state])
.fillMaxWidth()
- .preferredHeight(indicatorHeight)
+ .height(indicatorHeight)
.background(color = Color.Red)
.testTag("indicator")
)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt
index d44c3c7..9618e72 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt
@@ -18,8 +18,8 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.material.GOLDEN_MATERIAL
import androidx.compose.material.LocalContentColor
import androidx.compose.material.OutlinedTextField
@@ -82,7 +82,7 @@
value = "Text",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -98,7 +98,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -115,7 +115,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -135,7 +135,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -156,7 +156,7 @@
>
label = { Text("Label") },
isErrorValue = true,
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -175,7 +175,7 @@
>
label = { Text("Label") },
isErrorValue = true,
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -190,7 +190,7 @@
OutlinedTextField(
value = "Hello, world!",
>
- modifier = Modifier.testTag(TextFieldTag).width(280.dp)
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp)
)
}
}
@@ -205,7 +205,9 @@
value = "Text",
>
label = { Text("Label") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -218,7 +220,9 @@
OutlinedTextField(
value = "Text",
>
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -233,7 +237,9 @@
>
label = { Text("Label") },
placeholder = { Text("placeholder") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -249,7 +255,9 @@
value = "",
>
placeholder = { Text("placeholder") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -265,7 +273,9 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -280,7 +290,7 @@
>
singleLine = true,
label = { Text("Label") },
- modifier = Modifier.testTag(TextFieldTag).width(280.dp)
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp)
)
}
@@ -294,7 +304,7 @@
value = "Text",
>
singleLine = true,
- modifier = Modifier.testTag(TextFieldTag).width(280.dp)
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp)
)
}
@@ -310,7 +320,7 @@
placeholder = { Text("placeholder") },
label = { Text("Label") },
singleLine = true,
- modifier = Modifier.testTag(TextFieldTag).width(280.dp)
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp)
)
}
@@ -327,7 +337,7 @@
>
placeholder = { Text("placeholder") },
singleLine = true,
- modifier = Modifier.testTag(TextFieldTag).width(280.dp)
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp)
)
}
@@ -345,7 +355,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.testTag(TextFieldTag).width(280.dp)
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp)
)
}
@@ -361,7 +371,7 @@
>
singleLine = true,
enabled = false,
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -378,7 +388,7 @@
>
singleLine = true,
enabled = false,
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -396,7 +406,7 @@
value = longText,
},
singleLine = true,
- modifier = Modifier.width(300.dp),
+ modifier = Modifier.requiredWidth(300.dp),
enabled = false
)
}
@@ -419,7 +429,7 @@
OutlinedTextField(
value = TextFieldValue("Text"),
>
- modifier = Modifier.testTag(TextFieldTag).width(280.dp),
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp),
enabled = true,
readOnly = true
)
@@ -434,7 +444,7 @@
OutlinedTextField(
value = TextFieldValue("Text"),
>
- modifier = Modifier.testTag(TextFieldTag).width(280.dp),
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(280.dp),
enabled = true,
readOnly = true
)
@@ -452,7 +462,7 @@
OutlinedTextField(
value = longText,
},
- modifier = Modifier.testTag(TextFieldTag).width(300.dp),
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(300.dp),
singleLine = true,
enabled = true,
readOnly = true
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
index 11d7862..4c2d8ec 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
@@ -20,9 +20,9 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalContentColor
@@ -102,7 +102,7 @@
value = "input",
>
label = {},
- modifier = Modifier.width(40.dp)
+ modifier = Modifier.requiredWidth(40.dp)
)
}
.assertWidthIsEqualTo(40.dp)
@@ -498,11 +498,11 @@
OutlinedTextField(
value = "text",
>
- modifier = Modifier.preferredWidth(textFieldWidth),
+ modifier = Modifier.width(textFieldWidth),
label = {},
leadingIcon = {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
leadingPosition.value = it.positionInRoot()
leadingSize.value = it.size
}
@@ -510,7 +510,7 @@
},
trailingIcon = {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
trailingPosition.value = it.positionInRoot()
trailingSize.value = it.size
}
@@ -556,8 +556,8 @@
}
)
},
- trailingIcon = { Box(Modifier.preferredSize(iconSize)) },
- leadingIcon = { Box(Modifier.preferredSize(iconSize)) }
+ trailingIcon = { Box(Modifier.size(iconSize)) },
+ leadingIcon = { Box(Modifier.size(iconSize)) }
)
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt
index 7b49507..1f87e48 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt
@@ -18,8 +18,8 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.material.GOLDEN_MATERIAL
import androidx.compose.material.LocalContentColor
import androidx.compose.material.Text
@@ -81,7 +81,7 @@
value = "Text",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -97,7 +97,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -113,7 +113,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -132,7 +132,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp)
+ modifier = Modifier.requiredWidth(280.dp)
)
}
}
@@ -151,7 +151,7 @@
>
label = { Text("Label") },
isErrorValue = true,
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -168,7 +168,7 @@
>
label = { Text("Label") },
isErrorValue = true,
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -182,7 +182,7 @@
TextField(
value = "Hello, world!",
>
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
}
@@ -197,7 +197,9 @@
value = "Text",
>
label = { Text("Label") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -210,7 +212,9 @@
TextField(
value = "Text",
>
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -225,7 +229,9 @@
>
label = { Text("Label") },
placeholder = { Text("placeholder") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -241,7 +247,9 @@
value = "",
>
placeholder = { Text("placeholder") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -257,7 +265,9 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.height(300.dp).width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredHeight(300.dp)
+ .requiredWidth(280.dp)
+ .testTag(TextFieldTag)
)
}
@@ -272,7 +282,7 @@
>
singleLine = true,
label = { Text("Label") },
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -286,7 +296,7 @@
value = "Text",
>
singleLine = true,
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -302,7 +312,7 @@
placeholder = { Text("placeholder") },
label = { Text("Label") },
singleLine = true,
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -319,7 +329,7 @@
>
placeholder = { Text("placeholder") },
singleLine = true,
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -337,7 +347,7 @@
value = "",
>
label = { Text("Label") },
- modifier = Modifier.width(280.dp).testTag(TextFieldTag)
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag)
)
}
@@ -350,7 +360,7 @@
TextField(
value = TextFieldValue("Text"),
>
- modifier = Modifier.width(280.dp).testTag(TextFieldTag),
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag),
singleLine = true,
enabled = false
)
@@ -366,7 +376,7 @@
value = TextFieldValue("Text"),
>
singleLine = true,
- modifier = Modifier.width(280.dp).testTag(TextFieldTag),
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag),
enabled = false
)
}
@@ -383,7 +393,7 @@
value = longText,
},
singleLine = true,
- modifier = Modifier.testTag(TextFieldTag).width(300.dp),
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(300.dp),
enabled = false
)
}
@@ -405,7 +415,7 @@
TextField(
value = TextFieldValue("Text"),
>
- modifier = Modifier.width(280.dp).testTag(TextFieldTag),
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag),
enabled = true,
readOnly = true
)
@@ -420,7 +430,7 @@
TextField(
value = TextFieldValue("Text"),
>
- modifier = Modifier.width(280.dp).testTag(TextFieldTag),
+ modifier = Modifier.requiredWidth(280.dp).testTag(TextFieldTag),
enabled = true,
readOnly = true
)
@@ -438,7 +448,7 @@
TextField(
value = longText,
},
- modifier = Modifier.testTag(TextFieldTag).width(300.dp),
+ modifier = Modifier.testTag(TextFieldTag).requiredWidth(300.dp),
singleLine = true,
enabled = true,
readOnly = true
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
index fde5b7d..7ea7709 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
@@ -25,10 +25,10 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalContentColor
@@ -116,7 +116,7 @@
value = "input",
>
label = {},
- modifier = Modifier.preferredHeight(20.dp)
+ modifier = Modifier.height(20.dp)
)
}
.assertHeightIsEqualTo(20.dp)
@@ -129,7 +129,7 @@
value = "input",
>
label = {},
- modifier = Modifier.width(40.dp)
+ modifier = Modifier.requiredWidth(40.dp)
)
}
.assertWidthIsEqualTo(40.dp)
@@ -297,7 +297,7 @@
}
)
},
- modifier = Modifier.preferredHeight(56.dp)
+ modifier = Modifier.height(56.dp)
)
}
}
@@ -338,7 +338,7 @@
}
)
},
- modifier = Modifier.preferredHeight(56.dp)
+ modifier = Modifier.height(56.dp)
)
}
}
@@ -368,7 +368,7 @@
TextField(
value = "",
>
- modifier = Modifier.preferredHeight(height),
+ modifier = Modifier.height(height),
label = {
Text(
text = "label",
@@ -489,7 +489,7 @@
Box {
TextField(
modifier = Modifier
- .preferredHeight(60.dp)
+ .height(60.dp)
.testTag(TextfieldTag),
value = "",
>
@@ -534,14 +534,14 @@
rule.setMaterialContent {
Box {
TextField(
- modifier = Modifier.preferredHeight(height).testTag(TextfieldTag),
+ modifier = Modifier.height(height).testTag(TextfieldTag),
value = "",
>
label = {},
placeholder = {
Text(
text = "placeholder",
- modifier = Modifier.height(20.dp)
+ modifier = Modifier.requiredHeight(20.dp)
.onGloballyPositioned {
placeholderPosition.value = it.positionInRoot()
placeholderSize.value = it.size
@@ -646,11 +646,11 @@
TextField(
value = "text",
>
- modifier = Modifier.preferredSize(textFieldWidth, textFieldHeight),
+ modifier = Modifier.size(textFieldWidth, textFieldHeight),
label = {},
leadingIcon = {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
leadingPosition.value = it.positionInRoot()
leadingSize.value = it.size
}
@@ -658,7 +658,7 @@
},
trailingIcon = {
Box(
- Modifier.preferredSize(size).onGloballyPositioned {
+ Modifier.size(size).onGloballyPositioned {
trailingPosition.value = it.positionInRoot()
trailingSize.value = it.size
}
@@ -699,7 +699,7 @@
TextField(
value = "",
>
- modifier = Modifier.preferredHeight(height),
+ modifier = Modifier.height(height),
label = {
Text(
text = "label",
@@ -708,8 +708,8 @@
}
)
},
- trailingIcon = { Box(Modifier.preferredSize(iconSize)) },
- leadingIcon = { Box(Modifier.preferredSize(iconSize)) }
+ trailingIcon = { Box(Modifier.size(iconSize)) },
+ leadingIcon = { Box(Modifier.size(iconSize)) }
)
}
}
@@ -731,7 +731,7 @@
TextField(
value = "",
>
- modifier = Modifier.preferredHeight(height),
+ modifier = Modifier.height(height),
label = {
Text(
text = "label",
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
index 9c0969e..5f38585 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
@@ -24,8 +24,8 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -501,7 +501,7 @@
Row(
Modifier.fillMaxWidth()
.padding(contentPadding)
- .preferredHeight(AppBarHeight),
+ .height(AppBarHeight),
horizontalArrangement = Arrangement.SpaceBetween,
content = content
)
@@ -512,10 +512,10 @@
// TODO: this should probably be part of the touch target of the start and end icons, clarify this
private val AppBarHorizontalPadding = 4.dp
// Start inset for the title when there is no navigation icon provided
-private val TitleInsetWithoutIcon = Modifier.preferredWidth(16.dp - AppBarHorizontalPadding)
+private val TitleInsetWithoutIcon = Modifier.width(16.dp - AppBarHorizontalPadding)
// Start inset for the title when there is a navigation icon provided
private val TitleIconModifier = Modifier.fillMaxHeight()
- .preferredWidth(72.dp - AppBarHorizontalPadding)
+ .width(72.dp - AppBarHorizontalPadding)
// The gap on all sides between the FAB and the cutout
private val BottomAppBarCutoutOffset = 8.dp
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
index 0c61187..58d9c28 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
@@ -28,7 +28,7 @@
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
@@ -97,7 +97,7 @@
modifier = modifier
) {
Row(
- Modifier.fillMaxWidth().preferredHeight(BottomNavigationHeight),
+ Modifier.fillMaxWidth().height(BottomNavigationHeight),
horizontalArrangement = Arrangement.SpaceBetween,
content = content
)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
index 7c299c6..fe76953f 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
@@ -27,7 +27,7 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
@@ -324,7 +324,7 @@
Surface(
swipeable
.fillMaxWidth()
- .heightIn(min = sheetPeekHeight)
+ .requiredHeightIn(min = sheetPeekHeight)
.onGloballyPositioned {
bottomSheetHeight = it.size.height.toFloat()
},
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Checkbox.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Checkbox.kt
index 84173da..fe4f57e 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Checkbox.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Checkbox.kt
@@ -26,7 +26,7 @@
import androidx.compose.foundation.Interaction
import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.selection.triStateToggleable
import androidx.compose.material.ripple.rememberRipple
@@ -276,7 +276,7 @@
val checkColor by colors.checkmarkColor(value)
val boxColor by colors.boxColor(enabled, value)
val borderColor by colors.borderColor(enabled, value)
- Canvas(modifier.wrapContentSize(Alignment.Center).size(CheckboxSize)) {
+ Canvas(modifier.wrapContentSize(Alignment.Center).requiredSize(CheckboxSize)) {
val strokeWidthPx = floor(StrokeWidth.toPx())
drawBox(
boxColor = boxColor,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Divider.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Divider.kt
index a3fa093..9e35e0f 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Divider.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Divider.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -49,7 +49,7 @@
Box(
modifier.then(indentMod)
.fillMaxWidth()
- .preferredHeight(thickness)
+ .height(thickness)
.background(color = color)
)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
index eb8eed5..1e6ac33 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
@@ -28,7 +28,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSizeIn
+import androidx.compose.foundation.layout.sizeIn
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
@@ -332,7 +332,7 @@
Surface(
modifier = with(LocalDensity.current) {
Modifier
- .preferredSizeIn(
+ .sizeIn(
minWidth = modalDrawerConstraints.minWidth.toDp(),
minHeight = modalDrawerConstraints.minHeight.toDp(),
maxWidth = modalDrawerConstraints.maxWidth.toDp(),
@@ -463,7 +463,7 @@
)
Surface(
modifier = with(LocalDensity.current) {
- Modifier.preferredSizeIn(
+ Modifier.sizeIn(
minWidth = modalDrawerConstraints.minWidth.toDp(),
minHeight = modalDrawerConstraints.minHeight.toDp(),
maxWidth = modalDrawerConstraints.maxWidth.toDp(),
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
index fff2336..98fd3dd 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
@@ -27,8 +27,8 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSizeIn
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.sizeIn
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
@@ -152,7 +152,7 @@
elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation()
) {
FloatingActionButton(
- modifier = modifier.preferredSizeIn(
+ modifier = modifier.sizeIn(
minWidth = ExtendedFabSize,
minHeight = ExtendedFabSize
),
@@ -175,7 +175,7 @@
} else {
Row(verticalAlignment = Alignment.CenterVertically) {
icon()
- Spacer(Modifier.preferredWidth(ExtendedFabIconPadding))
+ Spacer(Modifier.width(ExtendedFabIconPadding))
text()
}
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt
index d6340ee..0416cfb 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt
@@ -17,7 +17,7 @@
package androidx.compose.material
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@@ -148,4 +148,4 @@
private fun Size.isInfinite() = width.isInfinite() && height.isInfinite()
// Default icon size, for icons with no intrinsic size information
-private val DefaultIconSizeModifier = Modifier.preferredSize(24.dp)
+private val DefaultIconSizeModifier = Modifier.size(24.dp)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
index e8ceb14..56b7f40 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.toggleable
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
@@ -123,4 +123,4 @@
// TODO: b/149691127 investigate our strategy around accessibility touch targets, and remove
// per-component definitions of this size.
// Diameter of the IconButton, to allow for correct minimum touch target size for accessibility
-private val IconButtonSizeModifier = Modifier.preferredSize(48.dp)
+private val IconButtonSizeModifier = Modifier.size(48.dp)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
index f285a10..2d02962 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
@@ -19,9 +19,9 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeightIn
-import androidx.compose.foundation.layout.preferredSizeIn
-import androidx.compose.foundation.layout.preferredWidthIn
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.sizeIn
+import androidx.compose.foundation.layout.widthIn
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
@@ -136,11 +136,11 @@
trailing: @Composable (() -> Unit)?
) {
val minHeight = if (icon == null) MinHeight else MinHeightWithIcon
- Row(modifier.preferredHeightIn(min = minHeight)) {
+ Row(modifier.heightIn(min = minHeight)) {
if (icon != null) {
Box(
Modifier.align(Alignment.CenterVertically)
- .preferredWidthIn(min = IconLeftPadding + IconMinPaddedWidth)
+ .widthIn(min = IconLeftPadding + IconMinPaddedWidth)
.padding(
start = IconLeftPadding,
top = IconVerticalPadding,
@@ -199,14 +199,14 @@
trailing: @Composable (() -> Unit)?
) {
val minHeight = if (icon == null) MinHeight else MinHeightWithIcon
- Row(modifier.preferredHeightIn(min = minHeight)) {
+ Row(modifier.heightIn(min = minHeight)) {
val columnModifier = Modifier.weight(1f)
.padding(start = ContentLeftPadding, end = ContentRightPadding)
if (icon != null) {
Box(
Modifier
- .preferredSizeIn(
+ .sizeIn(
minWidth = IconLeftPadding + IconMinPaddedWidth,
minHeight = minHeight
)
@@ -257,7 +257,7 @@
) {
Box(
// TODO(popam): find way to center and wrap content without minHeight
- Modifier.preferredHeightIn(min = minHeight)
+ Modifier.heightIn(min = minHeight)
.padding(end = TrailingRightPadding),
contentAlignment = Alignment.Center
) { trailing() }
@@ -296,12 +296,12 @@
overlineText: @Composable (() -> Unit)?,
trailing: @Composable (() -> Unit)?
) {
- Row(modifier.preferredHeightIn(min = MinHeight)) {
+ Row(modifier.heightIn(min = MinHeight)) {
if (icon != null) {
val minSize = IconLeftPadding + IconMinPaddedWidth
Box(
Modifier
- .preferredSizeIn(minWidth = minSize, minHeight = minSize)
+ .sizeIn(minWidth = minSize, minHeight = minSize)
.padding(
start = IconLeftPadding,
top = IconThreeLineVerticalPadding,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
index 9d9ac0a..b4c0338 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
@@ -32,8 +32,8 @@
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSizeIn
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.sizeIn
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ripple.rememberRipple
@@ -127,7 +127,7 @@
Column(
modifier = modifier
.padding(vertical = DropdownMenuVerticalPadding)
- .preferredWidth(IntrinsicSize.Max)
+ .width(IntrinsicSize.Max)
.verticalScroll(rememberScrollState()),
content = content
)
@@ -154,7 +154,7 @@
)
.fillMaxWidth()
// Preferred min and max width used during the intrinsic measurement.
- .preferredSizeIn(
+ .sizeIn(
minWidth = DropdownMenuItemDefaultMinWidth,
maxWidth = DropdownMenuItemDefaultMaxWidth,
minHeight = DropdownMenuItemDefaultMinHeight
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt
index d662254..58fe636 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt
@@ -29,7 +29,7 @@
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.focusable
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.progressSemantics
import androidx.compose.material.ProgressIndicatorDefaults.IndicatorBackgroundOpacity
import androidx.compose.runtime.Composable
@@ -75,7 +75,7 @@
Canvas(
modifier
.progressSemantics(progress)
- .preferredSize(LinearIndicatorWidth, LinearIndicatorHeight)
+ .size(LinearIndicatorWidth, LinearIndicatorHeight)
.focusable()
) {
val strokeWidth = ProgressIndicatorDefaults.StrokeWidth.toPx()
@@ -149,7 +149,7 @@
Canvas(
modifier
.progressSemantics()
- .preferredSize(LinearIndicatorWidth, LinearIndicatorHeight)
+ .size(LinearIndicatorWidth, LinearIndicatorHeight)
.focusable()
) {
val strokeWidth = ProgressIndicatorDefaults.StrokeWidth.toPx()
@@ -226,7 +226,7 @@
Canvas(
modifier
.progressSemantics(progress)
- .preferredSize(CircularIndicatorDiameter)
+ .size(CircularIndicatorDiameter)
.focusable()
) {
// Start at 12 O'clock
@@ -304,7 +304,7 @@
Canvas(
modifier
.progressSemantics()
- .preferredSize(CircularIndicatorDiameter)
+ .size(CircularIndicatorDiameter)
.focusable()
) {
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/RadioButton.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/RadioButton.kt
index e691c04..bdb73d6 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/RadioButton.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/RadioButton.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.ripple.rememberRipple
@@ -96,7 +96,7 @@
)
.wrapContentSize(Alignment.Center)
.padding(RadioButtonPadding)
- .size(RadioButtonSize)
+ .requiredSize(RadioButtonSize)
) {
drawRadio(radioColor, dotRadius)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
index d92687c..649cb0c 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
@@ -37,9 +37,9 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeightIn
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidthIn
+import androidx.compose.foundation.layout.heightIn
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.progressSemantics
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.SliderDefaults.InactiveTrackColorAlpha
@@ -283,7 +283,7 @@
)
)
) {
- Spacer(Modifier.preferredSize(thumbSize, thumbSize))
+ Spacer(Modifier.size(thumbSize, thumbSize))
}
}
}
@@ -478,7 +478,7 @@
private val SliderHeight = 48.dp
private val SliderMinWidth = 144.dp // TODO: clarify min width
private val DefaultSliderConstraints =
- Modifier.preferredWidthIn(min = SliderMinWidth)
- .preferredHeightIn(max = SliderHeight)
+ Modifier.widthIn(min = SliderMinWidth)
+ .heightIn(max = SliderHeight)
private val SliderToTickAnimation = TweenSpec<Float>(durationMillis = 100)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
index a26c589..cbd704a 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
@@ -27,7 +27,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.CircleShape
@@ -107,7 +107,7 @@
)
.wrapContentSize(Alignment.Center)
.padding(DefaultSwitchPadding)
- .size(SwitchWidth, SwitchHeight)
+ .requiredSize(SwitchWidth, SwitchHeight)
) {
SwitchImpl(
checked = checked,
@@ -178,7 +178,7 @@
interactionState = interactionState,
indication = rememberRipple(bounded = false, radius = ThumbRippleRadius)
)
- .size(ThumbDiameter),
+ .requiredSize(ThumbDiameter),
content = {}
)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt
index bd8eaad..36a9872 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt
@@ -26,8 +26,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
@@ -355,7 +355,7 @@
Box(
modifier
.fillMaxWidth()
- .preferredHeight(height)
+ .height(height)
.background(color = color)
)
}
@@ -385,7 +385,7 @@
fillMaxWidth()
.wrapContentSize(Alignment.BottomStart)
.offset(x = indicatorOffset)
- .preferredWidth(currentTabWidth)
+ .width(currentTabWidth)
}
/**
diff --git a/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/DrawScopeSample.kt b/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/DrawScopeSample.kt
index 4857e04..bfac00f 100644
--- a/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/DrawScopeSample.kt
+++ b/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/DrawScopeSample.kt
@@ -18,7 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.Canvas
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -36,7 +36,7 @@
fun DrawScopeSample() {
// Sample showing how to use the DrawScope receiver scope to issue
// drawing commands
- Canvas(Modifier.preferredSize(120.dp)) {
+ Canvas(Modifier.size(120.dp)) {
drawRect(color = Color.Gray) // Draw grey background
// Inset content by 10 pixels on the left/right sides and 12 by the
// top/bottom
@@ -59,7 +59,7 @@
@Sampled
@Composable
fun DrawScopeBatchedTransformSample() {
- Canvas(Modifier.preferredSize(120.dp)) { // CanvasScope
+ Canvas(Modifier.size(120.dp)) { // CanvasScope
inset(20.0f) {
// Use withTransform to batch multiple transformations for 1 or more drawing calls
// that are to be drawn.
diff --git a/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/PathEffectSample.kt b/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/PathEffectSample.kt
index 09c5dcc..b25f41e 100644
--- a/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/PathEffectSample.kt
+++ b/compose/ui/ui-graphics/samples/src/main/java/androidx/compose/ui/graphics/samples/PathEffectSample.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -44,7 +44,7 @@
close()
}
Column(modifier = Modifier.fillMaxHeight().wrapContentSize(Alignment.Center)) {
- val canvasModifier = Modifier.size(80.dp).align(Alignment.CenterHorizontally)
+ val canvasModifier = Modifier.requiredSize(80.dp).align(Alignment.CenterHorizontally)
// StampedPathEffectStyle.Morph will modify the lines of the square to be curved to fit
// the curvature of the circle itself. Each stamped square will be rendered as an arc
@@ -64,7 +64,7 @@
)
}
- Spacer(modifier = Modifier.size(10.dp))
+ Spacer(modifier = Modifier.requiredSize(10.dp))
// StampedPathEffectStyle.Rotate will draw the square repeatedly around the circle
// such that each stamped square is centered on the circumference of the circle and is
@@ -84,7 +84,7 @@
)
}
- Spacer(modifier = Modifier.size(10.dp))
+ Spacer(modifier = Modifier.requiredSize(10.dp))
// StampedPathEffectStyle.Translate will draw the square repeatedly around the circle
// with the top left of each stamped square on the circumference of the circle
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
index 8e1f2ff..363f58c 100644
--- a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicText
import androidx.compose.material.Button
import androidx.compose.material.Icon
@@ -333,7 +333,7 @@
Inspectable(slotTableRecord) {
Column {
Text(text = "Hello World", color = Color.Green)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Image(Icons.Filled.Call, null)
}
}
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/ParameterFactoryTest.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/ParameterFactoryTest.kt
index 0232b41..ccc359c 100644
--- a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/ParameterFactoryTest.kt
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/ParameterFactoryTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.CutCornerShape
@@ -442,7 +442,7 @@
.padding(2.0.dp)
.fillMaxWidth()
.wrapContentHeight(Alignment.Bottom)
- .preferredWidth(30.0.dp)
+ .width(30.0.dp)
.paint(TestPainter(10f, 20f))
)!!
) {
@@ -464,7 +464,7 @@
parameter("align", ParameterType.String, "Bottom")
parameter("unbounded", ParameterType.Boolean, false)
}
- parameter("preferredWidth", ParameterType.DimensionDp, 30.0f)
+ parameter("width", ParameterType.DimensionDp, 30.0f)
parameter("paint", ParameterType.String, "") {
parameter("alignment", ParameterType.String, "Center")
parameter("alpha", ParameterType.Float, 1.0f)
diff --git a/compose/ui/ui-test-junit4/src/androidAndroidTest/kotlin/androidx/compose/ui/test/junit4/WaitingForPopupTest.kt b/compose/ui/ui-test-junit4/src/androidAndroidTest/kotlin/androidx/compose/ui/test/junit4/WaitingForPopupTest.kt
index b387837..63fc721 100644
--- a/compose/ui/ui-test-junit4/src/androidAndroidTest/kotlin/androidx/compose/ui/test/junit4/WaitingForPopupTest.kt
+++ b/compose/ui/ui-test-junit4/src/androidAndroidTest/kotlin/androidx/compose/ui/test/junit4/WaitingForPopupTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.test.junit4
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
@@ -39,7 +39,7 @@
@Composable
private fun ShowPopup() {
Popup {
- Box(Modifier.preferredSize(10.dp, 10.dp))
+ Box(Modifier.size(10.dp, 10.dp))
}
}
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/BitmapCapturingTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/BitmapCapturingTest.kt
index 959d16d..56d88eb 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/BitmapCapturingTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/BitmapCapturingTest.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.AlertDialog
import androidx.compose.material.Text
import androidx.compose.testutils.assertContainsColor
@@ -202,13 +202,13 @@
Box(
Modifier
.testTag(tag11)
- .preferredSize(100.toDp(), 50.toDp())
+ .size(100.toDp(), 50.toDp())
.background(color = color11)
)
Box(
Modifier
.testTag(tag12)
- .preferredSize(100.toDp(), 50.toDp())
+ .size(100.toDp(), 50.toDp())
.background(color12)
)
}
@@ -216,13 +216,13 @@
Box(
Modifier
.testTag(tag21)
- .preferredSize(100.toDp(), 50.toDp())
+ .size(100.toDp(), 50.toDp())
.background(color21)
)
Box(
Modifier
.testTag(tag22)
- .preferredSize(100.toDp(), 50.toDp())
+ .size(100.toDp(), 50.toDp())
.background(color22)
)
}
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/IsDisplayedTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/IsDisplayedTest.kt
index 3803cbf..9483ba5 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/IsDisplayedTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/IsDisplayedTest.kt
@@ -26,9 +26,9 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.size
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
@@ -83,8 +83,10 @@
BoundaryNode("item$i") {
Box(
modifier =
- with(Modifier) { width?.let { width(it) } ?: fillMaxWidth() }
- .then(with(Modifier) { height?.let { height(it) } ?: fillMaxHeight() })
+ with(Modifier) { width?.let { requiredWidth(it) } ?: fillMaxWidth() }
+ .then(
+ with(Modifier) { height?.let { requiredHeight(it) } ?: fillMaxHeight() }
+ )
.background(colors[i % colors.size])
)
}
@@ -107,7 +109,7 @@
@Test
fun componentInScrollable_isDisplayed() {
rule.setContent {
- Column(modifier = Modifier.size(100.dp).verticalScroll(rememberScrollState())) {
+ Column(modifier = Modifier.requiredSize(100.dp).verticalScroll(rememberScrollState())) {
repeat(10) { Item(it, height = 30.dp) }
}
}
@@ -119,7 +121,7 @@
@Test
fun componentInScrollable_isNotDisplayed() {
rule.setContent {
- Column(modifier = Modifier.size(100.dp).verticalScroll(rememberScrollState())) {
+ Column(modifier = Modifier.requiredSize(100.dp).verticalScroll(rememberScrollState())) {
repeat(10) { Item(it, height = 30.dp) }
}
}
@@ -177,7 +179,7 @@
@Test
fun rowTooSmall() {
rule.setContent {
- Row(modifier = Modifier.size(100.dp)) {
+ Row(modifier = Modifier.requiredSize(100.dp)) {
repeat(10) { Item(it, width = 30.dp) }
}
}
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt
index febc6ad..bf73c7a2 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt
@@ -18,8 +18,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
@@ -58,7 +58,7 @@
}
) {
Box(
- Modifier.preferredSize(10.dp)
+ Modifier.size(10.dp)
.align(Alignment.Start)
.onGloballyPositioned { coordinates ->
childCoordinates = coordinates
@@ -82,16 +82,16 @@
var childCoordinates: LayoutCoordinates? = null
rule.setContent {
with(LocalDensity.current) {
- Box(Modifier.preferredWidth(40.toDp()), contentAlignment = Alignment.Center) {
+ Box(Modifier.width(40.toDp()), contentAlignment = Alignment.Center) {
Column(
- Modifier.preferredWidth(20.toDp())
+ Modifier.width(20.toDp())
.onGloballyPositioned { coordinates: LayoutCoordinates ->
parentCoordinates = coordinates
latch.countDown()
}
) {
Box(
- Modifier.preferredSize(10.toDp())
+ Modifier.size(10.toDp())
.align(Alignment.CenterHorizontally)
.onGloballyPositioned { coordinates ->
childCoordinates = coordinates
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt
index 3566122..d87b77f 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt
@@ -16,7 +16,7 @@
package androidx.compose.ui.test
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.MeasureBlock
@@ -86,7 +86,7 @@
with(LocalDensity.current) {
Layout(
content,
- modifier.size(crossAxisSize.toDp(), columnHeight.toDp()),
+ modifier.requiredSize(crossAxisSize.toDp(), columnHeight.toDp()),
verticalLayout(offset, columnHeight)
)
}
@@ -102,7 +102,7 @@
with(LocalDensity.current) {
Layout(
content,
- modifier.size(rowWidth.toDp(), crossAxisSize.toDp()),
+ modifier.requiredSize(rowWidth.toDp(), crossAxisSize.toDp()),
horizontalLayout(offset, rowWidth)
)
}
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/assertions/BoundsAssertionsTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/assertions/BoundsAssertionsTest.kt
index 7703b0b..0a0129f 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/assertions/BoundsAssertionsTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/assertions/BoundsAssertionsTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -67,7 +67,7 @@
Box(
modifier = Modifier
.testTag(tag)
- .size(80.dp, 100.dp)
+ .requiredSize(80.dp, 100.dp)
.background(color = Color.Black)
)
}
@@ -191,7 +191,7 @@
modifier = Modifier
.testTag(tag)
.offset((-30).dp, (-10).dp)
- .size(80.dp, 100.dp)
+ .requiredSize(80.dp, 100.dp)
.background(color = Color.Black)
)
}
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt
index fdd652e..768e17c 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.ui.Modifier
@@ -126,7 +126,7 @@
with(LocalDensity.current) {
if (isVertical) {
Column(
- Modifier.size(100.toDp())
+ Modifier.requiredSize(100.toDp())
.testTag("viewport")
.verticalScroll(
rememberScrollState(),
@@ -138,7 +138,7 @@
}
} else {
Row(
- Modifier.size(100.toDp())
+ Modifier.requiredSize(100.toDp())
.testTag("viewport")
.horizontalScroll(
rememberScrollState(),
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt
index 3838ccd..2950945 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
@@ -173,7 +173,7 @@
Column(
Modifier
.testTag("scrollable")
- .size(100.toDp(), 1000.toDp())
+ .requiredSize(100.toDp(), 1000.toDp())
.verticalScroll(
scrollState,
flingSpec = FloatExponentialDecaySpec()
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt
index eb655d8..8c40101 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -44,7 +44,9 @@
) {
with(LocalDensity.current) {
Box(
- modifier = modifier.testTag(tag).size(width.toDp(), height.toDp()).background(color)
+ modifier = modifier.testTag(tag)
+ .requiredSize(width.toDp(), height.toDp())
+ .background(color)
)
}
}
diff --git a/compose/ui/ui-tooling-data/src/androidTest/java/androidx/compose/ui/tooling/data/InspectableTests.kt b/compose/ui/ui-tooling-data/src/androidTest/java/androidx/compose/ui/tooling/data/InspectableTests.kt
index 73500d3..1f6f4d6 100644
--- a/compose/ui/ui-tooling-data/src/androidTest/java/androidx/compose/ui/tooling/data/InspectableTests.kt
+++ b/compose/ui/ui-tooling-data/src/androidTest/java/androidx/compose/ui/tooling/data/InspectableTests.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.ModalDrawer
import androidx.compose.material.Text
@@ -53,7 +53,7 @@
Inspectable(slotTableRecord) {
Column {
Box(
- Modifier.preferredSize(100.dp).drawBehind {
+ Modifier.size(100.dp).drawBehind {
drawRect(Color(0xFF))
}
)
@@ -296,7 +296,7 @@
Inspectable(CompositionDataRecord.create()) {
Column {
InInspectionModeOnly {
- Box(Modifier.preferredSize(100.dp).background(color = Color(0xFF)))
+ Box(Modifier.size(100.dp).background(color = Color(0xFF)))
displayed = true
}
}
@@ -312,7 +312,7 @@
show {
Column {
InInspectionModeOnly {
- Box(Modifier.preferredSize(100.dp).background(color = Color(0xFF)))
+ Box(Modifier.size(100.dp).background(color = Color(0xFF)))
displayed = true
}
}
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/LayoutInspectorTreeTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/LayoutInspectorTreeTest.kt
index 64c3020..835a64d 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/LayoutInspectorTreeTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/LayoutInspectorTreeTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicText
import androidx.compose.material.Button
import androidx.compose.material.Icon
@@ -318,7 +318,7 @@
Inspectable(slotTableRecord) {
Column {
Text(text = "Hello World", color = Color.Green)
- Spacer(Modifier.preferredHeight(16.dp))
+ Spacer(Modifier.height(16.dp))
Image(Icons.Filled.Call, null)
}
}
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
index dc8b8c1..d184a93 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.CutCornerShape
@@ -438,7 +438,7 @@
.padding(2.0.dp)
.fillMaxWidth()
.wrapContentHeight(Alignment.Bottom)
- .preferredWidth(30.0.dp)
+ .width(30.0.dp)
.paint(TestPainter(10f, 20f))
)!!
) {
@@ -460,7 +460,7 @@
parameter("align", ParameterType.String, "Bottom")
parameter("unbounded", ParameterType.Boolean, false)
}
- parameter("preferredWidth", ParameterType.DimensionDp, 30.0f)
+ parameter("width", ParameterType.DimensionDp, 30.0f)
parameter("paint", ParameterType.String, "") {
parameter("alignment", ParameterType.String, "Center")
parameter("alpha", ParameterType.Float, 1.0f)
diff --git a/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt b/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt
index 3bab754..327a41f 100644
--- a/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt
+++ b/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.viewinterop
import android.os.Build
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
import androidx.compose.testutils.assertPixels
@@ -97,7 +97,7 @@
CompositionLocalProvider(LocalDensity provides density) {
AndroidViewBinding(
TestLayoutBinding::inflate,
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
Truth.assertThat(it.size).isEqualTo(IntSize(sizeIpx, sizeIpx))
}
)
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/AnimatedVectorGraphicsDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/AnimatedVectorGraphicsDemo.kt
index f6e6af1..b45f5eb 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/AnimatedVectorGraphicsDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/AnimatedVectorGraphicsDemo.kt
@@ -28,7 +28,7 @@
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -61,7 +61,7 @@
Image(
painter = image.painterFor(atEnd),
contentDescription = "AnimatedImageVector",
- modifier = Modifier.preferredSize(200.dp).clickable {
+ modifier = Modifier.size(200.dp).clickable {
atEnd = !atEnd
},
contentScale = ContentScale.Crop
@@ -71,7 +71,7 @@
Image(
painter = createSampleVectorPainter(toggle),
contentDescription = "Transition with vector graphics",
- modifier = Modifier.preferredSize(200.dp).clickable {
+ modifier = Modifier.size(200.dp).clickable {
toggle = !toggle
},
contentScale = ContentScale.Crop
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DeclarativeGraphicsDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DeclarativeGraphicsDemo.kt
index d9cf0d1..52f5641 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DeclarativeGraphicsDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DeclarativeGraphicsDemo.kt
@@ -17,7 +17,7 @@
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -40,7 +40,7 @@
modifier =
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(120.dp, 120.dp)
+ .size(120.dp, 120.dp)
) {
drawRect(color = Color.Gray)
// Inset content by 10 pixels on the left/right sides and 12 by the
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DialogDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DialogDemo.kt
index b5b9090..442665e 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DialogDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/DialogDemo.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Text
@@ -46,7 +46,7 @@
if (openDialog) {
Dialog( openDialog = false }) {
Card(
- modifier = Modifier.preferredSize(350.dp, 200.dp).padding(10.dp),
+ modifier = Modifier.size(350.dp, 200.dp).padding(10.dp),
elevation = elevation,
shape = shape
) {
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/PopupDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/PopupDemo.kt
index 87f9053..28d1e5e 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/PopupDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/PopupDemo.kt
@@ -27,11 +27,11 @@
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.BasicTextField
@@ -149,14 +149,14 @@
// This example utilizes the Card to draw its shadow.
Column(Modifier.align(Alignment.CenterHorizontally)) {
- Box(Modifier.preferredSize(110.dp).background(background)) {
+ Box(Modifier.size(110.dp).background(background)) {
Popup(
alignment = Alignment.Center,
properties = PopupProperties(focusable = true),
dismissCounter++ }
) {
Card(
- Modifier.preferredSize(contentSize),
+ Modifier.size(contentSize),
elevation = elevation,
shape = shape
) {
@@ -165,9 +165,9 @@
}
}
- Spacer(Modifier.height(20.dp))
+ Spacer(Modifier.requiredHeight(20.dp))
Text("Dismiss clicked: $dismissCounter (focusable: $isFocusable)")
- Spacer(Modifier.height(20.dp))
+ Spacer(Modifier.requiredHeight(20.dp))
Row {
Button( elevation -= 1.dp }) {
Text("-1")
@@ -177,15 +177,15 @@
Text("+1")
}
}
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Button( shape = if (shape == CircleShape) RectangleShape else CircleShape }) {
Text("Toggle shape")
}
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Button( isFocusable = !isFocusable }) {
Text("Toggle focusable")
}
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Button(
>
background =
@@ -194,7 +194,7 @@
) {
Text("Toggle container background")
}
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Row {
Button( contentSize -= 10.dp }) {
Text("-10.dp")
@@ -212,11 +212,11 @@
val showPopup = remember { mutableStateOf(true) }
Column(Modifier.align(Alignment.CenterHorizontally)) {
- Box(Modifier.preferredSize(100.dp)) {
+ Box(Modifier.size(100.dp)) {
if (showPopup.value) {
Popup(alignment = Alignment.Center) {
Box(
- Modifier.preferredSize(70.dp).background(Color.Green, CircleShape),
+ Modifier.size(70.dp).background(Color.Green, CircleShape),
contentAlignment = Alignment.Center
) {
Text(
@@ -247,7 +247,7 @@
val totalContentExamples = 2
val popupCounter = remember { mutableStateOf(0) }
- Box(Modifier.preferredSize(widthSize, heightSize).background(Color.Gray)) {
+ Box(Modifier.size(widthSize, heightSize).background(Color.Gray)) {
Popup(Alignment.Center) {
when (popupContentState.value % totalContentExamples) {
0 -> ClickableTextWithBackground(
@@ -258,13 +258,13 @@
}
)
1 -> Box(
- Modifier.preferredSize(60.dp, 40.dp).background(Color.Blue, CircleShape)
+ Modifier.size(60.dp, 40.dp).background(Color.Blue, CircleShape)
)
}
}
}
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
ClickableTextWithBackground(
text = "Change content",
color = Color.Cyan,
@@ -286,11 +286,11 @@
Column(Modifier.align(Alignment.CenterHorizontally)) {
Box(
- Modifier.preferredSize(containerWidth, containerHeight),
+ Modifier.size(containerWidth, containerHeight),
contentAlignment = parentAlignment.value
) {
Box(
- Modifier.preferredSize(parentWidth.value, parentHeight.value)
+ Modifier.size(parentWidth.value, parentHeight.value)
.background(Color.Blue)
) {
Popup(Alignment.BottomCenter) {
@@ -298,7 +298,7 @@
}
}
}
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
ClickableTextWithBackground(
text = "Change parent's position",
color = Color.Cyan,
@@ -310,7 +310,7 @@
Alignment.TopStart
}
)
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
ClickableTextWithBackground(
text = "Change parent's size",
color = Color.Cyan,
@@ -336,7 +336,7 @@
val counter = remember { mutableStateOf(0) }
val popupAlignment = remember { mutableStateOf(Alignment.TopStart) }
Box(
- modifier = Modifier.preferredSize(widthSize, heightSize).background(Color.Red),
+ modifier = Modifier.size(widthSize, heightSize).background(Color.Red),
contentAlignment = Alignment.BottomCenter
) {
Popup(popupAlignment.value) {
@@ -361,7 +361,7 @@
}
}
- Spacer(Modifier.preferredHeight(10.dp))
+ Spacer(Modifier.height(10.dp))
Text(
modifier = Modifier.align(Alignment.CenterHorizontally)
.background(color = Color.White),
@@ -385,7 +385,7 @@
Text(text = showEmail.value)
Box(
- modifier = Modifier.preferredSize(widthSize, heightSize)
+ modifier = Modifier.size(widthSize, heightSize)
.align(Alignment.CenterHorizontally)
.background(Color.Red)
) {
@@ -399,7 +399,7 @@
}
) {
EditLine(
- modifier = Modifier.preferredWidth(editLineSize),
+ modifier = Modifier.width(editLineSize),
initialText = "",
color = Color.White,
>
@@ -420,23 +420,23 @@
val widthSize = 160.dp
val rectangleState = remember { mutableStateOf(0) }
- Spacer(Modifier.preferredHeight(15.dp))
+ Spacer(Modifier.height(15.dp))
Box(
- modifier = Modifier.preferredSize(widthSize, heightSize).background(Color.Magenta)
+ modifier = Modifier.size(widthSize, heightSize).background(Color.Magenta)
) {
if (showPopup.value) {
Popup(Alignment.Center) {
val size = when (rectangleState.value % 4) {
- 0 -> Modifier.preferredSize(30.dp)
- 1 -> Modifier.preferredSize(100.dp)
- 2 -> Modifier.preferredSize(30.dp, 90.dp)
- else -> Modifier.preferredSize(90.dp, 30.dp)
+ 0 -> Modifier.size(30.dp)
+ 1 -> Modifier.size(100.dp)
+ 2 -> Modifier.size(30.dp, 90.dp)
+ else -> Modifier.size(90.dp, 30.dp)
}
Box(modifier = size.background(Color.Gray))
}
}
}
- Spacer(Modifier.preferredHeight(25.dp))
+ Spacer(Modifier.height(25.dp))
ClickableTextWithBackground(
text = "Change size",
color = Color.Cyan,
@@ -450,13 +450,13 @@
@Composable
private fun ColumnScope.PopupInsideScroller() {
Column(
- Modifier.preferredSize(200.dp, 400.dp)
+ Modifier.size(200.dp, 400.dp)
.align(Alignment.CenterHorizontally)
.verticalScroll(rememberScrollState())
) {
Column(Modifier.fillMaxHeight()) {
Box(
- modifier = Modifier.preferredSize(80.dp, 160.dp).background(Color(0xFF00FF00))
+ modifier = Modifier.size(80.dp, 160.dp).background(Color(0xFF00FF00))
) {
Popup(alignment = Alignment.Center) {
ClickableTextWithBackground(text = "Centered", color = Color.Cyan)
@@ -476,10 +476,10 @@
val widthSize = 190.dp
val heightSize = 120.dp
- Spacer(Modifier.preferredHeight(350.dp))
+ Spacer(Modifier.height(350.dp))
Text("Start typing in the EditText below the parent(Red rectangle)")
Box(
- modifier = Modifier.preferredSize(widthSize, heightSize)
+ modifier = Modifier.size(widthSize, heightSize)
.align(Alignment.CenterHorizontally)
.background(Color.Red)
) {
@@ -492,7 +492,7 @@
EditLine(initialText = "Continue typing...", color = Color.Gray)
- Spacer(Modifier.preferredHeight(24.dp))
+ Spacer(Modifier.height(24.dp))
}
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/VectorGraphicsDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/VectorGraphicsDemo.kt
index fc620d9..12d2f95 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/VectorGraphicsDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/VectorGraphicsDemo.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -51,7 +51,7 @@
Image(
painter = imageVector,
contentDescription = "Crane",
- modifier = Modifier.preferredSize(200.dp, 200.dp),
+ modifier = Modifier.size(200.dp, 200.dp),
contentScale = ContentScale.Inside
)
@@ -59,14 +59,14 @@
Image(
painter = complexImageVector,
contentDescription = "Hourglass",
- modifier = Modifier.preferredSize(64.dp, 64.dp),
+ modifier = Modifier.size(64.dp, 64.dp),
contentScale = ContentScale.Fit
)
Image(
painter = vectorShape(120.dp, 120.dp),
contentDescription = null,
- modifier = Modifier.preferredSize(200.dp, 150.dp)
+ modifier = Modifier.size(200.dp, 150.dp)
)
}
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt
index 628069c..8eefbf1 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.MaterialTheme
@@ -80,7 +80,7 @@
)
}
- Spacer(Modifier.preferredHeight(40.dp))
+ Spacer(Modifier.height(40.dp))
Text("Email", style = labelStyle)
Autofill(
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/CustomFocusOrderDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/CustomFocusOrderDemo.kt
index a31d146..aa39593 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/CustomFocusOrderDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/CustomFocusOrderDemo.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
@@ -109,7 +109,7 @@
Text(
modifier = modifier
.border(width = 1.dp, color = Black)
- .width(50.dp)
+ .requiredWidth(50.dp)
.focusRequester(focusRequester)
.onFocusChanged { color = if (it.isFocused) Green else Black }
.focusModifier()
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt
index 7c17291..0997274 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
@@ -45,12 +45,12 @@
Column(Modifier.background(if (windowInfo.isWindowFocused) White else LightGray)) {
Text("Click the button to show the dialog. Click outside the dialog to dismiss it.")
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Button( showDialog = true }) {
Text("Show Dialog")
}
- Spacer(Modifier.height(50.dp))
+ Spacer(Modifier.requiredHeight(50.dp))
Text("Click this text field to bring the main app in focus.")
TextField(value = mainText, mainText = it })
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt
index 6d94243..a5c21ca 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material.TextField
@@ -47,12 +47,12 @@
Column(Modifier.background(if (windowInfo.isWindowFocused) White else LightGray)) {
Text("Click the button to show the popup. Click outside the popup to dismiss it.")
- Spacer(Modifier.height(10.dp))
+ Spacer(Modifier.requiredHeight(10.dp))
Button( showPopup = true }) {
Text("Show Popup")
}
- Spacer(Modifier.height(50.dp))
+ Spacer(Modifier.requiredHeight(50.dp))
Text("Click this text field to bring the main app in focus.")
TextField(value = mainText, mainText = it })
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt
index ee4ce02..d434562 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -140,7 +140,7 @@
Text(
modifier = modifier
.border(width = 1.dp, color = Black)
- .width(50.dp)
+ .requiredWidth(50.dp)
.focusRequester(focusRequester)
.onFocusChanged { color = if (it.isFocused) Green else Black }
.focusModifier()
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapGestureDetectorDemo.kt
index 9310a64..a0267ae 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapGestureDetectorDemo.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -50,7 +50,7 @@
Box(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) { detectTapGestures( }
.border(2.dp, BorderColor)
.background(color = color.value)
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapInTapDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapInTapDemo.kt
index 5308677..a184412 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapInTapDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DoubleTapInTapDemo.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -67,14 +67,14 @@
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) { detectTapGestures( }
.border(2.dp, BorderColor)
.background(color = outerColor.value)
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(96.dp)
+ .size(96.dp)
.pointerInput(Unit) { detectTapGestures( }
.border(2.dp, BorderColor)
.background(color = innerColor.value, shape = RectangleShape)
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt
index 9ee0be2..3296bee 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -57,7 +57,7 @@
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
.offset(offsetX, offsetY)
- .preferredSize(size.value)
+ .size(size.value)
.pointerInput(Unit) {
detectTransformGestures { _, pan, zoom, _ ->
size.value *= zoom
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragSlopExceededGestureFilterDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragSlopExceededGestureFilterDemo.kt
index b0eebfe..2b9c4ed 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragSlopExceededGestureFilterDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragSlopExceededGestureFilterDemo.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -63,7 +63,7 @@
Box(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) {
forEachGesture {
awaitPointerEventScope {
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/HorizontalScrollersInVerticalScrollerDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/HorizontalScrollersInVerticalScrollerDemo.kt
index 0c6ac04..c48f1f1 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/HorizontalScrollersInVerticalScrollerDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/HorizontalScrollersInVerticalScrollerDemo.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
@@ -219,7 +219,7 @@
Box(
gestureDetectors
- .preferredSize(width, height)
+ .size(width, height)
.border(1.dp, Color.Black)
.background(color = color.value)
.then(pressOverlay)
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt
index 1dc9c79..91b686b 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -55,7 +55,7 @@
Modifier.offset(offsetX, offsetY)
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) {
detectDragGesturesAfterLongPress(
color.value = Blue },
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressGestureDetectorDemo.kt
index 5802094..9cec514 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressGestureDetectorDemo.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -51,7 +51,7 @@
Box(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) { detectTapGestures( }
.background(color.value)
.border(BorderStroke(2.dp, BorderColor))
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedScrollingDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedScrollingDemo.kt
index 7f62f75..f86dee8 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedScrollingDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedScrollingDemo.kt
@@ -26,7 +26,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.preferredHeight
+import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -58,7 +58,7 @@
)
ScrollableContainer {
RepeatingColumn(repetitions = 3) {
- Box(Modifier.preferredHeight(398.dp).padding(72.dp)) {
+ Box(Modifier.height(398.dp).padding(72.dp)) {
// Inner composable that scrolls
ScrollableContainer {
RepeatingColumn(repetitions = 5) {
@@ -174,7 +174,7 @@
)
}
- val layout = Modifier.fillMaxWidth().preferredHeight(height)
+ val layout = Modifier.fillMaxWidth().height(height)
val pressOverlay =
if (showPressed.value) Modifier.background(color = pressedColor) else Modifier
@@ -194,7 +194,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(1.dp)
+ .height(1.dp)
.background(Color(0f, 0f, 0f, .12f))
)
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt
index f4b26b2..0e7c5e7 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PointerInputDuringSubCompDemo.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
@@ -64,7 +64,7 @@
Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .size(200.dp)
+ .requiredSize(200.dp)
.background(color = Color.White)
) {
items(100) {
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PopupDragDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PopupDragDemo.kt
index 5fb45d4..c7cb00d 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PopupDragDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PopupDragDemo.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -57,7 +57,7 @@
change.consumeAllChanges()
}
}
- .preferredSize(70.dp)
+ .size(70.dp)
.background(Color.Green, CircleShape),
contentAlignment = Alignment.Center
) {
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PressIndicatorGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PressIndicatorGestureDetectorDemo.kt
index ade7ff9..625a332 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PressIndicatorGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/PressIndicatorGestureDetectorDemo.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -63,7 +63,7 @@
Box(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) {
detectTapGestures(
>
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt
index f29a274..4169113 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -56,7 +56,7 @@
.fillMaxSize()
.wrapContentSize(Alignment.Center)
.offset(offsetX, offsetY)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) {
forEachGesture {
awaitPointerEventScope {
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScaleGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScaleGestureDetectorDemo.kt
index 8ac8279..57ecb8b 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScaleGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScaleGestureDetectorDemo.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -46,7 +46,7 @@
Box(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(size.value)
+ .size(size.value)
.pointerInput(Unit) {
detectTransformGestures { _, _, zoom, _ -> size.value *= zoom }
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
index 063deda..888edcc 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
@@ -25,7 +25,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -92,7 +92,7 @@
scrollDistance
}
)
- .preferredSize(size)
+ .size(size)
.background(color)
) {
content()
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TapGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TapGestureDetectorDemo.kt
index 880346a..9906d7d 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TapGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TapGestureDetectorDemo.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -52,7 +52,7 @@
Box(
Modifier.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) { detectTapGestures( }
.clipToBounds()
.background(color.value)
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt
index b001793..0118823 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -73,7 +73,7 @@
Modifier.offset(offsetX, offsetY)
.fillMaxSize()
.wrapContentSize(Alignment.Center)
- .preferredSize(192.dp)
+ .size(192.dp)
.pointerInput(Unit) {
if (canStartVertically.value) {
detectVerticalDragGestures(
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt
index ccbc08b..e5303c7 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt
@@ -29,8 +29,8 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -104,7 +104,7 @@
Box(
Modifier
.fillMaxHeight()
- .width(drawerWidth)
+ .requiredWidth(drawerWidth)
.offset { IntOffset(currentOffset.value.roundToInt(), 0) }
.background(color = DefaultBackgroundColor)
) {
@@ -262,7 +262,7 @@
Box(
Modifier
.fillMaxWidth()
- .preferredHeight(height)
+ .height(height)
.border(1.dp, Color.Black)
.background(color = color.value)
.then(pressOverlay).then(gestureDetectors)
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AlphaSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AlphaSample.kt
index c36e0b6..0eda2b2 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AlphaSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AlphaSample.kt
@@ -19,7 +19,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
@@ -29,5 +29,5 @@
@Sampled
@Composable
fun AlphaSample() {
- Box(Modifier.preferredSize(100.dp).alpha(alpha = 0.5f).background(Color.Red))
+ Box(Modifier.size(100.dp).alpha(alpha = 0.5f).background(Color.Red))
}
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt
index abf88bd..dbc3086 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt
@@ -23,7 +23,7 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -57,7 +57,7 @@
fun AndroidDrawableInDrawScopeSample() {
val drawable = LocalContext.current.getDrawable(R.drawable.sample_drawable)
Box(
- modifier = Modifier.size(100.dp)
+ modifier = Modifier.requiredSize(100.dp)
.drawBehind {
drawIntoCanvas { canvas ->
drawable?.let {
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AnimatedVectorSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AnimatedVectorSample.kt
index f940815..ecacbd2 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AnimatedVectorSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AnimatedVectorSample.kt
@@ -20,7 +20,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -43,7 +43,7 @@
Image(
painter = image.painterFor(atEnd),
contentDescription = "Your content description",
- modifier = Modifier.preferredSize(64.dp).clickable {
+ modifier = Modifier.size(64.dp).clickable {
atEnd = !atEnd
}
)
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DialogSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DialogSample.kt
index 9f56310..b5508de 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DialogSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DialogSample.kt
@@ -19,7 +19,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -38,7 +38,7 @@
if (openDialog.value) {
Dialog( openDialog.value = false }) {
// Draw a rectangle shape with rounded corners inside the dialog
- Box(Modifier.preferredSize(dialogWidth, dialogHeight).background(Color.White))
+ Box(Modifier.size(dialogWidth, dialogHeight).background(Color.White))
}
}
}
\ No newline at end of file
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DrawModifierSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DrawModifierSample.kt
index cb5f8ad..b7e85ca 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DrawModifierSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/DrawModifierSample.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
@@ -112,7 +112,7 @@
Image(
painter = vectorPainter,
contentDescription = null,
- modifier = Modifier.size(120.dp).drawWithCache {
+ modifier = Modifier.requiredSize(120.dp).drawWithCache {
val gradient = Brush.linearGradient(
colors = listOf(Color.Red, Color.Blue),
start = Offset.Zero,
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/OnGloballyPositionedSamples.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/OnGloballyPositionedSamples.kt
index 44e88bd..e094e96 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/OnGloballyPositionedSamples.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/OnGloballyPositionedSamples.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -46,7 +46,7 @@
coordinates.parentLayoutCoordinates
}
) {
- Box(Modifier.preferredSize(20.dp).background(Color.Green))
- Box(Modifier.preferredSize(20.dp).background(Color.Blue))
+ Box(Modifier.size(20.dp).background(Color.Green))
+ Box(Modifier.size(20.dp).background(Color.Blue))
}
}
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PainterSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PainterSample.kt
index 48f7a8e..cbfcaea 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PainterSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PainterSample.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.paint
@@ -67,6 +67,6 @@
Image(
painterResource(R.drawable.ic_vector_or_png),
contentDescription = null,
- modifier = Modifier.size(50.dp)
+ modifier = Modifier.requiredSize(50.dp)
)
}
\ No newline at end of file
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PopupSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PopupSample.kt
index fbdd5e6..5939d56 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PopupSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/PopupSample.kt
@@ -19,7 +19,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.background
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -40,7 +40,7 @@
// Draw a rectangle shape with rounded corners inside the popup
Box(
Modifier
- .preferredSize(popupWidth, popupHeight)
+ .size(popupWidth, popupHeight)
.background(Color.White, RoundedCornerShape(cornerSize))
)
}
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RotateSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RotateSample.kt
index 0cea374..cf3d922 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RotateSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/RotateSample.kt
@@ -18,7 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
@@ -29,6 +29,6 @@
fun RotateSample() {
Box(
Modifier.rotate(45f)
- .preferredSize(100.dp, 100.dp)
+ .size(100.dp, 100.dp)
)
}
\ No newline at end of file
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ScaleSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ScaleSample.kt
index 1efa0cc..e7798dbf 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ScaleSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ScaleSample.kt
@@ -18,7 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
@@ -29,7 +29,7 @@
fun ScaleUniformSample() {
Box(
Modifier.scale(2f)
- .preferredSize(100.dp, 100.dp)
+ .size(100.dp, 100.dp)
)
}
@@ -38,6 +38,6 @@
fun ScaleNonUniformSample() {
Box(
Modifier.scale(scaleX = 2f, scaleY = 3f)
- .preferredSize(100.dp, 100.dp)
+ .size(100.dp, 100.dp)
)
}
\ No newline at end of file
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ShadowSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ShadowSample.kt
index d88d9f7..7ddc032 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ShadowSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/ShadowSample.kt
@@ -18,7 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
@@ -30,6 +30,6 @@
fun ShadowSample() {
Box(
Modifier.shadow(12.dp, RectangleShape)
- .preferredSize(100.dp, 100.dp)
+ .size(100.dp, 100.dp)
)
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt
index 775a03d..259cb0b 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.BasicTextField
@@ -438,7 +438,7 @@
).toFontFamily()
),
text = AnnotatedString(text),
- modifier = Modifier.width(width.toDp()),
+ modifier = Modifier.requiredWidth(width.toDp()),
textLayoutResult = it }
)
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
index b40229f..917412f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
@@ -32,7 +32,7 @@
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.BasicTextField
@@ -180,13 +180,13 @@
Modifier
.zIndex(1f)
.testTag(OverlappedChildOneTag)
- .size(50.dp)
+ .requiredSize(50.dp)
)
BasicText(
"Child Two",
Modifier
.testTag(OverlappedChildTwoTag)
- .size(50.dp)
+ .requiredSize(50.dp)
)
}
if (isTextFieldVisible) {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
index 8bead58..0ffec4e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
@@ -36,7 +36,7 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.runtime.CompositionLocalProvider
@@ -3048,7 +3048,7 @@
Box(
Modifier
.background(Color.Blue)
- .size(30.toDp())
+ .requiredSize(30.toDp())
.padding(10.toDp())
.background(Color.White)
.drawLatchModifier()
@@ -3092,7 +3092,7 @@
Box(
Modifier
.background(Color.Blue)
- .size(30.toDp())
+ .requiredSize(30.toDp())
.padding(10.toDp())
.drawBehind {
drawRect(innerColor)
@@ -3347,7 +3347,7 @@
FixedSize(30, Modifier.background(Color.Blue)) {
FixedSize(30, Modifier.graphicsLayer()) {
with(LocalDensity.current) {
- Canvas(Modifier.size(10.toDp())) {
+ Canvas(Modifier.requiredSize(10.toDp())) {
drawRect(color)
drawLatch.countDown()
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt
index 919897f..2c628c4 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt
@@ -18,7 +18,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -300,7 +300,7 @@
rule.setContent {
with(LocalDensity.current) {
Box(
- Modifier.size(25.toDp())
+ Modifier.requiredSize(25.toDp())
.graphicsLayer(
rotationZ = 30f,
clip = true
@@ -312,7 +312,7 @@
transformOrigin = TransformOrigin(0f, 1f),
clip = true
)
- .size(20.toDp(), 10.toDp())
+ .requiredSize(20.toDp(), 10.toDp())
.onGloballyPositioned {
coords1 = it
}
@@ -325,7 +325,7 @@
transformOrigin = TransformOrigin(0f, 1f),
clip = true
)
- .size(10.toDp())
+ .requiredSize(10.toDp())
.onGloballyPositioned {
coords2 = it
}
@@ -358,12 +358,12 @@
Box(modifier = Modifier.testTag(testTag).wrapContentSize()) {
Box(
modifier = Modifier
- .size(100.dp)
+ .requiredSize(100.dp)
.background(Color.Gray)
.graphicsLayer(rotationY = 25f, cameraDistance = 1.0f)
.background(Color.Red)
) {
- Box(modifier = Modifier.size(100.dp))
+ Box(modifier = Modifier.requiredSize(100.dp))
}
}
}
@@ -391,7 +391,7 @@
}
val tag = "testTag"
rule.setContent {
- Box(modifier = Modifier.testTag(tag).size(100.dp).background(Color.Blue)) {
+ Box(modifier = Modifier.testTag(tag).requiredSize(100.dp).background(Color.Blue)) {
Box(
modifier = Modifier
.matchParentSize()
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/InvalidatingNotPlacedChildTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/InvalidatingNotPlacedChildTest.kt
index 4640edb..a6e6d66 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/InvalidatingNotPlacedChildTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/InvalidatingNotPlacedChildTest.kt
@@ -19,7 +19,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
@@ -61,7 +61,7 @@
.testTag("node")
) {
Spacer(
- Modifier.size(5.dp)
+ Modifier.requiredSize(5.dp)
.graphicsLayer()
.background(Color.Red)
)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt
index ae8e1b7..841ca95 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt
@@ -19,10 +19,10 @@
import android.graphics.Bitmap
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.heightIn
-import androidx.compose.foundation.layout.width
-import androidx.compose.foundation.layout.widthIn
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.requiredHeightIn
+import androidx.compose.foundation.layout.requiredWidth
+import androidx.compose.foundation.layout.requiredWidthIn
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -397,8 +397,8 @@
// is satisfied. Because the Painter is twice as tall as the composable, the composable
// width should be half that of the painter
testPainterScaleMatchesSize(
- Modifier.height(((composableHeightPx) / density).dp)
- .widthIn(0.dp, (composableMaxWidthPx / density).dp),
+ Modifier.requiredHeight(((composableHeightPx) / density).dp)
+ .requiredWidthIn(0.dp, (composableMaxWidthPx / density).dp),
ContentScale.Inside,
Size(painterWidth, painterHeight),
painterWidth / 2,
@@ -420,8 +420,8 @@
// is satisfied. Because the Painter is twice as tall as the composable, the composable
// width should be half that of the painter
testPainterScaleMatchesSize(
- Modifier.width(((composableWidthPx) / density).dp)
- .heightIn(0.dp, (composableMaxHeightPx / density).dp),
+ Modifier.requiredWidth(((composableWidthPx) / density).dp)
+ .requiredHeightIn(0.dp, (composableMaxHeightPx / density).dp),
ContentScale.Inside,
Size(painterWidth, painterHeight),
composableWidthPx,
@@ -439,7 +439,8 @@
// Because the constraints are tight here, do not attempt to resize the composable
// based on the intrinsic dimensions of the Painter
testPainterScaleMatchesSize(
- Modifier.width((composableWidth / density).dp).height((composableHeight / density).dp),
+ Modifier.requiredWidth((composableWidth / density).dp)
+ .requiredHeight((composableHeight / density).dp),
ContentScale.Fit,
Size(painterWidth, painterHeight),
composableWidth,
@@ -457,7 +458,8 @@
// same scale factor. Because the intrinsic width is twice that of the width constraint,
// the height should be double that of the intrinsic height of the painter
testPainterScaleMatchesSize(
- Modifier.width((composableWidthPx / rule.density.density).dp).wrapContentHeight(),
+ Modifier.requiredWidth((composableWidthPx / rule.density.density).dp)
+ .wrapContentHeight(),
ContentScale.FillWidth,
Size(painterWidth, painterHeight),
composableWidthPx,
@@ -476,7 +478,8 @@
// should have the composable width match that of its input and the height match
// that of the painter
testPainterScaleMatchesSize(
- Modifier.width((composableWidthPx / rule.density.density).dp).wrapContentHeight(),
+ Modifier.requiredWidth((composableWidthPx / rule.density.density).dp)
+ .wrapContentHeight(),
ContentScale.Inside,
Size(painterWidth, painterHeight),
composableWidthPx,
@@ -540,8 +543,8 @@
modifier = Modifier
.testTag(testTag)
.background(color = Color.Gray)
- .width((boxWidth / LocalDensity.current.density).dp)
- .height((boxHeight / LocalDensity.current.density).dp)
+ .requiredWidth((boxWidth / LocalDensity.current.density).dp)
+ .requiredHeight((boxHeight / LocalDensity.current.density).dp)
.paint(BitmapPainter(srcImage), contentScale = ContentScale.FillHeight)
)
}
@@ -585,8 +588,8 @@
modifier = Modifier
.testTag(testTag)
.background(color = Color.Gray)
- .width((boxWidth / LocalDensity.current.density).dp)
- .height((boxHeight / LocalDensity.current.density).dp)
+ .requiredWidth((boxWidth / LocalDensity.current.density).dp)
+ .requiredHeight((boxHeight / LocalDensity.current.density).dp)
.paint(BitmapPainter(srcImage), contentScale = ContentScale.FillBounds)
)
}
@@ -612,8 +615,8 @@
val vectorHeightDp = (vectorHeight / LocalDensity.current.density).dp
Box(
modifier = Modifier.background(color = Color.Gray)
- .width((boxWidth / LocalDensity.current.density).dp)
- .height((boxHeight / LocalDensity.current.density).dp)
+ .requiredWidth((boxWidth / LocalDensity.current.density).dp)
+ .requiredHeight((boxHeight / LocalDensity.current.density).dp)
.paint(
rememberVectorPainter(
defaultWidth = vectorWidthDp,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusTestUtils.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusTestUtils.kt
index 31edde0..7f957fb 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusTestUtils.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusTestUtils.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.focus
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.junit4.ComposeContentTestRule
@@ -29,6 +29,6 @@
*/
internal fun ComposeContentTestRule.setFocusableContent(content: @Composable () -> Unit) {
setContent {
- Box(modifier = Modifier.size(10.dp, 10.dp)) { content() }
+ Box(modifier = Modifier.requiredSize(10.dp, 10.dp)) { content() }
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
index 3bb8f81..60dfe8c 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
@@ -21,9 +21,9 @@
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -149,7 +149,7 @@
// Make sure that if we are given the size of zero we should not crash and instead
// act as a no-op
rule.setContent {
- Box(modifier = Modifier.preferredSize(0.dp).paint(createTestVectorPainter()))
+ Box(modifier = Modifier.size(0.dp).paint(createTestVectorPainter()))
}
}
@@ -157,7 +157,7 @@
fun testVectorZeroWidthDoesNotCrash() {
rule.setContent {
Box(
- modifier = Modifier.preferredWidth(0.dp).preferredHeight(100.dp).paint
+ modifier = Modifier.width(0.dp).height(100.dp).paint
(createTestVectorPainter())
)
}
@@ -167,7 +167,7 @@
fun testVectorZeroHeightDoesNotCrash() {
rule.setContent {
Box(
- modifier = Modifier.preferredWidth(50.dp).preferredHeight(0.dp).paint(
+ modifier = Modifier.width(50.dp).height(0.dp).paint(
createTestVectorPainter()
)
)
@@ -236,7 +236,7 @@
contentDescription = null,
modifier = Modifier
.testTag(testTag)
- .preferredSize(icon1.defaultWidth, icon1.defaultHeight)
+ .size(icon1.defaultWidth, icon1.defaultHeight)
.background(Color.Red)
.clickable { clickState.value = !clickState.value },
alignment = Alignment.TopStart,
@@ -296,7 +296,7 @@
contentDescription = null,
modifier = Modifier
.testTag(testTag)
- .preferredSize(defaultWidth * 7, defaultHeight * 3)
+ .size(defaultWidth * 7, defaultHeight * 3)
.background(Color.Red),
contentScale = ContentScale.FillBounds
)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/ClickNotPlacedChildTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/ClickNotPlacedChildTest.kt
index 3fbc3d6..862a16a 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/ClickNotPlacedChildTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/ClickNotPlacedChildTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.testTag
@@ -62,7 +62,7 @@
}
)
},
- modifier = Modifier.size(100.dp).testTag("parent")
+ modifier = Modifier.requiredSize(100.dp).testTag("parent")
) { measutables, constraints ->
val first = measutables[0].measure(constraints)
measutables[1].measure(constraints)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollModifierTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollModifierTest.kt
index 4c36890..1048602 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollModifierTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollModifierTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
@@ -87,9 +87,9 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -135,10 +135,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -183,10 +183,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -224,10 +224,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -267,10 +267,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -326,9 +326,9 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -372,10 +372,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -420,10 +420,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -460,10 +460,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -506,10 +506,10 @@
}
val childDispatcher = NestedScrollDispatcher()
rule.setContent {
- Box(Modifier.size(100.dp).nestedScroll(grandParentConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(parentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(grandParentConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(parentConnection)) {
Box(
- Modifier.size(100.dp).nestedScroll(childConnection, childDispatcher)
+ Modifier.requiredSize(100.dp).nestedScroll(childConnection, childDispatcher)
)
}
}
@@ -561,7 +561,7 @@
rule.setContent {
Box(
Modifier
- .size(100.dp)
+ .requiredSize(100.dp)
.nestedScroll(parentConnection) // parent
.nestedScroll(childConnection, childDispatcher) // child
)
@@ -633,7 +633,7 @@
@Test
fun nestedScroll_hierarchyDispatch_rootParentRemoval() {
testRootParentAdditionRemoval { root, child ->
- Box(Modifier.size(100.dp).then(root)) {
+ Box(Modifier.requiredSize(100.dp).then(root)) {
Box(child)
}
}
@@ -650,7 +650,13 @@
fun nestedScroll_flatDispatch_longChain_rootParentRemoval() {
testRootParentAdditionRemoval { root, child ->
// insert a few random modifiers so it's more realistic example of wrapper re-usage
- Box(Modifier.size(100.dp).then(root).padding(5.dp).size(50.dp).then(child))
+ Box(
+ Modifier.requiredSize(100.dp)
+ .then(root)
+ .padding(5.dp)
+ .requiredSize(50.dp)
+ .then(child)
+ )
}
}
@@ -658,9 +664,9 @@
fun nestedScroll_hierarchyDispatch_middleParentRemoval() {
testMiddleParentAdditionRemoval { rootMod, middleMod, childMod ->
// random boxes to emulate nesting
- Box(Modifier.size(100.dp).then(rootMod)) {
+ Box(Modifier.requiredSize(100.dp).then(rootMod)) {
Box {
- Box(Modifier.size(100.dp).then(middleMod)) {
+ Box(Modifier.requiredSize(100.dp).then(middleMod)) {
Box {
Box(childMod)
}
@@ -688,9 +694,9 @@
// insert a few random modifiers so it's more realistic example of wrapper re-usage
Box(
Modifier
- .size(100.dp)
+ .requiredSize(100.dp)
.then(rootMod)
- .size(90.dp)
+ .requiredSize(90.dp)
.clipToBounds()
.then(middleMod)
.padding(5.dp)
@@ -780,7 +786,7 @@
}
Box(
Modifier
- .size(100.dp)
+ .requiredSize(100.dp)
.then(nestedScrollParents)
.nestedScroll(childConnection, childDispatcher)
)
@@ -890,8 +896,8 @@
rule.setContent {
val outerBoxConnection = if (isConnection1Parent.value) connection1 else connection2
val innerBoxConnection = if (isConnection1Parent.value) connection2 else connection1
- Box(Modifier.size(100.dp).nestedScroll(outerBoxConnection)) {
- Box(Modifier.size(100.dp).nestedScroll(innerBoxConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(outerBoxConnection)) {
+ Box(Modifier.requiredSize(100.dp).nestedScroll(innerBoxConnection)) {
Box(Modifier.nestedScroll(childConnection, childDispatcher))
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
index 971633c..4c38613 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -96,7 +96,7 @@
SimpleLayout(
modifier = Modifier.fillMaxSize().offset(offsetX, offsetY)
) {
- SimpleLayout(modifier = background.then(Modifier.preferredSize(containerDp))) {
+ SimpleLayout(modifier = background.then(Modifier.size(containerDp))) {
SimpleLayout(
modifier = Modifier
.graphicsLayer(
@@ -110,7 +110,7 @@
drawRect(color)
}
.then(latchDrawModifier)
- .preferredSize(boxDp)
+ .size(boxDp)
.pointerInput(Unit) {
detectTapGestures(
>
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt
index 00fcd3d..b038d4b 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt
@@ -23,7 +23,7 @@
import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalDensity
@@ -73,7 +73,7 @@
disallowInterceptRequester,
motionEventCallback
)
- .size(100f.toDp(), 100f.toDp())
+ .requiredSize(100f.toDp(), 100f.toDp())
)
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
index 14cadbf..e27a680 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
@@ -401,18 +401,18 @@
activity.setContent {
with(LocalDensity.current) {
DelayedMeasure(50) {
- Box(Modifier.size(25.toDp())) {
+ Box(Modifier.requiredSize(25.toDp())) {
Box(
- Modifier.size(size.toDp())
+ Modifier.requiredSize(size.toDp())
.onGloballyPositioned {
coordinates1 = it
positionedLatch.countDown()
}
)
}
- Box(Modifier.size(25.toDp())) {
+ Box(Modifier.requiredSize(25.toDp())) {
Box(
- Modifier.size(size.toDp())
+ Modifier.requiredSize(size.toDp())
.onGloballyPositioned {
coordinates2 = it
positionedLatch.countDown()
@@ -611,13 +611,13 @@
with(LocalDensity.current) {
Box {
Offset(left) {
- Box(Modifier.size(10.toDp())) {
- Box(Modifier.size(10.toDp())) {
+ Box(Modifier.requiredSize(10.toDp())) {
+ Box(Modifier.requiredSize(10.toDp())) {
Box(
Modifier.onGloballyPositioned {
realLeft = it.positionInRoot().x
positionedLatch.countDown()
- }.size(10.toDp())
+ }.requiredSize(10.toDp())
)
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt
index 834e6f4..623a11f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt
@@ -19,7 +19,7 @@
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -71,7 +71,7 @@
latch.countDown()
}
) {
- Box(Modifier.size(sizePx.toDp()))
+ Box(Modifier.requiredSize(sizePx.toDp()))
}
}
}
@@ -108,7 +108,7 @@
latch.countDown()
}.padding(sizePx.toDp())
) {
- Box(Modifier.size(10.toDp()))
+ Box(Modifier.requiredSize(10.toDp()))
}
}
}
@@ -143,7 +143,7 @@
latch.countDown()
}
) {
- Box(Modifier.size(10.toDp()))
+ Box(Modifier.requiredSize(10.toDp()))
}
}
}
@@ -176,7 +176,7 @@
latch.countDown()
}
) {
- Box(Modifier.size(sizePx.toDp()))
+ Box(Modifier.requiredSize(sizePx.toDp()))
}
}
}
@@ -219,7 +219,7 @@
latch1.countDown()
}.then(mod)
) {
- Box(Modifier.size(10.toDp()))
+ Box(Modifier.requiredSize(10.toDp()))
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
index 85655db..79d086c 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ExperimentalLayout
import androidx.compose.foundation.layout.IntrinsicSize
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
@@ -228,7 +228,7 @@
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
Layout(
content = {},
- modifier = Modifier.preferredWidth(IntrinsicSize.Max),
+ modifier = Modifier.width(IntrinsicSize.Max),
minIntrinsicWidthMeasureBlock = { _, _ -> 0 },
minIntrinsicHeightMeasureBlock = { _, _ -> 0 },
maxIntrinsicWidthMeasureBlock = { _, _ ->
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
index 9238ea7..595bcce 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
@@ -21,7 +21,7 @@
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.CompositionLocalProvider
@@ -77,14 +77,14 @@
rule.setContent {
SubcomposeLayout { constraints ->
val first = subcompose(0) {
- Spacer(Modifier.size(50.dp).testTag(firstTag))
+ Spacer(Modifier.requiredSize(50.dp).testTag(firstTag))
}.first().measure(constraints)
// it is an input for the second subcomposition
val halfFirstSize = (first.width / 2).toDp()
val second = subcompose(1) {
- Spacer(Modifier.size(halfFirstSize).testTag(secondTag))
+ Spacer(Modifier.requiredSize(halfFirstSize).testTag(secondTag))
}.first().measure(constraints)
layout(first.width, first.height) {
@@ -114,8 +114,8 @@
rule.setContent {
SubcomposeLayout(Modifier.testTag(layoutTag)) { constraints ->
val placeables = subcompose(Unit) {
- Spacer(Modifier.size(50.dp).testTag(firstTag))
- Spacer(Modifier.size(30.dp).testTag(secondTag))
+ Spacer(Modifier.requiredSize(50.dp).testTag(firstTag))
+ Spacer(Modifier.requiredSize(30.dp).testTag(secondTag))
}.map {
it.measure(constraints)
}
@@ -159,7 +159,7 @@
measuresCount++
val placeable = subcompose(Unit) {
recompositionsCount1++
- NonInlineBox(Modifier.size(20.dp)) {
+ NonInlineBox(Modifier.requiredSize(20.dp)) {
model.value // model read
recompositionsCount2++
}
@@ -224,7 +224,7 @@
SubcomposeLayout(Modifier.testTag(layoutTag)) { constraints ->
val placeables = subcompose(Unit) {
if (addChild.value) {
- Spacer(Modifier.size(20.dp).testTag(childTag))
+ Spacer(Modifier.requiredSize(20.dp).testTag(childTag))
}
}.map { it.measure(constraints) }
@@ -258,7 +258,7 @@
@Test
fun providingNewLambdaCausingRecomposition() {
val content = mutableStateOf<@Composable () -> Unit>({
- Spacer(Modifier.size(10.dp))
+ Spacer(Modifier.requiredSize(10.dp))
})
rule.setContent {
@@ -269,7 +269,7 @@
rule.runOnIdle {
content.value = {
- Spacer(Modifier.size(10.dp).testTag(updatedTag))
+ Spacer(Modifier.requiredSize(10.dp).testTag(updatedTag))
}
}
@@ -334,10 +334,10 @@
rule.setContent {
SubcomposeLayout(Modifier.testTag(layoutTag)) { constraints ->
val first = subcompose(Color.Red) {
- Spacer(Modifier.size(10.dp).background(Color.Red))
+ Spacer(Modifier.requiredSize(10.dp).background(Color.Red))
}.first().measure(constraints)
val second = subcompose(Color.Green) {
- Spacer(Modifier.size(10.dp).background(Color.Green))
+ Spacer(Modifier.requiredSize(10.dp).background(Color.Green))
}.first().measure(constraints)
layout(first.width, first.height) {
first.place(0, 0)
@@ -364,10 +364,10 @@
val firstColor = if (firstSlotIsRed.value) Color.Red else Color.Green
val secondColor = if (firstSlotIsRed.value) Color.Green else Color.Red
val first = subcompose(firstColor) {
- Spacer(Modifier.size(10.dp).background(firstColor))
+ Spacer(Modifier.requiredSize(10.dp).background(firstColor))
}.first().measure(constraints)
val second = subcompose(secondColor) {
- Spacer(Modifier.size(10.dp).background(secondColor))
+ Spacer(Modifier.requiredSize(10.dp).background(secondColor))
}.first().measure(constraints)
layout(first.width, first.height) {
first.place(0, 0)
@@ -397,10 +397,10 @@
rule.setContent {
SubcomposeLayout(Modifier.testTag(layoutTag)) { constraints ->
val first = subcompose(Color.Red) {
- Spacer(Modifier.size(10.dp).background(Color.Red).zIndex(1f))
+ Spacer(Modifier.requiredSize(10.dp).background(Color.Red).zIndex(1f))
}.first().measure(constraints)
val second = subcompose(Color.Green) {
- Spacer(Modifier.size(10.dp).background(Color.Green))
+ Spacer(Modifier.requiredSize(10.dp).background(Color.Green))
}.first().measure(constraints)
layout(first.width, first.height) {
first.place(0, 0)
@@ -463,7 +463,7 @@
val sizeIpx = with(density) { size.roundToPx() }
CompositionLocalProvider(LocalDensity provides density) {
SubcomposeLayout(
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertThat(it.size).isEqualTo(IntSize(sizeIpx, sizeIpx))
}
) { constraints ->
@@ -482,10 +482,10 @@
rule.setContent {
SubcomposeLayout(Modifier.testTag(layoutTag)) { constraints ->
val first = subcompose(Color.Red) {
- Spacer(Modifier.size(10.dp).background(Color.Red))
+ Spacer(Modifier.requiredSize(10.dp).background(Color.Red))
}.first().measure(constraints)
val second = subcompose(Color.Green) {
- Spacer(Modifier.size(10.dp).background(Color.Green))
+ Spacer(Modifier.requiredSize(10.dp).background(Color.Green))
}.first().measure(constraints)
layout(first.width, first.height) {
@@ -525,7 +525,7 @@
SubcomposeLayout { constraints ->
val first = subcompose(Unit) {
stateUsedLatch.countDown()
- Box(Modifier.size(state.value))
+ Box(Modifier.requiredSize(state.value))
}.first().measure(constraints)
layout(first.width, first.height) {
first.place(0, 0)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt
index 4c54bbe..fc3d3ce 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt
@@ -29,7 +29,7 @@
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.getValue
@@ -205,7 +205,7 @@
rule.setContent {
AndroidView(
{ LayoutInflater.from(it).inflate(R.layout.test_layout, null) },
- Modifier.size(size)
+ Modifier.requiredSize(size)
)
}
Espresso
@@ -227,7 +227,7 @@
frameLayout = FrameLayout(activity)
}
rule.setContent {
- AndroidView({ frameLayout }, Modifier.size(size))
+ AndroidView({ frameLayout }, Modifier.requiredSize(size))
}
Espresso
@@ -267,7 +267,7 @@
rule.setContent {
AndroidView(
{ LayoutInflater.from(it).inflate(R.layout.test_layout, null) },
- Modifier.size(size.value)
+ Modifier.requiredSize(size.value)
)
}
Espresso
@@ -337,7 +337,7 @@
CompositionLocalProvider(LocalDensity provides density) {
AndroidView(
{ FrameLayout(it) },
- Modifier.size(size).onGloballyPositioned {
+ Modifier.requiredSize(size).onGloballyPositioned {
assertThat(it.size).isEqualTo(IntSize(sizeIpx, sizeIpx))
}
)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt
index 6ea928c..bb15949 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt
@@ -17,7 +17,7 @@
import android.os.Build
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.GOLDEN_UI
@@ -56,7 +56,7 @@
Box(
Modifier
.graphicsLayer(shape = RoundedCornerShape(percent = 15), clip = true)
- .preferredSize(200.dp)
+ .size(200.dp)
.background(Color(0xFFA896B0))
)
}
@@ -79,7 +79,7 @@
shape = RoundedCornerShape(percent = 15),
clip = true
)
- .preferredSize(200.dp)
+ .size(200.dp)
.background(Color(0xFFA896B0))
)
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt
index 1ae8ef6..7b1a7b6 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt
@@ -19,7 +19,7 @@
import android.view.View
import android.view.WindowManager
import androidx.activity.ComponentActivity
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -115,7 +115,7 @@
},
properties = dialogProperties
) {
- SimpleContainer(Modifier.preferredSize(50.dp), content = {})
+ SimpleContainer(Modifier.size(50.dp), content = {})
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupDismissTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupDismissTest.kt
index de29dc7..2ceab8e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupDismissTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupDismissTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.ClickableText
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -88,7 +88,7 @@
properties = PopupProperties(focusable = focusable),
dismissCounter++; latch.countDown() }
) {
- Box(Modifier.preferredSize(100.dp, 100.dp)) {
+ Box(Modifier.size(100.dp, 100.dp)) {
BasicText(text = "Popup", style = TextStyle(textAlign = TextAlign.Center))
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt
index 99e597d..2889dc2 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt
@@ -18,7 +18,7 @@
import android.view.WindowManager
import androidx.activity.ComponentActivity
-import androidx.compose.foundation.layout.preferredSize
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -122,7 +122,7 @@
alignment = Alignment.Center,
properties = popupProperties
) {
- SimpleContainer(Modifier.preferredSize(50.dp), content = {})
+ SimpleContainer(Modifier.size(50.dp), content = {})
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
index 6c499de..72dc684 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
@@ -18,9 +18,9 @@
import android.view.View
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.requiredHeight
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.getValue
@@ -80,7 +80,7 @@
SimpleContainer {
PopupTestTag(testTag) {
Popup(alignment = Alignment.Center) {
- SimpleContainer(Modifier.preferredSize(50.dp), content = {})
+ SimpleContainer(Modifier.size(50.dp), content = {})
}
}
}
@@ -150,7 +150,7 @@
// This is called after the OnChildPosition method in Popup() which
// updates the popup to its final position
Box(
- modifier = Modifier.width(200.dp).height(200.dp)
+ modifier = Modifier.requiredWidth(200.dp).requiredHeight(200.dp)
.onGloballyPositioned {
measureLatch.countDown()
}
@@ -242,7 +242,7 @@
Box(Modifier.fillMaxSize()) {
if (showPopup) {
Popup(alignment = Alignment.Center, showPopup = false }) {
- Box(Modifier.preferredSize(50.dp).testTag(testTag))
+ Box(Modifier.size(50.dp).testTag(testTag))
}
}
}
@@ -276,7 +276,7 @@
alignment = Alignment.Center,
showPopup = false }
) {
- Box(Modifier.preferredSize(50.dp).testTag(testTag))
+ Box(Modifier.size(50.dp).testTag(testTag))
}
}
}
@@ -302,7 +302,7 @@
properties = PopupProperties(dismissOnClickOutside = false),
showPopup = false }
) {
- Box(Modifier.preferredSize(50.dp).testTag(testTag))
+ Box(Modifier.size(50.dp).testTag(testTag))
}
}
}
@@ -337,7 +337,7 @@
alignment = Alignment.Center,
showPopup = false }
) {
- Box(Modifier.preferredSize(50.dp).testTag(testTag))
+ Box(Modifier.size(50.dp).testTag(testTag))
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt
index a201006..3f678ca 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt
@@ -17,7 +17,7 @@
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.requiredSize
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -66,7 +66,7 @@
}
rule.setContent {
with(LocalDensity.current) {
- Box(Modifier.size(size.toDp()).onGloballyPositioned { coordinates = it })
+ Box(Modifier.requiredSize(size.toDp()).onGloballyPositioned { coordinates = it })
}
}
diff --git a/paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt b/paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
index dc85a99..53dcc09 100644
--- a/paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
+++ b/paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
@@ -17,8 +17,8 @@
package androidx.paging.compose
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.foundation.layout.preferredWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.ui.Modifier
@@ -65,9 +65,9 @@
fun lazyPagingColumnShowsItems() {
rule.setContent {
val lazyPagingItems = createPager().flow.collectAsLazyPagingItems()
- LazyColumn(Modifier.preferredHeight(200.dp)) {
+ LazyColumn(Modifier.height(200.dp)) {
items(lazyPagingItems) {
- Spacer(Modifier.preferredHeight(101.dp).fillParentMaxWidth().testTag("$it"))
+ Spacer(Modifier.height(101.dp).fillParentMaxWidth().testTag("$it"))
}
}
}
@@ -91,10 +91,10 @@
fun lazyPagingColumnShowsIndexedItems() {
rule.setContent {
val lazyPagingItems = createPager().flow.collectAsLazyPagingItems()
- LazyColumn(Modifier.preferredHeight(200.dp)) {
+ LazyColumn(Modifier.height(200.dp)) {
itemsIndexed(lazyPagingItems) { index, item ->
Spacer(
- Modifier.preferredHeight(101.dp).fillParentMaxWidth()
+ Modifier.height(101.dp).fillParentMaxWidth()
.testTag("$index-$item")
)
}
@@ -120,9 +120,9 @@
fun lazyPagingRowShowsItems() {
rule.setContent {
val lazyPagingItems = createPager().flow.collectAsLazyPagingItems()
- LazyRow(Modifier.preferredWidth(200.dp)) {
+ LazyRow(Modifier.width(200.dp)) {
items(lazyPagingItems) {
- Spacer(Modifier.preferredWidth(101.dp).fillParentMaxHeight().testTag("$it"))
+ Spacer(Modifier.width(101.dp).fillParentMaxHeight().testTag("$it"))
}
}
}
@@ -146,10 +146,10 @@
fun lazyPagingRowShowsIndexedItems() {
rule.setContent {
val lazyPagingItems = createPager().flow.collectAsLazyPagingItems()
- LazyRow(Modifier.preferredWidth(200.dp)) {
+ LazyRow(Modifier.width(200.dp)) {
itemsIndexed(lazyPagingItems) { index, item ->
Spacer(
- Modifier.preferredWidth(101.dp).fillParentMaxHeight()
+ Modifier.width(101.dp).fillParentMaxHeight()
.testTag("$index-$item")
)
}