How can we create a grid list recyclerview adapter...
# compose
s
How can we create a grid list recyclerview adapter? I couldn't find any properties on top of modifiers. As of now AdapterList supports a linear vertical scrolling.
a
Don’t think it’s supported yet. Right now I create an AdapterList of Rows
v
There used to be a
Table
api but it was deprecated. An alternative version should be available soon!
👍 1
t
maybe this small wrapper is helpfull:
Copy code
@Composable
fun <T>ViewTableList(columns: Int = 2, item: List<T>, itemCallback: @Composable() (T) -> Unit) {
    key(item, columns) {
        AdapterList(data = item.chunked(columns)) { rowList ->
            Row {
                rowList.forEach {
                    itemCallback(it)
                }
                val emptyRows = (columns - rowList.size)
                repeat(emptyRows) {
                    Spacer(modifier = Modifier.weight(1f))
                }
            }
        }
    }
}