public class BottomSheetState(
initialValue: BottomSheetValue,
density: Density,
animationSpec: AnimationSpec<Float> = BottomSheetScaffoldDefaults.AnimationSpec,
confirmValueChange: (BottomSheetValue) -> Boolean = { true },
)
State of the persistent bottom sheet in BottomSheetScaffold.
Parameters
| initialValue | The initial value of the state. |
| density | The density that this state can use to convert values to and from dp. |
| animationSpec | The default animation that will be used to animate to a new state. |
| confirmValueChange | Optional callback invoked to confirm or veto a pending state change. |
Properties
currentValue
public val currentValue: BottomSheetValue
The current value of the BottomSheetState.
targetValue
public val targetValue: BottomSheetValue
The target value the state will settle at once the current interaction ends, or the currentValue if there is no interaction in progress.
isExpanded
public val isExpanded: Boolean
Whether the bottom sheet is expanded.
isCollapsed
public val isCollapsed: Boolean
Whether the bottom sheet is collapsed.
progress
@Deprecated(
message = "Please use the progress function to query progress explicitly between targets.",
replaceWith = ReplaceWith("progress(from = , to = )"),
)
public val progress: Float
The fraction of the progress, within 0f..1f bounds, or 1f if the AnchoredDraggableState is in a settled state.
Functions
progress
public fun progress(from: BottomSheetValue, to: BottomSheetValue): Float
The fraction of the offset between from and to, as a fraction between 0f..1f, or 1f if from is equal to to.
Parameters
| from | The starting value used to calculate the distance |
| to | The end value used to calculate the distance |
expand
public suspend fun expand()
Expand the bottom sheet with an animation and suspend until the animation finishes or is cancelled. Note: If the peek height is equal to the sheet height, this method will animate to the Collapsed state.
This method will throw CancellationException if the animation is interrupted.
collapse
public suspend fun collapse(): Unit
Collapse the bottom sheet with animation and suspend until it if fully collapsed or animation has been cancelled. This method will throw CancellationException if the animation is interrupted.
requireOffset
public fun requireOffset(): Float
Require the current offset.
Throws: IllegalStateException
If the offset has not been initialized yet
Members
Companion
public companion object
Functions
Saver
public fun Saver(
animationSpec: AnimationSpec<Float>,
confirmStateChange: (BottomSheetValue) -> Boolean,
density: Density,
): Saver<BottomSheetState, *>
The default Saver implementation for BottomSheetState.