diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/PasscodeNavGraph.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/PasscodeNavGraph.kt index bc9a7e01d6..8d1ccb12f7 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/PasscodeNavGraph.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/navigation/PasscodeNavGraph.kt @@ -9,8 +9,11 @@ */ package com.mifos.mifosxdroid.navigation +import androidx.navigation.NavController +import androidx.navigation.NavGraph.Companion.findStartDestination import androidx.navigation.NavGraphBuilder import androidx.navigation.NavHostController +import androidx.navigation.navOptions import androidx.navigation.navigation import org.mifos.library.passcode.PASSCODE_SCREEN import org.mifos.library.passcode.passcodeRoute @@ -23,20 +26,33 @@ internal fun NavGraphBuilder.passcodeNavGraph(navController: NavHostController) passcodeRoute( onForgotButton = { navController.popBackStack() - navController.navigate(MifosNavGraph.MAIN_GRAPH) + navController.navigateToMainGraph() }, onSkipButton = { navController.popBackStack() - navController.navigate(MifosNavGraph.MAIN_GRAPH) + navController.navigateToMainGraph() }, onPasscodeConfirm = { navController.popBackStack() - navController.navigate(MifosNavGraph.MAIN_GRAPH) + navController.navigateToMainGraph() }, onPasscodeRejected = { navController.popBackStack() - navController.navigate(MifosNavGraph.MAIN_GRAPH) + navController.navigateToMainGraph() }, ) } } +fun NavController.navigateToMainGraph(){ + val options = navOptions { + popUpTo(graph.findStartDestination().id) { + saveState = false + } + launchSingleTop = true + restoreState = false + } + navigate(MifosNavGraph.MAIN_GRAPH , options) + + + +}