Slide 19
Slide 19 text
fun LazyListScope.gridItems(
columns: Int,
items: List,
gridItem: @Composable (T) -> Unit
) {
val rows = (items.size + columns - 1) / columns
items(rows) { rowIndex ->
Row {
for (columnIndex in 0 until nColumns) {
val itemIndex = rowIndex * columns + columnIndex
if (itemIndex < items.size) {
Box(
modifier = Modifier.weight(1f, fill = true),
propagateMinConstraints = true
) {
gridItem.invoke(items[itemIndex])
}
} else {
Spacer(Modifier.weight(1f, fill = true))
}
}
}
}
}