Nicolai
02/14/2023, 9:58 PMvar items by remember {
mutableStateOf(emptyList<WithdrawalListItem>())
}
viewModel.items.observe.... it-> items = it
CompleteDialogContent(
listItems = items
)
@Composable
fun CompleteDialogContent(
listItems: List<WithdrawalListItem>,
) {
Card(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(),
shape = RoundedCornerShape(32.dp)
) {
Column( modifier = Modifier
.padding(top = 32.dp, start = 24.dp, end = 24.dp, bottom = 12.dp)
.wrapContentWidth()
.wrapContentHeight(),) {
listItems.forEach { WithdrawalItem(item = it) }
}
}
}
vide
02/14/2023, 10:35 PMwrapContentHeight
?Nicolai
02/14/2023, 10:41 PMvide
02/14/2023, 10:43 PMNicolai
02/14/2023, 10:46 PMvide
02/14/2023, 10:49 PM@Preview
@Composable
fun Demo() {
Box(
Modifier
.size(50.dp)
.background(Color.Cyan)
//.wrapContentHeight(Alignment.CenterVertically)
.size(30.dp) // The size wish is ignored here.
.background(Color.Magenta)
)
}
wrapContentHeight
is useful:
@Preview
@Composable
fun Demo() {
Box(
Modifier
.size(50.dp)
.background(Color.Cyan)
.wrapContentHeight(Alignment.CenterVertically) // Allows the next modifier to ignore the 50dp constraint
.size(30.dp)
.background(Color.Magenta)
)
}
Nicolai
02/14/2023, 11:09 PMvide
02/14/2023, 11:11 PMNicolai
02/14/2023, 11:12 PMvide
02/14/2023, 11:14 PMNicolai
02/14/2023, 11:17 PMvide
02/14/2023, 11:20 PM@Composable
fun Demo() {
val boxes = remember { mutableStateOf(0) }
LaunchedEffect(Unit) {
while (true) {
delay(1000)
boxes.value += 1
}
}
Column(
Modifier.width(40.dp).background(Color.Cyan),
verticalArrangement = Arrangement.spacedBy(5.dp)
) {
(0..boxes.value).forEach { Box(Modifier.size(20.dp).background(Color.Magenta)) }
}
}
It will just endlessly add elements to the column and the parent size will change