https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
d

Djuro

03/16/2024, 1:57 PM
Hi everyone, hope you are all doing well. I am trying to figure out how to make
PullToRefreshContainer
work with swipe in compose multiplatform. I can't get it to start refreshing when there is swipe down (that was behaviour I would expect for it, like in Android) Code is in the thread
Copy code
fun App(rootComponent: RootComponent) {
    LunchBreakTheme {
        val state = rememberPullToRefreshState()
        Box (modifier= Modifier.fillMaxSize().background(color= Color.Green).nestedScroll(state.nestedScrollConnection)){
            PullToRefreshContainer(state = state)
        }
}
It just doesn't work, its state is not automatically changing on swipe
Btw it work if lazy column is inside the Box, otherwise it doesn't
Okay solved by adding
verticalScroll
to the
Box
component but honestly I really don't like this
👍 1
Is there a way to do this without having the box scrollable
a

avdim88

03/18/2024, 7:13 PM
Can you please post working code with
verticalScroll
?
d

Djuro

03/18/2024, 7:16 PM
Copy code
fun App(rootComponent: RootComponent) {
    LunchBreakTheme {
        val state = rememberPullToRefreshState()
        Box (modifier= Modifier.fillMaxSize().background(color= Color.Green).verticalScroll(state=rememberScrollState()).nestedScroll(state.nestedScrollConnection)){
            PullToRefreshContainer(state = state)
        }
}
Just add it your `Box`'s
Modifier
a

avdim88

03/18/2024, 7:19 PM
Looks like your solution is good!
d

Djuro

03/19/2024, 8:32 AM
It sure does work :D, but I don't think that we should be adding vertical scroll to these components just in order to have
PullToRefreshIndicator
in
material3
, I would be happier with having something like
Material.pullRefresh()
like it was the case with
material
5 Views