LayerStackManager¶
class LayerStackManager(parentComposition: CompositionContext)
Manages an ordered stack of Layers for a single screen.
The stack determines the rendering order (bottom to top) and input-dispatch priority (top layer receives events first). Overlays such as dialogs, dropdowns, and tooltips are each their own layer on top of the base screen content.
Obtain an instance via the LocalLayerManager composition local.
Parameters¶
- parentComposition: The CompositionContext from the host screen, required when creating child Compositions for each layer.
Constructors¶
LayerStackManager¶
constructor(parentComposition: CompositionContext)
Parameters
- parentComposition: The CompositionContext from the host screen, required when creating child Compositions for each layer.
Properties¶
layers¶
The ordered list of active layers. Layers are rendered bottom-to-top.
top¶
The topmost (most recently pushed) layer, which receives input events first. null if the stack is empty.
Functions¶
modal¶
Pushes a new modal layer onto the stack.
Modals are opinionated, input-blocking overlays ideal for dialogs and confirmation prompts. A click outside the modal content area triggers onDismissRequest and, when dismissOnClickOutside is true, automatically removes the layer.
Parameters
-
alignment: Alignment of the modal within the full screen. Default
Alignment.Center. -
dismissOnClickOutside: Whether clicking outside the modal content closes it.
-
onDismissRequest: Optional callback invoked when the modal is dismissed.
-
content: The modal UI, a composable lambda with
ModalScopereceiver.
pop¶
Removes and disposes the topmost layer.
popById¶
Removes and disposes the layer identified by id.
Does nothing if no layer with that id exists.
Parameters
- id: The
UUIDof the layer to remove.
push¶
Pushes a new generic layer onto the stack.
The content lambda receives a dismiss function it can call to remove itself from the stack. This overload is suitable for persistent overlays and custom layer types.
Return
A dismiss handle; call it to imperatively remove the layer.
Parameters
- layerContent: The composable content for the new layer.