ContextualToolbarState

data class ContextualToolbarState(val kind: ContextualToolbarKind, val items: PersistentList<ToolbarItem> = persistentListOf(), val position: ToolbarPosition = ToolbarPosition.Top, val isDraggable: Boolean = true, val defaultChildIds: PersistentList<Int> = persistentListOf(), val allowedPositions: PersistentList<ToolbarPosition> = persistentListOf(ToolbarPosition.Top, ToolbarPosition.Start, ToolbarPosition.End), val usesBackButtonWhenHorizontal: Boolean = true)

State slice for the currently displayed contextual toolbar. null on the coordinator's contextualToolbar flow means no contextual toolbar is shown.

Items reuse the main-toolbar item model (ToolbarItem.Button / ToolbarItem.Toggle / ToolbarItem.Submenu); the item list is flat and pre-grouped by the producer, same contract as ToolbarItems.

position and isDraggable carry the legacy ContextualToolbar docking behavior: the bar can dock ToolbarPosition.Top, ToolbarPosition.Start, or ToolbarPosition.End, and the user can drag it between those positions when isDraggable is true.

Constructors

Link copied to clipboard
constructor(kind: ContextualToolbarKind, items: PersistentList<ToolbarItem> = persistentListOf(), position: ToolbarPosition = ToolbarPosition.Top, isDraggable: Boolean = true, defaultChildIds: PersistentList<Int> = persistentListOf(), allowedPositions: PersistentList<ToolbarPosition> = persistentListOf(ToolbarPosition.Top, ToolbarPosition.Start, ToolbarPosition.End), usesBackButtonWhenHorizontal: Boolean = true)

Properties

Link copied to clipboard
val allowedPositions: PersistentList<ToolbarPosition>

Docks the user may drag the bar to — the View LayoutParams.allowedPositions. Drag releases only ever resolve to one of these; position itself is not required to be in the set (the View logs and corrects that case, producers here are trusted). Defaults to all three docks.

Link copied to clipboard
val defaultChildIds: PersistentList<Int>

Item ids ranked most-recently-used first. When a synthesized group has no selected child, it represents itself with its highest-ranked child instead of the first one — the View annotation toolbar's last-used-tool-as-group-default behavior. Empty (the default) keeps first-child representation.

Link copied to clipboard

Whether the user may drag the bar between docking positions.

Link copied to clipboard
val items: PersistentList<ToolbarItem>

Flat, pre-grouped item list rendered by the generic contextual toolbar.

Link copied to clipboard

Which mode bar this state belongs to.

Link copied to clipboard

Which window edge the bar is docked against.

Link copied to clipboard

The View ContextualToolbar.setUseBackButtonForCloseWhenHorizontal flag: when true (the View default), a ToolbarPosition.Top-docked bar renders its close button as a back arrow at the leading edge; side-docked (and always when false) the close button is a circled X at the trailing end.