Nicolai
12/14/2023, 9:30 AMNicolai
12/14/2023, 9:31 AM@Composable
private fun RowScope.ScrollableContent(state: TableUiState, modifier: Modifier) {
val scrollState: ScrollState = rememberScrollState()
var width by remember { mutableStateOf(0.dp) }
Row(
modifier = modifier
.background(colors.commonBackground)
.horizontalScroll(scrollState)
.weight(1f)
) {
state.items.forEachIndexed { index, tableColumn ->
val columnModifier = when (width) {
0.dp -> Modifier
else -> Modifier.width(width)
}
Column(modifier = columnModifier.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
if (placeable.width.dp > width) {
width = placeable.width.dp
}
// Return the placeable after setting the width
layout(placeable.width, placeable.height) {
placeable.place(0, 0)
}
}) {
tableColumn.items.forEach { tableItem ->
TableItemRow(tableItem = tableItem)
}
}
}
}
}
Peter
12/14/2023, 8:25 PMweight(1f)
for every child in your row?