NavigableCircuitContent

fun <R : BackStack.Record> NavigableCircuitContent(navigator: Navigator, backStack: BackStack<R>, modifier: Modifier = Modifier, circuit: Circuit = requireNotNull(LocalCircuit.current), providedValues: Map<out BackStack.Record, ProvidedValues> = emptyMap(), decoration: NavDecoration = circuit.defaultNavDecoration, decoratorFactory: AnimatedNavDecorator.Factory? = null, unavailableRoute: @Composable (screen: Screen, modifier: Modifier) -> Unit = circuit.onUnavailableContent)(source)

A composable that provides the core navigation and state management for Circuit-based navigation systems. It manages the rendering of screens from a backstack, handles navigation transitions, and coordinates result passing between screens when navigating backward. This is the primary entry point for creating navigable content surfaces in Circuit.

Features

  • State Management: Manages saveable and retained state for each screen in the backstack with automatic preservation across configuration changes

  • Navigation Transitions: Handles animated transitions between screens using NavDecoration or custom AnimatedNavDecorator

  • Result Handling: Automatically manages screen results when using rememberAnsweringNavigator to pass data back from child screens

Usage

setContent {
val backStack = rememberSaveableBackStack(root = HomeScreen)
val navigator = rememberCircuitNavigator(backStack)
NavigableCircuitContent(navigator, backStack)
}

State Management

This creates an isolated retained state registry for the navigation graph to ensure proper state preservation across configuration changes when using rememberRetained. This prevents state loss for off-screen backstack records, even when they're not actively composed. See the implementation comments for technical details.

Parameters

navigator

The Navigator used to handle navigation events. Typically created via rememberCircuitNavigator.

backStack

The BackStack containing the stack of Records to display. Must have at least one record. Typically created via rememberSaveableBackStack.

modifier

The Modifier to apply to the content.

circuit

The Circuit instance providing UI factories and configuration. Defaults to LocalCircuit.

providedValues

Optional map of ProvidedValues to make available to specific records in the backstack. These values will be provided via composition locals when the corresponding record is displayed.

decoration

The NavDecoration used to decorate navigation transitions. Defaults to the circuit's default decoration.

decoratorFactory

Optional AnimatedNavDecorator.Factory to create custom animated transitions. If provided, takes precedence over decoration.

unavailableRoute

A composable function invoked when a screen cannot be rendered (e.g., no UI factory available). Defaults to the circuit's Circuit.onUnavailableContent.

See also

for requesting results from child screens

for creating a backstack

for creating a navigator


fun <R : BackStack.Record> NavigableCircuitContent(navigator: Navigator, backStack: BackStack<R>, answeringResultHandler: AnsweringResultHandler, modifier: Modifier = Modifier, circuit: Circuit = requireNotNull(LocalCircuit.current), providedValues: Map<out BackStack.Record, ProvidedValues> = emptyMap(), decoration: NavDecoration = circuit.defaultNavDecoration, decoratorFactory: AnimatedNavDecorator.Factory? = null, unavailableRoute: @Composable (screen: Screen, modifier: Modifier) -> Unit = circuit.onUnavailableContent)(source)

An experimental variant of NavigableCircuitContent that exposes answeringResultHandler for a a AnsweringResultHandler to be provided.

Usage

setContent {
val backStack = rememberSaveableBackStack(root = HomeScreen)
val navigator = rememberCircuitNavigator(backStack)
val answeringResultHandler = rememberAnsweringResultHandler()
NavigableCircuitContent(navigator, backStack, answeringResultHandler)
}