Swipe Refresh
A layout which implements the swipe-to-refresh pattern.
The layout can be used whenever the user has the ability to refresh content via a vertical swipe gesture.
Apps should provide a onRefresh block to be notified each time a swipe to refresh gesture is completed. That block is responsible for updating the state as appropriately, typically by setting SwipeRefreshState.isRefreshing to true once a 'refresh' has been started. Once a refresh has completed, the app should then set SwipeRefreshState.isRefreshing to false.
If an app wishes to show just the progress animation, outside of a swipe refresh, it can set SwipeRefreshState.isRefreshing as required.
This layout does not clip any of it's contents, including the indicator. If clipping is required, apps can provide the androidx.compose.ui.draw.clipToBounds modifier.
Samples
Parameters
the state object to be used to control or observe the SwipeRefresh state.
Lambda which is invoked when a swipe to refresh gesture is completed.
the modifier to apply to this layout.
Whether the the layout should react to swipe gestures or not.
The minimum swipe distance which would trigger a refresh.
The alignment of the indicator. Defaults to Alignment.TopCenter.
Content padding for the indicator, to inset the indicator in if required.
the indicator that represents the current state. By default this will use a SwipeRefreshIndicator.
The content containing a scroll composable.