Graph

A declarable navigation graph, the structural counterpart to Screen and Modal.

Implement this on an object when a graph is a surface in its own right rather than just a grouping: something presented as a sheet, arriving and leaving as one piece with its own transitions and its own dismissal. Structural graphs need none of this and can keep using the graph("id") { } form, which declares no presentation and behaves exactly as before.

object WizardGraph : Graph {
override val route = "wizard"
override val enterTransition = NavTransition.SlideUpBottom
override val popExitTransition = NavTransition.SlideOutBottom
}

graph(WizardGraph) {
start(WizardDetailsScreen)
screens(WizardDetailsScreen, WizardPaymentScreen)
layout { content -> WizardLayout(content) }
}

Transitions are nullable on purpose. Null means the graph has no opinion and the entering screen's own transition is used, which is why every existing graph keeps its current behaviour. NavTransition.None is a different statement, meaning the graph arrives with no animation.

A navigation uses the transition of the outermost boundary it crosses, so entering this graph animates the graph while moving between screens already inside it animates the screen. That is what lets the steps of a wizard slide sideways inside a sheet that arrived from the bottom.

See also

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val enterTransition: NavTransition?

Transition when a navigation enters this graph from outside it.

Link copied to clipboard
open override val exitTransition: NavTransition?

Transition when a navigation leaves this graph.

Link copied to clipboard
open val onDismissRequest: suspend StoreAccessor.() -> Unit?

Invoked instead of popping when the graph is dismissed, letting the surface decide what leaving means. Takes precedence over the current screen's own handler.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

True when this node describes a surface of its own rather than deferring to what it contains.

Link copied to clipboard
abstract override val route: String
Link copied to clipboard

Whether to offer the grab affordance for the drag.

Link copied to clipboard

Whether destinations inside this graph want a navigation header.

Link copied to clipboard
Link copied to clipboard

Whether the whole graph can be dragged away as one surface.