> Documentation index: https://developer.android.com/reference/llms.txt

# OneHandedGestureDefaults

Artifact: [androidx.wear.compose:compose-material3](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/wear/compose/material3/onehandedgesture/OneHandedGestureDefaults.kt+class:androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.7.0)


```
object OneHandedGestureDefaults
```

<br />

*** ** * ** ***

## Summary

| ### Constants |
|---|---|
| `const Float` | `ScrollFraction = 0.5f` The default fraction of the viewport height that `scrollDown` scrolls by on each gesture. |
| `const Long` | `ShowIndicatorDelayMillis = 1000` The default delay, in milliseconds, before the gesture indicator is shown, i.e. before the `onGestureAvailable` callback is invoked. |

| ### Public functions |
|---|---|
| `suspend Unit` | `scrollDown(scrollState: ScalingLazyListState, wrapAround: Boolean)` A scroll implementation tailored for use with `ScalingLazyListState`. |
| `suspend Unit` | `scrollDown(scrollState: TransformingLazyColumnState, wrapAround: Boolean)` A scroll implementation tailored for use with `TransformingLazyColumnState`. |
| `suspend Unit` | `scrollDown( scrollState: ScalingLazyListState, scrollFraction: @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) Float, wrapAround: Boolean )` A scroll implementation tailored for use with `ScalingLazyListState`. |
| `suspend Unit` | `scrollDown( scrollState: TransformingLazyColumnState, scrollFraction: @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) Float, wrapAround: Boolean )` A scroll implementation tailored for use with `TransformingLazyColumnState`. |
| `suspend Unit` | `scrollDownToNextItem( scrollState: ScalingLazyListState, wrapAround: Boolean )` A scroll implementation tailored for use with `ScalingLazyListState`. |
| `suspend Unit` | `scrollDownToNextItem( scrollState: TransformingLazyColumnState, wrapAround: Boolean )` A scroll implementation tailored for use with `TransformingLazyColumnState`. |
| `suspend Unit` | `scrollToNextPage(pagerState: PagerState, wrapAround: Boolean)` Automatically animates the `pagerState` to the next available page. |

| ### Public properties |
|---|---|
| `OneHandedGestureIndicatorSize` | `indicatorSize` The default size constraints for the gesture indicator icon. |
| `Color` | `indicatorTint` The tint color used for the gesture animation. |
| `Color` | `pageIndicatorBackgroundColor` The background color used behind the pager gesture animations. |
| `Color` | `pageIndicatorTint` The tint color used for the pager gesture animation icons. |
| `Color` | `scrollIndicatorBackgroundColor` The background color used behind the scroll gesture animations. |
| `Color` | `scrollIndicatorTint` The tint color used for the scroll gesture animation icons. |

## Constants

### ScrollFraction

Added in [1.8.0-alpha04](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.8.0-alpha04)

```
const val ScrollFraction = 0.5f: Float
```

The default fraction of the viewport height that `scrollDown` scrolls by on each gesture.

### ShowIndicatorDelayMillis

Added in [1.8.0-alpha04](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.8.0-alpha04)

```
const val ShowIndicatorDelayMillis = 1000: Long
```

The default delay, in milliseconds, before the gesture indicator is shown, i.e. before the `onGestureAvailable` callback is invoked.

## Public functions

### scrollDown

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.7.0)

```
suspend fun scrollDown(scrollState: ScalingLazyListState, wrapAround: Boolean = true): Unit
```

A scroll implementation tailored for use with `ScalingLazyListState`.

This logic handles one-handed gesture by first attempting to scroll the list by `ScrollFraction` of the viewport height, i.e. half of it. Use the overload with the `scrollFraction` parameter to customize this. If the list cannot scroll further forward and `wrapAround` is enabled, it scrolls back to the start.

Sample demonstrating gesture handling with `ScalingLazyListState`:

