Hi, it's my first time writing a custom lazy list ...
# compose
a
Hi, it's my first time writing a custom lazy list with
LazyLayout
. My question is: Is there a way to access a
DrawScope
behind the composable to draw some shapes based on the items? More in đź§µ
The composable currently lays the items out like this
And I want to draw lines behind them somewhat like this
e
Modifier.drawBehind { ... }
a
I'm calculating the size of the items and the spaces between them inside the `LazyLayout`'s
MeasurePolicy
. I'm not sure how I can access or delegate it to be used inside
Modifier.drawBehind { ... }
. Any suggestions?
Also the list is scrollable. Will this cause any performance problems?
e
It wont cause performance problems and as with anything in compose you can hoist the state to a parent level that your draw behind can access for example, you just need to get the visible items on screen, chunk them 2 each and for each pair, get their location on screen and draw your lines
(Sounds a lot like “draw the rest of the owl” but not sure how else to explain it)
Also as long as you make sure not to introduce inter dependency between the phases ie make sure you use information from the measure phase to update state thats read in the draw phase and not copmposition phase, then it should be good.
a
Thanks, it's working just like you said ❤️