SheetState

@Stable
class SheetState(skipPartiallyExpanded: Boolean, positionalThreshold: () -> Float, velocityThreshold: () -> Float, initialValue: SheetValue = Hidden, confirmValueChange: (SheetValue) -> Boolean = { true }, skipHiddenState: Boolean = false)

State of a sheet composable, such as ModalBottomSheet

Contains states relating to its swipe position as well as animations between state values.

Parameters

skipPartiallyExpanded

Whether the partially expanded state, if the sheet is large enough, should be skipped. If true, the sheet will always expand to the Expanded state and move to the Hidden state if available when hiding the sheet, either programmatically or by user interaction.

positionalThreshold

The positional threshold, in px, to be used when calculating the target state while a drag is in progress and when settling after the drag ends. This is the distance from the start of a transition. It will be, depending on the direction of the interaction, added or subtracted from/to the origin offset. It should always be a positive value.

velocityThreshold

The velocity threshold (in px per second) that the end velocity has to exceed in order to animate to the next state, even if the positionalThreshold has not been reached.

initialValue

The initial value of the state.

confirmValueChange

Optional callback invoked to confirm or veto a pending state change.

skipHiddenState

Whether the hidden state should be skipped. If true, the sheet will always expand to the Expanded state and move to the PartiallyExpanded if available, either programmatically or by user interaction.

Constructors

Link copied to clipboard
constructor(skipPartiallyExpanded: Boolean, positionalThreshold: () -> Float, velocityThreshold: () -> Float, initialValue: SheetValue = Hidden, confirmValueChange: (SheetValue) -> Boolean = { true }, skipHiddenState: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The current value of the state.

Link copied to clipboard

Whether the sheet has an expanded state defined.

Link copied to clipboard

Whether the modal bottom sheet has a partially expanded state defined.

Link copied to clipboard

Whether an expanding or collapsing sheet animation is currently in progress.

Link copied to clipboard

Whether the modal bottom sheet is visible.

Link copied to clipboard

The target value of the bottom sheet state.

Functions

Link copied to clipboard
suspend fun expand()

If confirmValueChange returns true, fully expand the bottom sheet with animation and suspend until it is fully expanded or animation has been cancelled.

Link copied to clipboard
suspend fun hide()

If confirmValueChange returns true, hide the bottom sheet with animation and suspend until it is fully hidden or animation has been cancelled.

Link copied to clipboard
suspend fun partialExpand()

If confirmValueChange returns true, animate the bottom sheet and suspend until it is partially expanded or animation has been cancelled.

Link copied to clipboard

Require the current offset (in pixels) of the bottom sheet.

Link copied to clipboard
suspend fun show()

If confirmValueChange returns true, expand the bottom sheet with animation and suspend until it is PartiallyExpanded if defined, else Expanded.