```kotlin
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberOverscrollEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.EdgeButton
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicatorState
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePriority
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val backDispatcherOwner = LocalOnBackPressedDispatcherOwner.current
val onClick =
    remember<() -> Unit> { { backDispatcherOwner?.onBackPressedDispatcher?.onBackPressed() } }
val scrollState = rememberScalingLazyListState()
val coroutineScope = rememberCoroutineScope()

val buttonInteractionSource = remember { MutableInteractionSource() }
val buttonGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Clickable,
    )
val buttonIndicatorState = remember { OneHandedGestureClickIndicatorState() }

val scrollGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Scrollable,
    )
val scrollIndicatorState =
    remember(scrollGestureConfig) { OneHandedGestureScrollIndicatorState() }

ScreenScaffold(
    scrollState = scrollState,
    edgeButton = {
        EdgeButton(
            onClick = onClick,
            interactionSource = buttonInteractionSource,
            modifier =
                if (scrollState.canScrollForward) {
                    Modifier
                } else {
                    // Apply the one-handed gesture modifier only when the container cannot
                    // scroll further, ensuring the EdgeButton is fully visible and interactive
                    Modifier.oneHandedGesture(
                        gestureConfiguration = buttonGestureConfig,
                        interactionSource = buttonInteractionSource,
                        onGestureLabel = "close",
                        onGestureAvailable = {
                            coroutineScope.launch { buttonIndicatorState.showIndicator() }
                        },
                        onGesture = onClick,
                    )
                } then
                    Modifier.scrollable(
                        state = scrollState,
                        orientation = Orientation.Vertical,
                        reverseDirection = true,
                        overscrollEffect = rememberOverscrollEffect(),
                    ),
        ) {
            OneHandedGestureClickIndicator(buttonGestureConfig, buttonIndicatorState) {
                Text("Close")
            }
        }
    },
    scrollIndicator = {
        OneHandedGestureScrollIndicator(
            gestureConfiguration = scrollGestureConfig,
            indicatorState = scrollIndicatorState,
            scrollState = scrollState,
            modifier = Modifier.align(Alignment.CenterEnd),
        )
    },
) { contentPadding ->
    ScalingLazyColumn(
        state = scrollState,
        contentPadding = contentPadding,
        modifier =
            Modifier.fillMaxSize()
                .oneHandedGesture(
                    gestureConfiguration = scrollGestureConfig,
                    onGestureLabel = "scroll",
                    onGestureAvailable = {
                        coroutineScope.launch { scrollIndicatorState.showIndicator() }
                    },
                    onGesture = { OneHandedGestureDefaults.scrollDown(scrollState) },
                ),
        autoCentering = null,
    ) {
        items(10) { Text("Item $it") }
    }
}
```

| Parameters |
|---|---|
| `scrollState: ScalingLazyListState` | The scroll state associated with a scaling lazy column. |
| `wrapAround: Boolean = true` | Whether to automatically scroll back to the first item when reaching the end of the content. |

### scrollDown

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.7.0)

```
suspend fun scrollDown(
    scrollState: TransformingLazyColumnState,
    wrapAround: Boolean = true
): Unit
```

A scroll implementation tailored for use with `TransformingLazyColumnState`.

This logic handles one-handed gesture by first attempting to scroll the list by `ScrollFraction` of the viewport height, i.e. half of it. Use the overload with the `scrollFraction` parameter to customize this. If the list cannot scroll further forward and `wrapAround` is enabled, it scrolls back to the start.

Sample demonstrating gesture handling with `TransformingLazyColumnState`:

