Thread
#compose
    a

    alorma

    1 year ago
    Is there a "tab" or GridLayout for compose?
    a

    allan.conda

    1 year ago
    there’s TabBar, but no GridLayout. Compose-samples uses
    FlowRow
    for each row in the grid in a
    LazyColumnFor
    a

    alorma

    1 year ago
    uhm, experimental...
    i will wait then
    Spikey Sanju

    Spikey Sanju

    1 year ago
    @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 🙂 @alorma
    a

    allan.conda

    1 year ago
    I use
    list.chunked(numColumns).forEach { /* render each item in row */ }
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    uhm, experimental...
    Compose itself is effectively experimental at the moment