androidx.compose.material3.adaptive.layout

rememberPaneExpansionStateSince 1.1Experimental

Function · from org.jetbrains.compose.material3.adaptive:adaptive-layout:1.3.0

No hand-written docs yet.

Remembers and returns a PaneExpansionState associated to a given PaneExpansionStateKeyProvider.

With keyProviderExperimental

@Composable
fun rememberPaneExpansionState(
    keyProvider: PaneExpansionStateKeyProvider,
    anchors: List<PaneExpansionAnchor> = emptyList(),
    initialAnchoredIndex: Int = -1,
    anchoringAnimationSpec: FiniteAnimationSpec<Float> = DefaultAnchoringAnimationSpec,
    flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
    consumeDragDelta: ((delta: Float) -> Float) = PaneExpansionState.noOpConsumeDragDelta,
): PaneExpansionState

keyProvider: PaneExpansionStateKeyProviderRequired

the provider of PaneExpansionStateKey

anchors: List<PaneExpansionAnchor>Optional

Default: emptyList()

the anchor list of the returned PaneExpansionState

initialAnchoredIndex: IntOptional

Default: -1

the index of the anchor that is supposed to be used during the initial layout of the associated scaffold; it has to be a valid index of the provided anchors otherwise the function throws; by default the value will be -1 and no initial anchor will be used.

anchoringAnimationSpec: FiniteAnimationSpec<Float>Optional

Default: DefaultAnchoringAnimationSpec

the animation spec used to perform anchoring animation; by default it will be a spring motion.

flingBehavior: FlingBehaviorOptional

Default: ScrollableDefaults.flingBehavior()

the fling behavior used to handle flings; by default ScrollableDefaults.flingBehavior will be applied.

consumeDragDelta: ((delta: Float) -> Float)OptionalSince 1.2

Default: PaneExpansionState.noOpConsumeDragDelta

the callback that will be called before the drag starts to change the pane sizes; the input of the lambda will be the raw delta by user dragging, and it should returns the remaining delta after the consumption by the callback; this can be used to implement custom behavior like nested scrolling or combining pane expansion with other element expansion behavior like navigation rails.

With keyExperimental

@Composable
fun rememberPaneExpansionState(
    key: PaneExpansionStateKey = PaneExpansionStateKey.Default,
    anchors: List<PaneExpansionAnchor> = emptyList(),
    initialAnchoredIndex: Int = -1,
    anchoringAnimationSpec: FiniteAnimationSpec<Float> = DefaultAnchoringAnimationSpec,
    flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
    consumeDragDelta: ((Float) -> Float) = PaneExpansionState.noOpConsumeDragDelta,
): PaneExpansionState

key: PaneExpansionStateKeyOptional

consumeDragDelta: ((Float) -> Float)OptionalSince 1.2

Default: PaneExpansionState.noOpConsumeDragDelta

the callback that will be called before the drag starts to change the pane sizes; the input of the lambda will be the raw delta by user dragging, and it should returns the remaining delta after the consumption by the callback; this can be used to implement custom behavior like nested scrolling or combining pane expansion with other element expansion behavior like navigation rails.

Same as above: anchors, initialAnchoredIndex, anchoringAnimationSpec, flingBehavior.

Library docs

Remembers and returns a PaneExpansionState associated to a given PaneExpansionStateKeyProvider.

Note that the remembered PaneExpansionState with all keys that have been used will be persistent through the associated pane scaffold's lifecycles.