Curious how someone might implement something like...
# compose
a
Curious how someone might implement something like this with a LazyColumn, where there’s a custom scaffold for toolbar, banner image, and content, and the content where the background decoration scrolls with the list 🤔
d
That doesn't look like a job for
LazyColumn
I think. The number of items seems pretty small.
a
I understand that we don’t know the true height aot with LazyColumn
It can vary heavily
Depends on how many devices the user decides to put on the screen
d
Does the entire screen scroll or just the sections?
a
Entire screen
And not within the background either, the background scrolls with the list
d
It can vary heavily
Sure but how large can it get?
You could still just use
LazyColumn
I suppose. What's getting in the way of just using it?
a
It depends on the property and integrations. Sometimes it’s only one device, sometimes properties have tons of devices and staff add tons they want to use from the dashboard screen. We also have integration shortcuts
The background decoration
I could, hypothetically draw it as the background for each item, but that leaves a gap at the bottom
d
Oh, why not just do the background outside the LazyColumn?
a
It would stay fixed, and since we don’t know the height ahead of time with the lazy column, we can’t just set it and translate it with scroll either
d
Oh I think I'm understanding now. So you have a stack of three things. • The background photo • The top app bar • The body which has the devices, appliances, etc. And you want 1 and 3 to scroll together?
a
1 scrolls as parallax, that I can use nested scroll for 3 scrolls normal, but the background decoration scrolls with it
d
What exactly is this background decoration? I though you were referring to the image but now I'm not so sure. Is it the "ACCESS . 4 DEVICES" bit?
a
You could use nestedScroll modifier or the scroll state (although LazyList state makes it slightly more complicated than vertical ScrollState). Here’s a sample that uses NestedScrollConnection to move the toolbar on scroll. Instead of moving the background 1:1 with it, you could move it as much or as little as you want. https://github.com/androidx/androidx/blob/8cb282ccdbb00687dbf253a4419ded0dfc786fb5[…]rc/main/java/androidx/compose/ui/samples/NestedScrollSamples.kt
a
The toolbar stays fixed, the list background doesnt. The background needs to be the size of the list at most, and at minimum fill the area. We can’t use nestedscroll for this since we don’t know ahead of time the height of the LazyColumn.
The decoration is the background itself, where the top portion has rounded corners and a border, then goes to the bottom
d
Explaining UI via text is difficult but I think I understand now.
a
I guess what could technically be done is drawing the background the size of the parent + the size of the top corner radius, and translate with nested scroll
d
You read my mind there.
a
🙌🏻
Works better now 🙂
d
Nice