Package 

Class SwipeRefreshKt

    • Method Summary

      Modifier and Type Method Description
      final static SwipeRefreshState rememberSwipeRefreshState(Boolean isRefreshing) Creates a SwipeRefreshState that is remembered across compositions.
      final static Unit SwipeRefresh(SwipeRefreshState state, Function0<Unit> onRefresh, Modifier modifier, Boolean swipeEnabled, Dp refreshTriggerDistance, Alignment indicatorAlignment, PaddingValues indicatorPadding, Function2<SwipeRefreshState, Dp, Unit> indicator, Boolean clipIndicatorToPadding, Function0<Unit> content) A layout which implements the swipe-to-refresh pattern, allowing the user to refresh content via a vertical swipe gesture.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • SwipeRefresh

         final static Unit SwipeRefresh(SwipeRefreshState state, Function0<Unit> onRefresh, Modifier modifier, Boolean swipeEnabled, Dp refreshTriggerDistance, Alignment indicatorAlignment, PaddingValues indicatorPadding, Function2<SwipeRefreshState, Dp, Unit> indicator, Boolean clipIndicatorToPadding, Function0<Unit> content)

        A layout which implements the swipe-to-refresh pattern, allowing the user to refresh content via a vertical swipe gesture.

        This layout requires its content to be scrollable so that it receives vertical swipe events. The scrollable content does not need to be a direct descendant though. Layouts such as androidx.compose.foundation.lazy.LazyColumn are automatically scrollable, but others such as androidx.compose.foundation.layout.Column require you to provide the androidx.compose.foundation.verticalScroll modifier to that content.

        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 the progress animation outside of a swipe gesture, 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.

        Parameters:
        state - the state object to be used to control or observe the SwipeRefresh state.
        onRefresh - Lambda which is invoked when a swipe to refresh gesture is completed.
        modifier - the modifier to apply to this layout.
        swipeEnabled - Whether the the layout should react to swipe gestures or not.
        refreshTriggerDistance - The minimum swipe distance which would trigger a refresh.
        indicatorAlignment - The alignment of the indicator.
        indicatorPadding - Content padding for the indicator, to inset the indicator in if required.
        indicator - the indicator that represents the current state.
        clipIndicatorToPadding - Whether to clip the indicator to indicatorPadding.
        content - The content containing a scroll composable.