@Composable
fun BoxContainer() {
Box(
modifier = Modifier
.background(Color.White)
.fillMaxSize(),
contentAlignment = Alignment.Center,
// propagateMinConstraints = true
) {
DummyBox2(modifier = Modifier.size(200.dp), color = Color.Green)
DummyBox2(modifier = Modifier.size(150.dp), color = Color.Yellow)
DummyBox2(color = Color.Blue)
}
}
@Composable
fun BoxWithConstraintContainer() {
BoxWithConstraints(
modifier = Modifier
.background(Color.White)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
if (this.minHeight > 400.dp) {
DummyBox2(modifier = Modifier.size(200.dp), color = Color.Green)
}
else {
DummyBox2(modifier = Modifier.size(200.dp), color = Color.Yellow)
}
Text(text = "minHeight: ${this.minHeight}")
}
}
@Composable
fun BoxWithConstraintContainer() {
Box(
modifier = Modifier
.background(Color.White)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Column() {
BoxWithConstraintItem(modifier = Modifier
.size(200.dp)
.background(Color.Yellow)
)
BoxWithConstraintItem(modifier = Modifier
.size(300.dp)
.background(Color.Green)
)
}
}
}
@Composable
fun BoxWithConstraintItem(modifier: Modifier = Modifier) {
BoxWithConstraints(
modifier = modifier,
contentAlignment = Alignment.Center
) {
if (this.minWidth > 200.dp) {
Text(text = "이것은 큰 상자이다")
}
else {
Text(text = "이것은 작은 상자이다")
}
}
}