Hi everyone :wave: I am trying to build a custom l...
# compose
g
Hi everyone 👋 I am trying to build a custom layout in Compose that sort of resembles a spread sheet. Meaning it can have an unknown number of rows and columns. The layout should have the basic grid and permanent/sticky headers on both the left and top (these are sticky but scroll with the content). I want to make it lazy but I can’t find any Layout that would do this out of the box. More in the comments 🙌
I am trying to use
SubcomposeLayout
for it as it allows me to measure how many rows and columns fit into the current view port and then
subcompose
them. At the moment I am just trying to scroll vertically, so I am measuring how many rows fit into the received constraints and what is the first row I am seeing when scrolling. These two values then allow me to determine the items I need to show on screen, which for me is a
IntRange
(wrapped in a
State
) with Int being indexes that I need to render. My issue is the scroll freezes for a moment when a new row is composed. I understand that when this
IntRange
changes (as soon as I scroll up or down and a new row needs to be shown) I trigger the measure phase again (where I am calling
subcompose
), so I suspect I am doing something there that is overloading what was supposed to be lazy on my end. Any dos or don’ts regarding using
SubcomposeLayout
? Any obvious mistakes I should avoid? I also considered using
LazyLayout
but for my case I found it weird to represent this data as a List, considering the views should be generated as I scroll (possibly for a very long time), the data for them solely relies on scroll position.
k
g
Hey @Kirill Grouchnikov 👋 Thank you for the tip! It surely seems to fit the spreadsheet use case and I can possibly make it work, even with
MinaBox
, also by the same author! But before adopting it I would really like to understand what I am doing wrong in my approach, so I can evaluate if it is worth it to add and learn this new library 😅