Hello! Is the behavior observed here expected, or ...
# compose
g
Hello! Is the behavior observed here expected, or could it be a bug? Specifically, when using a
Scaffold
with a
TopAppBar
and a
PullToRefreshBox
, and passing
innerPadding
to a
LazyVerticalStaggeredGrid
(or any other layout that only composes and lays out visible items on screen), we need to do this:
Copy code
Scaffold(
    topBar = {...}
) { innerPadding ->
    PullToRefreshBox(
        ...,
        indicator = {
            Indicator(
                modifier = Modifier
                    .align(Alignment.TopCenter)
                    .padding(top = innerPadding.calculateTopPadding()),
                isRefreshing = isRefreshing,
                state = pullState
            )
        }
    ) {
        LazyVerticalStaggeredGrid(contentPadding = innerPadding, ...) {...}
    }
}
To ensure both work correctly. If the
calculateTopPadding
is ignored, the pull-to-refresh functionality doesn’t work properly. Is this the intended solution or is there a better way to achieve this?
c
So the grid view is not a child of the refresh box?
g
it’s a child yes (code updated)
c
Pass the inner padding to the refresh box and not the grid.
g
bot how, cannot be through padding, I want the list to be behind the top bar, thus the contentPadding
using calculateTopPadding as Indicator padding
using calculateTopPadding as PullToRefreshBox padding
padding.png
c
Then you have to do it the way you did.
g
Ok, just wanted to check if I was on the right track 🙂, thanks!