orangy

    orangy

    1 year ago
    Is there any tutorial/manual/samples/docs on lazy components, like how
    LazyVerticalGrid
    works internally. I want to implement
    LazyTileMap
    (a big table of cells into which one looks through a small viewport, I need it for a game-like experience) which would only compose tiles that are visible and will allow scrolling and (optionally) zooming. But I’m currently lost in all these layout stuff, subcomposition, measurements, etc. What is the best guide into this? I’ve read Custom layouts section, but it seems it’s a tiny fraction of the underlying machinery.
    jim

    jim

    1 year ago
    Na, I think that's mostly it. There are a few external blogs that have explored the topic of custom layouts (eg. https://jorgecastillo.dev/jetpack-compose-withconstraints) but I think the code is authoritative here. Just start by looking at the source code of simpler layouts and work your way up to the more complex ones, and if you have specific layout questions where you're banging your head against the wall then ask in the #compose channel.
    orangy

    orangy

    1 year ago
    Huh, the example on the docs page is no longer valid:
    @Composable
    fun MyOwnColumn(
        modifier: Modifier = Modifier,
        content: @Composable() () -> Unit
    ) {
        Layout(
            modifier = modifier,
            children = content
        ) { measurables, constraints ->
            // measure and position children given constraints logic here
        }
    }
    The signature of
    Layout
    function is very different now
    Ah, got it. Confused by different overload. Still docs needs fixing because apparently
    children
    parameter was renamed to
    content