NavGraphBuilder
-
Cmn
@NavDestinationDsl
open class NavGraphBuilder : NavDestinationBuilder
DynamicNavGraphBuilder |
DSL for constructing a new |
DSL for constructing a new NavGraph
Summary
Public constructors |
|
|---|---|
This function is deprecated. Use routes to build your NavGraph instead |
android
|
NavGraphBuilder(DSL for constructing a new |
Cmn
android
|
NavGraphBuilder(DSL for constructing a new |
Cmn
android
|
NavGraphBuilder(DSL for constructing a new |
Cmn
android
|
Public functions |
||
|---|---|---|
Unit |
addDestination(destination: NavDestination)Add the destination to the |
Cmn
android
|
open NavGraph |
build()Build the NavDestination by calling |
Cmn
android
|
Unit |
<D : NavDestination> destination(navDestination: NavDestinationBuilder<D>)Build and add a new destination to the |
Cmn
android
|
operator Unit |
Adds this destination to the |
Cmn
android
|
Public properties |
||
|---|---|---|
NavigatorProvider |
The |
Cmn
android
|
Inherited functions |
||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
NavGraphBuilder
NavGraphBuilder(
provider: NavigatorProvider,
id: @IdRes Int,
startDestination: @IdRes Int
)
DSL for constructing a new NavGraph
| Parameters | |
|---|---|
provider: NavigatorProvider |
navigator used to create the destination |
id: @IdRes Int |
the graph's unique id |
startDestination: @IdRes Int |
the starting destination for this NavGraph |
| Returns | |
|---|---|
NavGraphBuilder |
the newly created NavGraph |
NavGraphBuilder
NavGraphBuilder(
provider: NavigatorProvider,
startDestination: String,
route: String?
)
DSL for constructing a new NavGraph
| Parameters | |
|---|---|
provider: NavigatorProvider |
navigator used to create the destination |
startDestination: String |
the starting destination's route for this NavGraph |
route: String? |
the graph's unique route |
| Returns | |
|---|---|
NavGraphBuilder |
the newly created NavGraph |
NavGraphBuilder
NavGraphBuilder(
provider: NavigatorProvider,
startDestination: Any,
route: KClass<*>?,
typeMap: Map<KType, NavType<*>>
)
DSL for constructing a new NavGraph
| Parameters | |
|---|---|
provider: NavigatorProvider |
navigator used to create the destination |
startDestination: Any |
the starting destination's route as an Object for this NavGraph. The respective NavDestination must be added with route from a |
route: KClass<*>? |
the graph's unique route as a |
typeMap: Map<KType, NavType<*>> |
A mapping of KType to custom NavType<*> in the |
| Returns | |
|---|---|
NavGraphBuilder |
the newly created NavGraph |
NavGraphBuilder
NavGraphBuilder(
provider: NavigatorProvider,
startDestination: KClass<*>,
route: KClass<*>?,
typeMap: Map<KType, NavType<*>>
)
DSL for constructing a new NavGraph
| Parameters | |
|---|---|
provider: NavigatorProvider |
navigator used to create the destination |
startDestination: KClass<*> |
the starting destination's route as a |
route: KClass<*>? |
the graph's unique route as a |
typeMap: Map<KType, NavType<*>> |
A mapping of KType to custom NavType<*> in the |
| Returns | |
|---|---|
NavGraphBuilder |
the newly created NavGraph |
Public functions
addDestination
fun addDestination(destination: NavDestination): Unit
Add the destination to the NavGraphBuilder
destination
fun <D : NavDestination> destination(navDestination: NavDestinationBuilder<D>): Unit
Build and add a new destination to the NavGraphBuilder
unaryPlus
operator fun NavDestination.unaryPlus(): Unit
Adds this destination to the NavGraphBuilder
Public properties
Extension functions
activity
inline fun NavGraphBuilder.activity(id: @IdRes Int, builder: ActivityNavigatorDestinationBuilder.() -> Unit): Unit
Construct a new ActivityNavigator.Destination
activity
inline fun NavGraphBuilder.activity(route: String, builder: ActivityNavigatorDestinationBuilder.() -> Unit): Unit
Construct a new ActivityNavigator.Destination
activity
inline fun <T : Any> NavGraphBuilder.activity(
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: ActivityNavigatorDestinationBuilder.() -> Unit
): Unit
Construct a new ActivityNavigator.Destination
| Parameters | |
|---|---|
<T : Any> |
destination's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
builder: ActivityNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
dialog
inline fun <F : DialogFragment> NavGraphBuilder.dialog(id: @IdRes Int): Unit
Construct a new DialogFragmentNavigator.Destination
dialog
inline fun <F : DialogFragment> NavGraphBuilder.dialog(route: String): Unit
Construct a new DialogFragmentNavigator.Destination
| Parameters | |
|---|---|
route: String |
the destination's unique route |
dialog
inline fun <F : DialogFragment, T : Any> NavGraphBuilder.dialog(
typeMap: Map<KType, NavType<*>> = emptyMap()
): Unit
Construct a new DialogFragmentNavigator.Destination
dialog
inline fun <F : DialogFragment> NavGraphBuilder.dialog(
id: @IdRes Int,
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit
Construct a new DialogFragmentNavigator.Destination
| Parameters | |
|---|---|
id: @IdRes Int |
the destination's unique id |
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
dialog
inline fun <F : DialogFragment> NavGraphBuilder.dialog(
route: String,
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit
Construct a new DialogFragmentNavigator.Destination
| Parameters | |
|---|---|
route: String |
the destination's unique route |
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
dialog
inline fun <F : DialogFragment, T : Any> NavGraphBuilder.dialog(
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit
Construct a new DialogFragmentNavigator.Destination
| Parameters | |
|---|---|
<T : Any> |
the destination's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
fragment
inline fun <F : Fragment> NavGraphBuilder.fragment(id: @IdRes Int): Unit
Construct a new FragmentNavigator.Destination
fragment
inline fun <F : Fragment> NavGraphBuilder.fragment(route: String): Unit
Construct a new FragmentNavigator.Destination
| Parameters | |
|---|---|
route: String |
the destination's unique route |
fragment
inline fun <F : Fragment, T : Any> NavGraphBuilder.fragment(
typeMap: Map<KType, NavType<*>> = emptyMap()
): Unit
Construct a new FragmentNavigator.Destination
fragment
inline fun <F : Fragment> NavGraphBuilder.fragment(id: @IdRes Int, builder: FragmentNavigatorDestinationBuilder.() -> Unit): Unit
Construct a new FragmentNavigator.Destination
| Parameters | |
|---|---|
id: @IdRes Int |
the destination's unique id |
builder: FragmentNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
fragment
inline fun <F : Fragment> NavGraphBuilder.fragment(route: String, builder: FragmentNavigatorDestinationBuilder.() -> Unit): Unit
Construct a new FragmentNavigator.Destination
| Parameters | |
|---|---|
route: String |
the destination's unique route |
builder: FragmentNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
fragment
inline fun <F : Fragment, T : Any> NavGraphBuilder.fragment(
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: FragmentNavigatorDestinationBuilder.() -> Unit
): Unit
Construct a new FragmentNavigator.Destination
| Parameters | |
|---|---|
<T : Any> |
the destination's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
builder: FragmentNavigatorDestinationBuilder.() -> Unit |
the builder used to construct the fragment destination |
bottomSheet
fun NavGraphBuilder.bottomSheet(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit
): Unit
Add the content as bottom sheet content to the NavGraphBuilder
import androidx.compose.material.Text import androidx.compose.material.navigation.ModalBottomSheetLayout import androidx.compose.material.navigation.bottomSheet import androidx.compose.material.navigation.rememberBottomSheetNavigator import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator) ModalBottomSheetLayout(bottomSheetNavigator) { NavHost(navController, Destinations.Home) { composable(Destinations.Home) { HomeScreen( showSheet = { navController.navigate(Destinations.Sheet + "?arg=From Home Screen") }, showFeed = { navController.navigate(Destinations.Feed) }, ) } composable(Destinations.Feed) { Text("Feed!") } bottomSheet(Destinations.Sheet + "?arg={arg}") { backstackEntry -> val arg = backstackEntry.arguments?.getString("arg") ?: "Missing argument :(" BottomSheet( showFeed = { navController.navigate(Destinations.Feed) }, showAnotherSheet = { navController.navigate(Destinations.Sheet + "?arg=${UUID.randomUUID()}") }, arg = arg, ) } } }
| Parameters | |
|---|---|
route: String |
route for the destination |
arguments: List<NamedNavArgument> = emptyList() |
list of arguments to associate with destination |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit |
the sheet content at the given destination |
bottomSheet
inline fun <T : Any> NavGraphBuilder.bottomSheet(
typeMap: Map<KType, NavType<*>> = emptyMap(),
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
noinline content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit
): Unit
Add the content as bottom sheet content to the NavGraphBuilder
import androidx.compose.material.Text import androidx.compose.material.navigation.ModalBottomSheetLayout import androidx.compose.material.navigation.bottomSheet import androidx.compose.material.navigation.rememberBottomSheetNavigator import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator) ModalBottomSheetLayout(bottomSheetNavigator) { NavHost(navController, Destinations.Home) { composable(Destinations.Home) { HomeScreen( showSheet = { navController.navigate(Destinations.Sheet + "?arg=From Home Screen") }, showFeed = { navController.navigate(Destinations.Feed) }, ) } composable(Destinations.Feed) { Text("Feed!") } bottomSheet(Destinations.Sheet + "?arg={arg}") { backstackEntry -> val arg = backstackEntry.arguments?.getString("arg") ?: "Missing argument :(" BottomSheet( showFeed = { navController.navigate(Destinations.Feed) }, showAnotherSheet = { navController.navigate(Destinations.Sheet + "?arg=${UUID.randomUUID()}") }, arg = arg, ) } } }
| Parameters | |
|---|---|
<T : Any> |
route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
arguments: List<NamedNavArgument> = emptyList() |
list of arguments to associate with destination |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
noinline content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit |
the sheet content at the given destination |
composable
fun NavGraphBuilder.composable(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable (NavBackStackEntry) -> Unit
): Unit
Utility function for building Wear Compose navigation graphs.
Adds the content composable to the NavGraphBuilder as a WearNavigator.Destination.
| Parameters | |
|---|---|
route: String |
route for the destination |
arguments: List<NamedNavArgument> = emptyList() |
list of arguments to associate with destination |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
content: @Composable (NavBackStackEntry) -> Unit |
composable for the destination |
composable
inline fun <T : Any> NavGraphBuilder.composable(
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder
| Parameters | |
|---|---|
<T : Any> |
route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to determine the destination's enter transition |
noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to determine the destination's exit transition |
noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to determine the destination's popEnter transition |
noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to determine the destination's popExit transition |
noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to determine the destination's sizeTransform. |
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit |
composable for the destination |
composable
fun <T : Any> NavGraphBuilder.composable(
route: KClass<T>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder
| Parameters | |
|---|---|
route: KClass<T> |
route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to determine the destination's enter transition |
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to determine the destination's exit transition |
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to determine the destination's popEnter transition |
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to determine the destination's popExit transition |
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to determine the destination's sizeTransform. |
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit |
composable for the destination |
composable
fun NavGraphBuilder.composable(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder
import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition import androidx.compose.animation.SizeTransform import androidx.compose.animation.core.keyframes import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.ui.unit.IntSize import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController val navController = rememberNavController() Box { NavHost(navController, startDestination = Collapsed) { composable<Collapsed>( enterTransition = { EnterTransition.None }, exitTransition = { ExitTransition.None }, sizeTransform = { SizeTransform { initialSize, targetSize -> keyframes { durationMillis = 500 IntSize( initialSize.width, (initialSize.height + targetSize.height) / 2 ) at 150 } } } ) { CollapsedScreen { navController.navigate(Expanded) } } composable<Expanded>( enterTransition = { EnterTransition.None }, exitTransition = { ExitTransition.None }, sizeTransform = { SizeTransform { initialSize, targetSize -> keyframes { durationMillis = 500 IntSize(targetSize.width, initialSize.height + 400) at 150 } } } ) { ExpandedScreen { navController.popBackStack() } } } }
| Parameters | |
|---|---|
route: String |
route for the destination |
arguments: List<NamedNavArgument> = emptyList() |
list of arguments to associate with destination |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to determine the destination's enter transition |
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to determine the destination's exit transition |
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to determine the destination's popEnter transition |
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to determine the destination's popExit transition |
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to determine the destination's sizeTransform. |
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit |
composable for the destination |
dialog
inline fun <T : Any> NavGraphBuilder.dialog(
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
dialogProperties: DialogProperties = DialogProperties(),
noinline content: @Composable (NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.
| Parameters | |
|---|---|
<T : Any> |
route from a KClass for the destination |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
dialogProperties: DialogProperties = DialogProperties() |
properties that should be passed to |
noinline content: @Composable (NavBackStackEntry) -> Unit |
composable content for the destination that will be hosted within the Dialog |
dialog
fun <T : Any> NavGraphBuilder.dialog(
route: KClass<T>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
dialogProperties: DialogProperties = DialogProperties(),
content: @Composable (NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.
| Parameters | |
|---|---|
route: KClass<T> |
|
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
dialogProperties: DialogProperties = DialogProperties() |
properties that should be passed to |
content: @Composable (NavBackStackEntry) -> Unit |
composable content for the destination that will be hosted within the Dialog |
dialog
fun NavGraphBuilder.dialog(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
dialogProperties: DialogProperties = DialogProperties(),
content: @Composable (NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.
| Parameters | |
|---|---|
route: String |
route for the destination |
arguments: List<NamedNavArgument> = emptyList() |
list of arguments to associate with destination |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
dialogProperties: DialogProperties = DialogProperties() |
properties that should be passed to |
content: @Composable (NavBackStackEntry) -> Unit |
composable content for the destination that will be hosted within the Dialog |
navigation
inline fun NavGraphBuilder.navigation(
id: @IdRes Int,
startDestination: @IdRes Int,
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
id: @IdRes Int |
the destination's unique id |
startDestination: @IdRes Int |
the starting destination for this NavGraph |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
inline fun <T : Any> NavGraphBuilder.navigation(
startDestination: Any,
typeMap: Map<KType, NavType<*>> = emptyMap(),
noinline builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
<T : Any> |
the graph's unique route from a KClass |
startDestination: Any |
the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added with route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
noinline builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
inline fun <T : Any> NavGraphBuilder.navigation(
startDestination: KClass<*>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
noinline builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
<T : Any> |
the graph's unique route from a KClass |
startDestination: KClass<*> |
the starting destination's route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
noinline builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
inline fun NavGraphBuilder.navigation(
startDestination: String,
route: String,
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
startDestination: String |
the starting destination's route for this NavGraph |
route: String |
the destination's unique route |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
fun <T : Any> NavGraphBuilder.navigation(
route: KClass<T>,
startDestination: Any,
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
route: KClass<T> |
the graph's unique route from a KClass |
startDestination: Any |
the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added with route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
fun <T : Any> NavGraphBuilder.navigation(
route: KClass<T>,
startDestination: KClass<*>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
route: KClass<T> |
the graph's unique route from KClass |
startDestination: KClass<*> |
the starting destination's route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
inline fun <T : Any> NavGraphBuilder.navigation(
startDestination: Any,
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
noinline builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
<T : Any> |
the destination's unique route from a KClass |
startDestination: Any |
the starting destination's route from an Object for this NavGraph |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to define enter transitions for destination in this NavGraph |
noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to define exit transitions for destination in this NavGraph |
noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to define pop enter transitions for destination in this NavGraph |
noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to define pop exit transitions for destination in this NavGraph |
noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to define the size transform for destinations in this NavGraph |
noinline builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
inline fun <T : Any> NavGraphBuilder.navigation(
startDestination: KClass<*>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
noinline builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition import androidx.compose.animation.SizeTransform import androidx.compose.animation.core.keyframes import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.ui.unit.IntSize import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.navigation import androidx.navigation.compose.rememberNavController val navController = rememberNavController() Box { NavHost(navController, startDestination = Collapsed) { navigation<NestedGraph>( enterTransition = { EnterTransition.None }, exitTransition = { ExitTransition.None }, startDestination = InnerCollapsed::class, sizeTransform = { SizeTransform { initialSize, targetSize -> keyframes { durationMillis = 500 IntSize( initialSize.width, (initialSize.height + targetSize.height) / 2, ) at 150 } } }, ) { composable<InnerCollapsed>( enterTransition = { EnterTransition.None }, exitTransition = { ExitTransition.None }, ) { ExpandedScreen {} } } } }
| Parameters | |
|---|---|
<T : Any> |
the destination's unique route from a KClass |
startDestination: KClass<*> |
the starting destination's route from |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to define enter transitions for destination in this NavGraph |
noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to define exit transitions for destination in this NavGraph |
noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to define pop enter transitions for destination in this NavGraph |
noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to define pop exit transitions for destination in this NavGraph |
noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to define the size transform for destinations in this NavGraph |
noinline builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
fun <T : Any> NavGraphBuilder.navigation(
startDestination: Any,
route: KClass<T>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
startDestination: Any |
the starting destination's route from an Object for this NavGraph |
route: KClass<T> |
the destination's unique route from a KClass |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to define enter transitions for destination in this NavGraph |
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to define exit transitions for destination in this NavGraph |
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to define pop enter transitions for destination in this NavGraph |
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to define pop exit transitions for destination in this NavGraph |
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to define the size transform for destinations in this NavGraph |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
fun <T : Any> NavGraphBuilder.navigation(
startDestination: KClass<*>,
route: KClass<T>,
typeMap: Map<KType, NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
startDestination: KClass<*> |
the starting destination's route from |
route: KClass<T> |
the destination's unique route from a KClass |
typeMap: Map<KType, NavType<*>> = emptyMap() |
map of destination arguments' kotlin type |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to define enter transitions for destination in this NavGraph |
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to define exit transitions for destination in this NavGraph |
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to define pop enter transitions for destination in this NavGraph |
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to define pop exit transitions for destination in this NavGraph |
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to define the size transform for destinations in this NavGraph |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |
navigation
fun NavGraphBuilder.navigation(
startDestination: String,
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
builder: NavGraphBuilder.() -> Unit
): Unit
Construct a nested NavGraph
| Parameters | |
|---|---|
startDestination: String |
the starting destination's route for this NavGraph |
route: String |
the destination's unique route |
arguments: List<NamedNavArgument> = emptyList() |
list of arguments to associate with destination |
deepLinks: List<NavDeepLink> = emptyList() |
list of deep links to associate with the destinations |
enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null |
callback to define enter transitions for destination in this NavGraph |
exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null |
callback to define exit transitions for destination in this NavGraph |
popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition |
callback to define pop enter transitions for destination in this NavGraph |
popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition |
callback to define pop exit transitions for destination in this NavGraph |
sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null |
callback to define the size transform for destinations in this NavGraph |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
| Returns | |
|---|---|
Unit |
the newly constructed nested NavGraph |