alorma
10/23/2020, 9:16 AMallan.conda
10/23/2020, 9:37 AMFlowRow
for each row in the grid in a LazyColumnFor
alorma
10/23/2020, 9:39 AMSpikey Sanju
10/23/2020, 11:29 AM@Composable
fun <T> GridView(
cols: Int = 1,
list: List<T>,
rowModifier: Modifier = Modifier,
colModifier: Modifier = Modifier,
child: @Composable (dataModal: T) -> Unit
) {
val rows = (list.size / cols) + (if (list.size % cols > 0) 1 else 0)
ScrollableColumn {
for (r in 0 until rows) {
Row(modifier = rowModifier, horizontalArrangement = Arrangement.SpaceAround) {
for (cell in 0 until cols) {
val i = (r * cols) + cell
if (i < list.size) {
child(list[i])
} else {
break
}
}
}
}
}
}
I'm currently using this approach 🙂 @alormaallan.conda
10/23/2020, 11:31 AMlist.chunked(numColumns).forEach { /* render each item in row */ }
Zach Klippenstein (he/him) [MOD]
10/23/2020, 3:32 PMuhm, experimental...Compose itself is effectively experimental at the moment