```kotlin
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberOverscrollEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.EdgeButton
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicatorState
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePriority
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val backDispatcherOwner = LocalOnBackPressedDispatcherOwner.current
val onClick =
    remember<() -> Unit> { { backDispatcherOwner?.onBackPressedDispatcher?.onBackPressed() } }
val scrollState = rememberTransformingLazyColumnState()
val coroutineScope = rememberCoroutineScope()

val buttonInteractionSource = remember { MutableInteractionSource() }
val buttonGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Clickable,
    )
val buttonIndicatorState = remember { OneHandedGestureClickIndicatorState() }

val scrollGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Scrollable,
    )
val scrollIndicatorState =
    remember(scrollGestureConfig) { OneHandedGestureScrollIndicatorState() }

ScreenScaffold(
    scrollState = scrollState,
    edgeButton = {
        EdgeButton(
            onClick = onClick,
            interactionSource = buttonInteractionSource,
            modifier =
                if (scrollState.canScrollForward) {
                    Modifier
                } else {
                    // Apply the one-handed gesture modifier only when the container cannot
                    // scroll further, ensuring the EdgeButton is fully visible and interactive
                    Modifier.oneHandedGesture(
                        gestureConfiguration = buttonGestureConfig,
                        interactionSource = buttonInteractionSource,
                        onGestureLabel = "close",
                        onGestureAvailable = {
                            coroutineScope.launch { buttonIndicatorState.showIndicator() }
                        },
                        onGesture = onClick,
                    )
                } then
                    Modifier.scrollable(
                        state = scrollState,
                        orientation = Orientation.Vertical,
                        reverseDirection = true,
                        overscrollEffect = rememberOverscrollEffect(),
                    ),
        ) {
            OneHandedGestureClickIndicator(buttonGestureConfig, buttonIndicatorState) {
                Text("Close")
            }
        }
    },
    scrollIndicator = {
        OneHandedGestureScrollIndicator(
            gestureConfiguration = scrollGestureConfig,
            indicatorState = scrollIndicatorState,
            scrollState = scrollState,
            modifier = Modifier.align(Alignment.CenterEnd),
        )
    },
) { contentPadding ->
    TransformingLazyColumn(
        state = scrollState,
        contentPadding = contentPadding,
        modifier =
            Modifier.fillMaxSize()
                .oneHandedGesture(
                    gestureConfiguration = scrollGestureConfig,
                    onGestureLabel = "scroll",
                    onGestureAvailable = {
                        coroutineScope.launch { scrollIndicatorState.showIndicator() }
                    },
                    onGesture = { OneHandedGestureDefaults.scrollDown(scrollState) },
                ),
    ) {
        items(10) { Text("Item $it") }
    }
}
```

| Parameters |
|---|---|
| `scrollState: TransformingLazyColumnState` | The scroll state associated with a transforming lazy column. |
| `wrapAround: Boolean = true` | Whether to automatically scroll back to the first item when reaching the end of the content. |

### scrollDown

Added in [1.8.0-alpha04](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.8.0-alpha04)

```
suspend fun scrollDown(
    scrollState: ScalingLazyListState,
    scrollFraction: @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) Float,
    wrapAround: Boolean = true
): Unit
```

A scroll implementation tailored for use with `ScalingLazyListState`.

This logic handles one-handed gesture by first attempting to scroll the list by `scrollFraction` of the viewport height. If the list cannot scroll further forward and `wrapAround` is enabled, it scrolls back to the start.

Sample demonstrating gesture handling with `ScalingLazyListState`:

