This class manages the pane expansion state for pane scaffolds. By providing and modifying an instance of this class, you can specify the expanded panes' expansion width or proportion when pane scaffold is displaying a dual-pane layout.

This class also serves as the DraggableState of pane expansion handle. When a handle implementation is provided to the associated pane scaffold, the scaffold will use PaneExpansionState to store and manage dragging and anchoring of the handle, and thus the pane expansion state.

Summary

Constants

const Int

The constant value used to denote the pane expansion is not specified.

Cmn

Public functions

suspend Unit
animateTo(anchor: PaneExpansionAnchor, initialVelocity: Float)

Animate the pane expansion to the given PaneExpansionAnchor.

Cmn
Unit

Clears any previously set firstPaneWidth or firstPaneProportion, as well as the user dragging result.

Cmn
Boolean

Returns true if none of firstPaneWidth or firstPaneProportion has been set.

Cmn
Unit
setFirstPaneProportion(
    firstPaneProportion: @FloatRange(from = 0.0, to = 1.0) Float
)

Set the proportion of the first expanded pane in the layout.

Cmn
Unit
setFirstPaneWidth(firstPaneWidth: Int)

Set the width of the first expanded pane in the layout.

Cmn

Public properties

PaneExpansionAnchor?

The current anchor that pane expansion has been settled or is settling to.

Cmn

Extension functions

SemanticsPropertyReceiver.() -> Unit

This function sets up the default semantics of pane expansion drag handles with the given PaneExpansionState.

Cmn

Constants

Unspecified

const val UnspecifiedInt

The constant value used to denote the pane expansion is not specified.

Public functions

animateTo

suspend fun animateTo(anchor: PaneExpansionAnchor, initialVelocity: Float = 0.0f): Unit

Animate the pane expansion to the given PaneExpansionAnchor. Note that the given anchor must be one of the provided anchor when creating the state with rememberPaneExpansionState; otherwise the function throws.

Parameters
anchor: PaneExpansionAnchor

the anchor to animate to

initialVelocity: Float = 0.0f

the initial velocity of the animation

clear

fun clear(): Unit

Clears any previously set firstPaneWidth or firstPaneProportion, as well as the user dragging result.

isUnspecified

fun isUnspecified(): Boolean

Returns true if none of firstPaneWidth or firstPaneProportion has been set.

setFirstPaneProportion

fun setFirstPaneProportion(
    firstPaneProportion: @FloatRange(from = 0.0, to = 1.0) Float
): Unit

Set the proportion of the first expanded pane in the layout. The set value needs to be within the range of [0f, 1f], otherwise the setter throws.

Note that setting this value will reset the first pane width previously set via setFirstPaneWidth or the current dragging result if there's any. Also if user drags the pane after setting the first pane proportion, the user dragging result will take the priority over this set value when rendering panes, but the set value will be saved.

setFirstPaneWidth

fun setFirstPaneWidth(firstPaneWidth: Int): Unit

Set the width of the first expanded pane in the layout. When the set value gets applied, it will be coerced within the range of [0, the full displayable width of the layout].

Note that setting this value will reset the first pane proportion previously set via setFirstPaneProportion or the current dragging result if there's any. Also if user drags the pane after setting the first pane width, the user dragging result will take the priority over this set value when rendering panes, but the set value will be saved.

Public properties

currentAnchor

val currentAnchorPaneExpansionAnchor?

The current anchor that pane expansion has been settled or is settling to. Note that this field might be null if:

  1. No anchors have been set to the state.

  2. Pane expansion is set directly via setFirstPaneWidth or set setFirstPaneProportion.

  3. Pane expansion is in its initial state without an initial anchor provided.

Extension functions

defaultDragHandleSemantics

@ExperimentalMaterial3AdaptiveApi
@Composable
fun PaneExpansionState.defaultDragHandleSemantics(): SemanticsPropertyReceiver.() -> Unit

This function sets up the default semantics of pane expansion drag handles with the given PaneExpansionState. It will provide suitable contentDescription as well as onClick function to move the pane expansion among anchors that can be operated via accessibility services.

It's supposed to be used with a PaneScaffoldScope.paneExpansionDraggable modifier, or a plain semantics modifier associated with a drag handle composable.