Object

OneHandedGestureDefaults

Contains the default values used by one-handed gestures

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
public object OneHandedGestureDefaults

Contains the default values used by one-handed gestures

Functions

scrollDown

public suspend fun scrollDown(scrollState: TransformingLazyColumnState)

A scroll implementation tailored for use with TransformingLazyColumnState.

This logic handles one-handed gesture by first attempting to scroll to the next item in the list (or scrolling through the current item if it exceeds the viewport size). If the list cannot scroll further forward, it scrolls back to the start.

Sample demonstrating gesture handling with TransformingLazyColumnState:

Parameters

scrollState The scroll state associated with a transforming lazy column.

scrollToNextPage

public suspend fun scrollToNextPage(pagerState: PagerState)

Automatically animates the pagerState to the next available page.

This function triggers a smooth scroll transition to the next page index. If the current page is the last page in the pager, the animation will wrap around to the first page (index 0).

Samples demonstrating gesture handling with horizontal and vertical pagers:

Parameters

pagerState The state of the pager to be animated.

GestureIndicator

@Composable
public fun GestureIndicator(
    gestureIndicatorVisible: Boolean,
    onGestureIndicatorFinished: () -> Unit,
    modifier: Modifier = Modifier,
    content: @Composable () -> Unit,
)

A wrapper that replaces the content to indicate to the user that a gesture action is available.

This component handles the visual transition between the standard content and a gesture indicator. When gestureIndicatorVisible is enabled, the content is swapped out for the indicator. Once the indicator display sequence is complete, onGestureIndicatorFinished is called, allowing the UI to return to its original state.

Sample demonstrating a gesture indicator applied to a androidx.wear.compose.material3.Button:

Parameters

gestureIndicatorVisible A boolean flag that triggers the transition from content to the indicator. While true, the content is hidden and the indicator is played.
onGestureIndicatorFinished A lambda function to be called when the gesture indicator animation sequence finishes. Implementation of this lambda must reset gestureIndicatorVisible to false in order to restore the original content.
modifier The Modifier to be applied to the indicator animation container.
content The original button content (e.g., Text or Icon) to be displayed when no indicator is active.

ScrollGestureIndicator

@Composable
public fun ScrollGestureIndicator(
    gestureIndicatorVisible: Boolean,
    onGestureIndicatorFinished: () -> Unit,
    state: TransformingLazyColumnState,
    modifier: Modifier = Modifier,
    colors: ScrollIndicatorColors = ScrollIndicatorDefaults.colors(),
    reverseDirection: Boolean = false,
    positionAnimationSpec: AnimationSpec<Float> = ScrollIndicatorDefaults.PositionAnimationSpec,
)

A scroll indicator that transitions to indicate that a scroll gesture is available to the user.

Under normal conditions, this component behaves like a standard scroll indicator, reflecting the current scroll position of a androidx.wear.compose.foundation.lazy.TransformingLazyColumn. When gestureIndicatorVisible is set to true, the indicator temporarily replaces its standard visual state with a gesture animation sequence.

Sample demonstrating a gesture indicator applied to a androidx.wear.compose.foundation.lazy.TransformingLazyColumn:

Parameters

gestureIndicatorVisible A boolean flag that triggers the gesture indicator animation. While true, the standard scroll indicator is transformed into the gesture indicator.
onGestureIndicatorFinished A lambda function to be called when the gesture indicator animation sequence finishes. Implementation of this lambda must reset gestureIndicatorVisible to false in order to restore the original content.
state The state object of the androidx.wear.compose.foundation.lazy.TransformingLazyColumn this indicator is coupled with.
modifier The Modifier to be applied to the scroll indicator.
colors ScrollIndicatorColors that will be used to resolve the indicator and track colors for this androidx.wear.compose.material3.ScrollIndicator.
reverseDirection Reverses direction of ScrollIndicator if true.
positionAnimationSpec AnimationSpec for position animation. The Position animation is used for animating changes to the scroll size and position. To disable this animation androidx.compose.animation.core.snap AnimationSpec should be passed instead.

HorizontalPageGestureIndicator

@Composable
public fun HorizontalPageGestureIndicator(
    gestureIndicatorVisible: Boolean,
    onGestureIndicatorFinished: () -> Unit,
    pagerState: PagerState,
    modifier: Modifier = Modifier,
    selectedColor: Color = PageIndicatorDefaults.selectedColor,
    unselectedColor: Color = PageIndicatorDefaults.unselectedColor,
    backgroundColor: Color = PageIndicatorDefaults.backgroundColor,
)

A horizontal page indicator that can temporarily display a gesture indicator to demonstrate how to navigate between pages using one-handed gestures.

In its idle state, this component functions as a standard page indicator, using dots or bars to represent the pagerState. When gestureIndicatorVisible is set to true, the indicator temporarily replaces its standard visual state with a gesture animation sequence.

Sample demonstrating a gesture indicator applied to a androidx.wear.compose.foundation.pager.HorizontalPager:

Parameters

gestureIndicatorVisible A boolean flag that triggers the gesture indicator animation. While true, the standard scroll indicator is transformed into the gesture indicator.
onGestureIndicatorFinished A lambda function to be called when the gesture indicator animation sequence finishes. Implementation of this lambda must reset gestureIndicatorVisible to false in order to restore the original content.
pagerState The state of the androidx.wear.compose.foundation.pager.HorizontalPager that this indicator represents.
modifier Modifier to be applied to the HorizontalPageIndicator
selectedColor The color which will be used for a selected indicator item.
unselectedColor The color which will be used for an unselected indicator item.
backgroundColor The color which will be used for an indicator background.

VerticalPageGestureIndicator

@Composable
public fun VerticalPageGestureIndicator(
    gestureIndicatorVisible: Boolean,
    onGestureIndicatorFinished: () -> Unit,
    pagerState: PagerState,
    modifier: Modifier = Modifier,
    selectedColor: Color = PageIndicatorDefaults.selectedColor,
    unselectedColor: Color = PageIndicatorDefaults.unselectedColor,
    backgroundColor: Color = PageIndicatorDefaults.backgroundColor,
)

A vertical page indicator that can temporarily display a gesture indicator to demonstrate how to navigate between pages using one-handed gestures.

In its idle state, this component functions as a standard page indicator, using dots or bars to represent the pagerState. When gestureIndicatorVisible is set to true, the indicator temporarily replaces its standard visual state with a gesture animation sequence.

Sample demonstrating a gesture indicator applied to a androidx.wear.compose.foundation.pager.VerticalPager:

Parameters

gestureIndicatorVisible A boolean flag that triggers the gesture indicator animation. While true, the standard scroll indicator is transformed into the gesture indicator.
onGestureIndicatorFinished A lambda function to be called when the gesture indicator animation sequence finishes. Implementation of this lambda must reset gestureIndicatorVisible to false in order to restore the original content.
pagerState The state of the androidx.wear.compose.foundation.pager.VerticalPager that this indicator represents.
modifier Modifier to be applied to the VerticalPageIndicator
selectedColor The color which will be used for a selected indicator item.
unselectedColor The color which will be used for an unselected indicator item.
backgroundColor The color which will be used for an indicator background.