Thread
#compose
    tjohnn

    tjohnn

    2 years ago
    A simple gridview implementation with compose, anyone?
    Timo Drick

    Timo Drick

    2 years ago
    Here very basic but easy to adjust for your needs:
    @Composable
    fun <T>ViewTableList(columns: Int = 2, item: List<T>, itemCallback: @Composable() (T) -> Unit) {
        key(item, columns) {
            LazyColumnItems(items = item.chunked(columns)) { rowList ->
                Row {
                    rowList.forEach {
                        itemCallback(it)
                    }
                    val emptyRows = (columns - rowList.size)
                    repeat(emptyRows) {
                        Spacer(modifier = Modifier.weight(1f))
                    }
                }
            }
        }
    }
    tjohnn

    tjohnn

    2 years ago
    Thanks.