I am facing a challenge where I want the user to c...
# multiplatform
y
I am facing a challenge where I want the user to choose the size of a Composable Grid, I have made a simple grid using columns and rows, but it has several issues the grid needs to work in both portrait and landscape mode the grid needs to be non-scrollable (lazy) and it should allow for reordering animation. my current code only works on Portrait that is because the columns get placed first then the rows in portrait I have to place the rows first then the columns I still don't know how to add animation for reordering (this is quite easy for a lazy list), also if I open the app on the phone (the app is only intended for tablets) its a mess so it needs to be dynamic. my possible solution so far is to use a lazyVerticalGrid and disable scrolling its not the best any better ideas?
Copy code
@Composable
fun Grid(
    rows: Int,
    columns: Int,
    items: List<AacItem>,
    addAndPlay: (AacItem) -> Unit,
) {
    Column {
        repeat(columns) { rowIndex ->
            Row {
                repeat(rows) { columnIndex ->
                    val index = rowIndex * columns + columnIndex
                    if (index < items.size) {
                        Box(
                            contentAlignment = Alignment.Center,
                            modifier = Modifier
                                .weight(1f)
                                .aspectRatio(1f)
                        ) {
                            AacItem(items[index]) {
                                addAndPlay(it)
                            }
                        }
                    }
                    else {
                        Spacer(modifier = Modifier.weight(1f))
                    }
                }
            }
        }
    }
}
y
y
thank you this is exactly what i needed