```kotlin
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberOverscrollEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.EdgeButton
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicatorState
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePriority
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val backDispatcherOwner = LocalOnBackPressedDispatcherOwner.current
val onClick =
    remember<() -> Unit> { { backDispatcherOwner?.onBackPressedDispatcher?.onBackPressed() } }
val scrollState = rememberScalingLazyListState()
val coroutineScope = rememberCoroutineScope()

val buttonInteractionSource = remember { MutableInteractionSource() }
val buttonGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Clickable,
    )
val buttonIndicatorState = remember { OneHandedGestureClickIndicatorState() }

val scrollGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Scrollable,
    )
val scrollIndicatorState =
    remember(scrollGestureConfig) { OneHandedGestureScrollIndicatorState() }

ScreenScaffold(
    scrollState = scrollState,
    edgeButton = {
        EdgeButton(
            onClick = onClick,
            interactionSource = buttonInteractionSource,
            modifier =
                if (scrollState.canScrollForward) {
                    Modifier
                } else {
                    // Apply the one-handed gesture modifier only when the container cannot
                    // scroll further, ensuring the EdgeButton is fully visible and interactive
                    Modifier.oneHandedGesture(
                        gestureConfiguration = buttonGestureConfig,
                        interactionSource = buttonInteractionSource,
                        onGestureLabel = "close",
                        onGestureAvailable = {
                            coroutineScope.launch { buttonIndicatorState.showIndicator() }
                        },
                        onGesture = onClick,
                    )
                } then
                    Modifier.scrollable(
                        state = scrollState,
                        orientation = Orientation.Vertical,
                        reverseDirection = true,
                        overscrollEffect = rememberOverscrollEffect(),
                    ),
        ) {
            OneHandedGestureClickIndicator(buttonGestureConfig, buttonIndicatorState) {
                Text("Close")
            }
        }
    },
    scrollIndicator = {
        OneHandedGestureScrollIndicator(
            gestureConfiguration = scrollGestureConfig,
            indicatorState = scrollIndicatorState,
            scrollState = scrollState,
            modifier = Modifier.align(Alignment.CenterEnd),
        )
    },
) { contentPadding ->
    ScalingLazyColumn(
        state = scrollState,
        contentPadding = contentPadding,
        modifier =
            Modifier.fillMaxSize()
                .oneHandedGesture(
                    gestureConfiguration = scrollGestureConfig,
                    onGestureLabel = "scroll",
                    onGestureAvailable = {
                        coroutineScope.launch { scrollIndicatorState.showIndicator() }
                    },
                    onGesture = { OneHandedGestureDefaults.scrollDown(scrollState) },
                ),
        autoCentering = null,
    ) {
        items(10) { Text("Item $it") }
    }
}
```

| Parameters |
|---|---|
| `scrollState: ScalingLazyListState` | The scroll state associated with a scaling lazy column. |
| `scrollFraction: @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) Float` | The fraction of the viewport height to scroll by on each gesture. Must be greater than 0 and at most 1. |
| `wrapAround: Boolean = true` | Whether to automatically scroll back to the first item when reaching the end of the content. |

### scrollDown

Added in [1.8.0-alpha04](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.8.0-alpha04)

```
suspend fun scrollDown(
    scrollState: TransformingLazyColumnState,
    scrollFraction: @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) Float,
    wrapAround: Boolean = true
): Unit
```

A scroll implementation tailored for use with `TransformingLazyColumnState`.

This logic handles one-handed gesture by first attempting to scroll the list by `scrollFraction` of the viewport height. If the list cannot scroll further forward and `wrapAround` is enabled, it scrolls back to the start.

Sample demonstrating gesture handling with `TransformingLazyColumnState` and a custom `scrollFraction`:

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePriority
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val scrollState = rememberTransformingLazyColumnState()
val coroutineScope = rememberCoroutineScope()

val scrollGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Scrollable,
    )
val scrollIndicatorState =
    remember(scrollGestureConfig) { OneHandedGestureScrollIndicatorState() }

ScreenScaffold(
    scrollState = scrollState,
    scrollIndicator = {
        OneHandedGestureScrollIndicator(
            gestureConfiguration = scrollGestureConfig,
            indicatorState = scrollIndicatorState,
            scrollState = scrollState,
            modifier = Modifier.align(Alignment.CenterEnd),
        )
    },
) { contentPadding ->
    TransformingLazyColumn(
        state = scrollState,
        contentPadding = contentPadding,
        modifier =
            Modifier.fillMaxSize()
                .oneHandedGesture(
                    gestureConfiguration = scrollGestureConfig,
                    onGestureLabel = "scroll",
                    onGestureAvailable = {
                        coroutineScope.launch { scrollIndicatorState.showIndicator() }
                    },
                    onGesture = {
                        // Scroll by 80% of the viewport height on each gesture.
                        OneHandedGestureDefaults.scrollDown(scrollState, scrollFraction = 0.8f)
                    },
                ),
    ) {
        items(20) { Text("Item $it") }
    }
}
```

| Parameters |
|---|---|
| `scrollState: TransformingLazyColumnState` | The scroll state associated with a transforming lazy column. |
| `scrollFraction: @FloatRange(from = 0.0, to = 1.0, fromInclusive = false) Float` | The fraction of the viewport height to scroll by on each gesture. Must be greater than 0 and at most 1. |
| `wrapAround: Boolean = true` | Whether to automatically scroll back to the first item when reaching the end of the content. |

### scrollDownToNextItem

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.7.0)

```
suspend fun scrollDownToNextItem(
    scrollState: ScalingLazyListState,
    wrapAround: Boolean = true
): Unit
```

A scroll implementation tailored for use with `ScalingLazyListState`.

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 `ScalingLazyListState`:

```kotlin
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberOverscrollEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.EdgeButton
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicatorState
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePriority
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val backDispatcherOwner = LocalOnBackPressedDispatcherOwner.current
val onClick =
    remember<() -> Unit> { { backDispatcherOwner?.onBackPressedDispatcher?.onBackPressed() } }
