GIGAMOLE / ComposeScrollbars

ComposeScrollbars: Polish your Android Compose UI with advanced scrollbars
https://www.linkedin.com/in/gigamole/
MIT License
126 stars 4 forks source link

How to use with `LazyList`? #2

Closed christophehenry closed 8 months ago

christophehenry commented 8 months ago

The documentation just states "Just place it on top of your scrollable content.". But if I use it like this:

@Composable
private fun FeedList() {
    val listState = rememberLazyListState()

    Row {
        Scrollbars(…)
        LazyColumn(state = listState, modifier = Modifier.weight(1f).fillMaxSize()) { … }
    }
}

The LazyColumn is not displayed: it has a width of 0. If I remove the Row, then the scrollbar isn't displayed.

GIGAMOLE commented 8 months ago

Hi.

Just place it above (Z-order) of your scrollable content so its visible. (Changed in Readme). And from what I see, you haven't checked the sample app :)

As you can see, you are using Row, which is not correct, The Scrollbars takes all place (fillMaxSize by default) so the LazyColumn is pushed out and has 0 size.

Do something like this, example:

Box(modifier = Modifier.fillMaxSize()) {
    LazyColumn(
        modifier = Modifier.fillMaxSize(),
        state = lazyListState
    ) {
        // Populate items here.
    }
    Scrollbars(state = scrollbarsState)
  }
christophehenry commented 8 months ago

I couldn't find any LazyColumn in the sample app but maybe I just missed it. Anyway, thanks for the help!