Код: Выделить всё
NavHost(
navController = appState.navController,
route = rootRoute,
startDestination = authGraphRoute,
) {
authGraph(appState)
editProfileListScreen(appState, appViewModel)
homeGraph(appState)
}
Код: Выделить всё
const val authGraphRoute = "auth_graph_route"
fun NavGraphBuilder.authGraph(
appState: InnoAppState
) {
navigation(
startDestination = splashRoute,
route = authGraphRoute
) {
splashScreen(appState)
onboardingScreen(appState)
signInScreen(appState)
otpScreen(appState)
notificationPermissionScreen(appState)
appUpdateScreen(appState)
}
}
Код: Выделить всё
appState.navController.navToEditProfileListScreen(){
popUpTo(authGraphRoute){
inclusive = true
}
}
Код: Выделить всё
appState.navController.navigateToHomeGraph(){
popUpTo(editProfileListScreenRoute){
inclusive = true
saveState = false
}
launchSingleTop = true
restoreState = true
}
Код: Выделить всё
fun navigateToTopLevelDestination(topLevelDestination: BtmBarScreen) {
val topLevelNavOptions = navOptions {
// Pop up to the start destination of the graph to
// avoid building up a large stack of destinations
// on the back stack as users select items
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
// Avoid multiple copies of the same destination when
// reselecting the same item
launchSingleTop = true
// Restore state when reselecting a previously selected item
restoreState = true
}
when (topLevelDestination) {
BtmBarScreen.HomeGraph -> navController.navigateToHomeGraph(topLevelNavOptions)
BtmBarScreen.MyList -> navController.navToMyWatchListGraph(topLevelNavOptions)
BtmBarScreen.LiveTvGraph -> navController.navigateToLiveTvGraph(topLevelNavOptions)
BtmBarScreen.BrowseGraph -> navController.navigateToBrowseGraph(topLevelNavOptions)
BtmBarScreen.YouGraph -> navController.navToYouGraph(topLevelNavOptions)
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... rtroute-of