i'm currently trying to create a table composable....
# compose
j
i'm currently trying to create a table composable. i got it working using a
LazyColumn
but i'm now trying to add in a "sticky column" but if i "share" the
LazyListState
it seems I can't get them both to scroll vertically. only the "sticky" one does
Copy code
Box {
        Box(modifier = modifier.then(Modifier.horizontalScroll(horizontalScrollState))) {
            LazyColumn(state = verticalLazyListState) {
                ...
            }
        }

        if (hasLazyColumn) {
            LazyColumn(state = verticalLazyListState) {
                ...
            }
        }
    }
Ended up doing a snapshot flow and just syncing the states
Copy code
LaunchedEffect(verticalLazyListState) {
                snapshotFlow { verticalLazyListState.firstVisibleItemScrollOffset }
                    .collect {
                        stickyLazyListState.scrollToItem(verticalLazyListState.firstVisibleItemIndex, verticalLazyListState.firstVisibleItemScrollOffset)
                    }
            }
but it gets really off sometimes when trying to sync the two states together so would love a better solution
o
Could you try
LazyTable
? https://github.com/oleksandrbalan/lazytable It has
pinConfiguration
lambda to specify how many columns / rows should be "pinned" (act like sticky) I am not sure if it fits your needs, but I will be very happy for any feedback
j
will definitely take a look. i'm using this in a kmp project so might need to fork this
o
Keep in mind that in depends on https://github.com/oleksandrbalan/minabox So you have to fork it also
j
https://github.com/oleksandrbalan/minabox/pull/4 - let me know how that looks. code was super awesome to migrate so great job with that. might not do lazytable as i realized after doing the conversion that this might not work perfectly for me as i need dynamic cell sizing but might play around with it
o
Omg, thx for the PR! I will definetely check it during the weekend 🤗
j
https://github.com/oleksandrbalan/lazytable/pull/5 and here is lazytable (obviously dependent on minabox getting updated but i tested locally and it works)