https://kotlinlang.org logo
#compose
Title
# compose
s

sen kumar

03/04/2021, 1:59 AM
Will Nested LazyColumns be possible any time?
c

Colton Idle

03/04/2021, 2:27 AM
I'm also curious about this. Currently my team uses epoxy and we're used to creating a recycler view for every set of similar data. Then we put all of it in a scroll view. I'm curious if the general gist in Compose is that only the root (or something close to representing the page) should be lazy and basically no other composable should be lazy. Basically, I think I could create every page with a topBar then a lazyCol and make sure no other composable is lazy or Col with scrollable modifier. @Andrey Kulikov did help me in the past and I think his answer was along the lines of "a lazyCol (or Col with scrollable) has an infinite height and you can have two items with infinite height. If it worked in the view system there were probably bugs in the Recycling where it probably didn't work correctly even though it seemed like it did. Compose is strict so it doesn't let you do that to give you a false sense of it working correctly" Don't take that for granted though. I could be misremembering or misrepresenting @Andrey Kulikov
a

Albert Chang

03/04/2021, 3:05 AM
Now we have
Modifier.fillParentMaxSize
in
LazyItemScope
which sets the minimum and maximum size to the parent size. I think it will be nice to have another modifier to only set the maximum size without changing the minimum size so that scrollable elements without a fixed size can be used inside LazyLists. I wonder if I'm missing something.
s

sen kumar

03/04/2021, 3:12 AM
Our parent LazyColumn items can collapse and expand - so a max or min size is not going to of much user - The child is within parent and on expand shows up
a

Albert Chang

03/04/2021, 3:32 AM
@sen kumar If you take a look at here you’ll see that the reason you can’t use nested LazyLists (without fixed sizes) is that items in a LazyList are measured without a maximum size and if we can give them a maximum size they will work.
If you know the size of the child LazyList you can set a fixed size on it (
Modifier.height()
in your case) and it will also work.
a

Andrey Kulikov

03/04/2021, 1:53 PM
@Albert Chang you can do Modifier.fillParentMaxHeight().wrapContentHeight(). this should do what you asked: min constraint is 0, max constraint is a LazyColumn size
👍 1
s

sen kumar

03/04/2021, 5:56 PM
@Andrey Kulikov - Is fillParentMaxHeight() not there in the beta verison of compose?
Oh I see it’s in LazyItemScope
a

Albert Chang

03/05/2021, 1:39 AM
@Andrey Kulikov
wrapContentHeight()
sets the minimum height to 0 but it just align the content in the actual minimum height space which is not desirable. What I want is probably a
ParentDataModifier
by which LazyList can measure the content using zero minimum size and parent maximum size.
That being said, nested scroll in Compose UI is still not quite usable because of this so even if you implement nested LazyColumns now that can be a big problem.
3 Views