val scrollState = rememberScalingLazyListState()
val coroutineScope = rememberCoroutineScope()

val buttonInteractionSource = remember { MutableInteractionSource() }
val buttonGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Clickable,
    )
val buttonIndicatorState = remember { OneHandedGestureClickIndicatorState() }

val scrollGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Scrollable,
    )
val scrollIndicatorState =
    remember(scrollGestureConfig) { OneHandedGestureScrollIndicatorState() }

ScreenScaffold(
    scrollState = scrollState,
    edgeButton = {
        EdgeButton(
            onClick = onClick,
            interactionSource = buttonInteractionSource,
            modifier =
                if (scrollState.canScrollForward) {
                    Modifier
                } else {
                    // Apply the one-handed gesture modifier only when the container cannot
                    // scroll further, ensuring the EdgeButton is fully visible and interactive
                    Modifier.oneHandedGesture(
                        gestureConfiguration = buttonGestureConfig,
                        interactionSource = buttonInteractionSource,
                        onGestureLabel = "close",
                        onGestureAvailable = {
                            coroutineScope.launch { buttonIndicatorState.showIndicator() }
                        },
                        onGesture = onClick,
                    )
                } then
                    Modifier.scrollable(
                        state = scrollState,
                        orientation = Orientation.Vertical,
                        reverseDirection = true,
                        overscrollEffect = rememberOverscrollEffect(),
                    ),
        ) {
            OneHandedGestureClickIndicator(buttonGestureConfig, buttonIndicatorState) {
                Text("Close")
            }
        }
    },
    scrollIndicator = {
        OneHandedGestureScrollIndicator(
            gestureConfiguration = scrollGestureConfig,
            indicatorState = scrollIndicatorState,
            scrollState = scrollState,
            modifier = Modifier.align(Alignment.CenterEnd),
        )
    },
) { contentPadding ->
    ScalingLazyColumn(
        state = scrollState,
        contentPadding = contentPadding,
        modifier =
            Modifier.fillMaxSize()
                .oneHandedGesture(
                    gestureConfiguration = scrollGestureConfig,
                    onGestureLabel = "scroll",
                    onGestureAvailable = {
                        coroutineScope.launch { scrollIndicatorState.showIndicator() }
                    },
                    onGesture = { OneHandedGestureDefaults.scrollDownToNextItem(scrollState) },
                ),
        autoCentering = null,
    ) {
        items(10) { Text("Item $it") }
    }
}
```

| Parameters |
|---|---|
| `scrollState: ScalingLazyListState` | The scroll state associated with a scaling lazy column. |
| `wrapAround: Boolean = true` | Whether to automatically scroll back to the first item when reaching the end of the content. |

### scrollDownToNextItem

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.7.0)

```
suspend fun scrollDownToNextItem(
    scrollState: TransformingLazyColumnState,
    wrapAround: Boolean = true
): Unit
```

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`:

