NavigationContainer

fun NavigationContainer(key: Any, onClose: () -> Unit, screenSize: Size, controller: NavigationController, foreground: @Composable BoxScope.() -> Unit? = null, background: @Composable BoxScope.() -> Unit? = null, topBar: @Composable () -> Unit? = null, navigationBar: @Composable () -> Unit? = null, setup: NavigationConfiguration.() -> Unit = {}, scope: NavigationScope.() -> Unit)

Container component that provides navigation for screens, which were added in scope. It is expected to have only one NavigationContainer per application.

Parameters

key
  • The key can be used to re-apply setup without unnecessary UI recomposition.

onClose
  • The action, which will be triggered on BackDestination sent, in case backstack is empty.

screenSize
  • Screen size, used to properly calculate transition distance for animations.

controller
  • The controller, which is responsible for navigation.

background
  • The layout that is always in the background, regardless of the current Destination. In most cases, it should not have semantics - if this is the case for you, remember to clear it using clearAndSetSemantics.

topBar
  • The component, which is always located at the top of the current screen.

navigationBar
setup
scope
  • The scope, which allows to bind destinations with respective screen composables via NavigationScope.screen. Example:

NavigationContainer(
key = "app",
onClose = { finish() },
screenSize = size,
controller = controller,
) {
screen(Home::class) { HomeScreen() }
screen(Profile::class) { ProfileScreen() }
}