louis993546 / Metro-Compose

(WIP) Build Metro (WP8) app on Android using Compose
MIT License
6 stars 4 forks source link

`Lazy` + `VerticalTilesGrid` #7

Open louis993546 opened 3 years ago

louis993546 commented 3 years ago

It would be nice if I can make this into a separate library or something, and make it more efficient

@Composable
fun LazyVerticalTilesGrid(
    modifier: Modifier = Modifier,
    columns: Int,
    gap: Dp,
    content: @Composable LazyVerticalTilesGridScope.() -> Unit
) {
    // TODO Probably need to use SubcomposeLayout or something similar
}

enum class TileSize {
    S, M, L
}

interface LazyVerticalTilesGridScope {
    fun <T> item(item: T, size: TileSize, key: String, content: @Composable () -> Unit)

    fun <T> items(
        items: Iterable<T>,
        size: (T) -> TileSize,
        key: (T) -> String,
        content: @Composable (T) -> Unit
    )
}
louis993546 commented 2 weeks ago

https://www.ackee.agency/blog/custom-lazylayout-with-jetpack-compose