```kotlin
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberOverscrollEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.EdgeButton
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureClickIndicatorState
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePriority
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureScrollIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val backDispatcherOwner = LocalOnBackPressedDispatcherOwner.current
val onClick =
    remember<() -> Unit> { { backDispatcherOwner?.onBackPressedDispatcher?.onBackPressed() } }
val scrollState = rememberTransformingLazyColumnState()
val coroutineScope = rememberCoroutineScope()

val buttonInteractionSource = remember { MutableInteractionSource() }
val buttonGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Clickable,
    )
val buttonIndicatorState = remember { OneHandedGestureClickIndicatorState() }

val scrollGestureConfig =
    rememberOneHandedGestureConfiguration(
        action = OneHandedGestureAction.Primary,
        priority = OneHandedGesturePriority.Scrollable,
    )
val scrollIndicatorState =
    remember(scrollGestureConfig) { OneHandedGestureScrollIndicatorState() }

ScreenScaffold(
    scrollState = scrollState,
    edgeButton = {
        EdgeButton(
            onClick = onClick,
            interactionSource = buttonInteractionSource,
            modifier =
                if (scrollState.canScrollForward) {
                    Modifier
                } else {
                    // Apply the one-handed gesture modifier only when the container cannot
                    // scroll further, ensuring the EdgeButton is fully visible and interactive
                    Modifier.oneHandedGesture(
                        gestureConfiguration = buttonGestureConfig,
                        interactionSource = buttonInteractionSource,
                        onGestureLabel = "close",
                        onGestureAvailable = {
                            coroutineScope.launch { buttonIndicatorState.showIndicator() }
                        },
                        onGesture = onClick,
                    )
                } then
                    Modifier.scrollable(
                        state = scrollState,
                        orientation = Orientation.Vertical,
                        reverseDirection = true,
                        overscrollEffect = rememberOverscrollEffect(),
                    ),
        ) {
            OneHandedGestureClickIndicator(buttonGestureConfig, buttonIndicatorState) {
                Text("Close")
            }
        }
    },
    scrollIndicator = {
        OneHandedGestureScrollIndicator(
            gestureConfiguration = scrollGestureConfig,
            indicatorState = scrollIndicatorState,
            scrollState = scrollState,
            modifier = Modifier.align(Alignment.CenterEnd),
        )
    },
) { contentPadding ->
    TransformingLazyColumn(
        state = scrollState,
        contentPadding = contentPadding,
        modifier =
            Modifier.fillMaxSize()
                .oneHandedGesture(
                    gestureConfiguration = scrollGestureConfig,
                    onGestureLabel = "scroll",
                    onGestureAvailable = {
                        coroutineScope.launch { scrollIndicatorState.showIndicator() }
                    },
                    onGesture = { OneHandedGestureDefaults.scrollDownToNextItem(scrollState) },
                ),
    ) {
        items(10) { Text("Item $it") }
    }
}
```

| Parameters |
|---|---|
| `scrollState: TransformingLazyColumnState` | The scroll state associated with a transforming lazy column. |
| `wrapAround: Boolean = true` | Whether to automatically scroll back to the first item when reaching the end of the content. |

### scrollToNextPage

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/wear-compose.md.txt#1.7.0)

```
suspend fun scrollToNextPage(pagerState: PagerState, wrapAround: Boolean = true): Unit
```

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:

