Halil Ozercan
09/19/2020, 12:25 PMrefreshingState: Boolean,
is an argument to the SwipeToRefresh composable. It makes total sense that refreshing status is controlled by the parent. However, inner swipe state and this received state of refresh are combined together to call onRefresh
callback inside the listener for swipe state change as follows:
val state = rememberSwipeableState(refreshingState) { newValue ->
// compare both copies of the swipe state before calling onRefresh(). This is a workaround.
if (newValue && !refreshingState) onRefresh()
true
}
However, something goes wrong in this lambda. Even if the refreshingState
is changed from true
to false
by the parent, this lambda will keep reading it as the first time remember
is called. If refreshingState
was true at the start, it will remain true in the scope of this lambda until composition of SwipeRefreshLayout
leaves the UI. As a workaround, I've changed refreshingState
to a lambda that returns a boolean.Adam Powell
09/19/2020, 11:40 PMHalil Ozercan
09/20/2020, 2:24 PMArkadii Ivanov
02/26/2021, 11:28 PMHalil Ozercan
02/27/2021, 10:50 AMrememberUpdatedState
which might be helpful.