# RevealState

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


```
class RevealState
```

<br />

*** ** * ** ***

A class to keep track of the state of the composable. It can be used to customise the behavior and state of the composable.

## Summary

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/annotation/RememberInComposition https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#RevealState(androidx.wear.compose.material3.RevealValue)(initialValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue)` Create a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState`. |

| ### Public functions |
|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#animateTo(androidx.wear.compose.material3.RevealValue)(targetValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue)` Animates to the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#animateTo(androidx.wear.compose.material3.RevealValue)` with the animation spec provided. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#dispatchRawDelta(kotlin.Float)(delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Drag by the supplied `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#dispatchRawDelta(kotlin.Float)`, coerce it in the swipe bounds and return the remaining available. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)(dragPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority, block: suspend https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealDragScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Call this function to take control of the drag logic and mutate the offset. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#positionOf(androidx.wear.compose.material3.RevealValue)(revealValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue)` Get the offset position for an associated `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#snapTo(androidx.wear.compose.material3.RevealValue)(targetValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue)` Snaps to the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#snapTo(androidx.wear.compose.material3.RevealValue)` without any animation (if a previous item was already revealed, that item will be reset to the covered state with animation). |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#currentValue()` The current `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` based on the status of the component. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#isAnimationRunning()` Returns whether the animation is running or not. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#offset()` The current amount by which the revealable content has been revealed. |
| `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#targetValue()` The target `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` based on the status of the component. |

## Public constructors

### RevealState

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

```
@RememberInComposition
RevealState(initialValue: RevealValue)
```

Create a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState`.

| Parameters |
|---|---|
| `initialValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` | The initial value of this state. |

## Public functions

### animateTo

```
suspend fun animateTo(targetValue: RevealValue): Unit
```

Animates to the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#animateTo(androidx.wear.compose.material3.RevealValue)` with the animation spec provided.

| Parameters |
|---|---|
| `targetValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` | The target `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` where the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#currentValue()` will animate to. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the target `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` is not valid for current `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState` instance. |

### dispatchRawDelta

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

```
fun dispatchRawDelta(delta: Float): Float
```

Drag by the supplied `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#dispatchRawDelta(kotlin.Float)`, coerce it in the swipe bounds and return the remaining available. These bounds are determined by the screen width and the configured `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealDirection`.

| Parameters |
|---|---|
| `delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The delta (positive or negative) to drag |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The consumed delta |

### drag

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

```
suspend fun drag(
    dragPriority: MutatePriority = MutatePriority.Default,
    block: suspend SwipeToRevealDragScope.() -> Unit
): Unit
```

Call this function to take control of the drag logic and mutate the offset.

All actions that change the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#offset()` of this `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState` must be performed within a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced. The offset provided to `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealDragScope#dragTo(kotlin.Float)` will be coerced to the interval of the min/max offset values of `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue`.

If `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` is called from elsewhere with the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` higher or equal to ongoing drag, the ongoing drag will be cancelled.

**If layout dimensions change while the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` is being executed, it will be cancelled and re-executed.**

| Parameters |
|---|---|
| `dragPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority = MutatePriority.Default` | of the drag operation |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealDragScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The suspending block where the drag mutations are performed |

### positionOf

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

```
fun positionOf(revealValue: RevealValue): Float
```

Get the offset position for an associated `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue`

| Parameters |
|---|---|
| `revealValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` | The value to look up |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The offset position of the revealValue, or `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/-companion/-na-n.html` if the revealValue does not exist or not supported by current SwipeToReveal and RevealState instance |

### snapTo

```
suspend fun snapTo(targetValue: RevealValue): Unit
```

Snaps to the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#snapTo(androidx.wear.compose.material3.RevealValue)` without any animation (if a previous item was already revealed, that item will be reset to the covered state with animation).

| Parameters |
|---|---|
| `targetValue: https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` | The target `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` where the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#currentValue()` will be changed to. |

## Public properties

### currentValue

```
val currentValue: RevealValue
```

The current `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` based on the status of the component.

### isAnimationRunning

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

```
val isAnimationRunning: Boolean
```

Returns whether the animation is running or not.

### offset

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

```
val offset: Float
```

The current amount by which the revealable content has been revealed.

### targetValue

```
val targetValue: RevealValue
```

The target `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` based on the status of the component. This will be equal to the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealState#currentValue()` if there is no animation running or swiping has stopped. Otherwise, this returns the next `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/RevealValue` based on the animation/swipe direction.