```kotlin
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.pager.HorizontalPager
import androidx.wear.compose.foundation.pager.rememberPagerState
import androidx.wear.compose.material3.AnimatedPage
import androidx.wear.compose.material3.HorizontalPagerScaffold
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureHorizontalPageIndicator
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePageIndicatorState
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val pagerState = rememberPagerState(pageCount = { 10 })
val gestureConfig =
    rememberOneHandedGestureConfiguration(action = OneHandedGestureAction.Primary)
val indicatorState = remember { OneHandedGesturePageIndicatorState() }
val coroutineScope = rememberCoroutineScope()

HorizontalPagerScaffold(
    pagerState = pagerState,
    pageIndicator = {
        OneHandedGestureHorizontalPageIndicator(
            gestureConfiguration = gestureConfig,
            indicatorState = indicatorState,
            pagerState = pagerState,
        )
    },
) {
    HorizontalPager(
        state = pagerState,
        modifier =
            Modifier.oneHandedGesture(
                gestureConfiguration = gestureConfig,
                onGestureLabel = "scroll to the next page",
                onGestureAvailable = {
                    coroutineScope.launch { indicatorState.showIndicator() }
                },
            ) {
                OneHandedGestureDefaults.scrollToNextPage(pagerState)
            },
    ) { page ->
        AnimatedPage(pageIndex = page, pagerState = pagerState) {
            ScreenScaffold { contentPadding ->
                Column(
                    modifier = Modifier.fillMaxSize().padding(contentPadding),
                    horizontalAlignment = Alignment.CenterHorizontally,
                    verticalArrangement = Arrangement.Center,
                ) {
                    Text(text = "Page #$page")
                    Spacer(modifier = Modifier.height(8.dp))
                    Text(text = "Swipe left and right")
                }
            }
        }
    }
}
```

```kotlin
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.pager.VerticalPager
import androidx.wear.compose.foundation.pager.rememberPagerState
import androidx.wear.compose.material3.AnimatedPage
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.VerticalPagerScaffold
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureAction
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureDefaults
import androidx.wear.compose.material3.onehandedgesture.OneHandedGesturePageIndicatorState
import androidx.wear.compose.material3.onehandedgesture.OneHandedGestureVerticalPageIndicator
import androidx.wear.compose.material3.onehandedgesture.oneHandedGesture
import androidx.wear.compose.material3.onehandedgesture.rememberOneHandedGestureConfiguration

val pagerState = rememberPagerState(pageCount = { 10 })
val gestureConfig =
    rememberOneHandedGestureConfiguration(action = OneHandedGestureAction.Primary)
val indicatorState = remember { OneHandedGesturePageIndicatorState() }
val coroutineScope = rememberCoroutineScope()

VerticalPagerScaffold(
    pagerState = pagerState,
    pageIndicator = {
        OneHandedGestureVerticalPageIndicator(
            gestureConfiguration = gestureConfig,
            indicatorState = indicatorState,
            pagerState = pagerState,
        )
    },
) {
    VerticalPager(
        state = pagerState,
        modifier =
            Modifier.oneHandedGesture(
                gestureConfiguration = gestureConfig,
                onGestureLabel = "scroll to the next page",
                onGestureAvailable = {
                    coroutineScope.launch { indicatorState.showIndicator() }
                },
            ) {
                OneHandedGestureDefaults.scrollToNextPage(pagerState)
            },
    ) { page ->
        AnimatedPage(pageIndex = page, pagerState = pagerState) {
            ScreenScaffold { contentPadding ->
                Column(
                    modifier = Modifier.fillMaxSize().padding(contentPadding),
                    horizontalAlignment = Alignment.CenterHorizontally,
                    verticalArrangement = Arrangement.Center,
                ) {
                    Text(text = "Page #$page")
                    Spacer(modifier = Modifier.height(8.dp))
                    Text(text = "Swipe up and down")
                }
            }
        }
    }
}
```

| Parameters |
|---|---|
| `pagerState: PagerState` | The state of the pager to be animated. |
| `wrapAround: Boolean = true` | Determines whether the pager should wrap around to the first page (index 0) after reaching the last page. |

## Public properties

### indicatorSize

```
val indicatorSize: OneHandedGestureIndicatorSize
```

The default size constraints for the gesture indicator icon.

### indicatorTint

```
val indicatorTint: Color
```

The tint color used for the gesture animation.

### pageIndicatorBackgroundColor

```
val pageIndicatorBackgroundColor: Color
```

The background color used behind the pager gesture animations.

### pageIndicatorTint

```
val pageIndicatorTint: Color
```

The tint color used for the pager gesture animation icons.

### scrollIndicatorBackgroundColor

```
val scrollIndicatorBackgroundColor: Color
```

The background color used behind the scroll gesture animations.

### scrollIndicatorTint

```
val scrollIndicatorTint: Color
```

The tint color used for the scroll gesture animation icons.