Rename other navigation extensions per new naming convention (#134)

This commit is contained in:
Andrew Haisting 2023-10-19 09:33:16 -05:00 committed by Álison Fernandes
parent ab2a500607
commit 6f212066e3
5 changed files with 28 additions and 29 deletions

View file

@ -12,15 +12,15 @@ import com.x8bit.bitwarden.ui.auth.feature.landing.landingDestinations
import com.x8bit.bitwarden.ui.auth.feature.login.loginDestinations import com.x8bit.bitwarden.ui.auth.feature.login.loginDestinations
import com.x8bit.bitwarden.ui.auth.feature.login.navigateToLogin import com.x8bit.bitwarden.ui.auth.feature.login.navigateToLogin
const val AUTH_ROUTE: String = "auth" const val AUTH_GRAPH_ROUTE: String = "auth_graph"
/** /**
* Add auth destinations to the nav graph. * Add auth destinations to the nav graph.
*/ */
fun NavGraphBuilder.authDestinations(navController: NavHostController) { fun NavGraphBuilder.authGraph(navController: NavHostController) {
navigation( navigation(
startDestination = LANDING_ROUTE, startDestination = LANDING_ROUTE,
route = AUTH_ROUTE, route = AUTH_GRAPH_ROUTE,
) { ) {
createAccountDestinations(onNavigateBack = { navController.popBackStack() }) createAccountDestinations(onNavigateBack = { navController.popBackStack() })
landingDestinations( landingDestinations(
@ -37,10 +37,10 @@ fun NavGraphBuilder.authDestinations(navController: NavHostController) {
/** /**
* Navigate to the auth screen. Note this will only work if auth destination was added * Navigate to the auth screen. Note this will only work if auth destination was added
* via [authDestinations]. * via [authGraph].
*/ */
fun NavController.navigateToAuth( fun NavController.navigateToAuthGraph(
navOptions: NavOptions? = null, navOptions: NavOptions? = null,
) { ) {
navigate(AUTH_ROUTE, navOptions) navigate(AUTH_GRAPH_ROUTE, navOptions)
} }

View file

@ -10,15 +10,15 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions import androidx.navigation.navOptions
import com.x8bit.bitwarden.ui.auth.feature.auth.AUTH_ROUTE import com.x8bit.bitwarden.ui.auth.feature.auth.AUTH_GRAPH_ROUTE
import com.x8bit.bitwarden.ui.auth.feature.auth.authDestinations import com.x8bit.bitwarden.ui.auth.feature.auth.authGraph
import com.x8bit.bitwarden.ui.auth.feature.auth.navigateToAuth import com.x8bit.bitwarden.ui.auth.feature.auth.navigateToAuthGraph
import com.x8bit.bitwarden.ui.platform.feature.splash.SPLASH_ROUTE import com.x8bit.bitwarden.ui.platform.feature.splash.SPLASH_ROUTE
import com.x8bit.bitwarden.ui.platform.feature.splash.navigateToSplash import com.x8bit.bitwarden.ui.platform.feature.splash.navigateToSplash
import com.x8bit.bitwarden.ui.platform.feature.splash.splashDestinations import com.x8bit.bitwarden.ui.platform.feature.splash.splashDestination
import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.VAULT_UNLOCKED_ROUTE import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.VAULT_UNLOCKED_GRAPH_ROUTE
import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.navigateToVaultUnlocked import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.navigateToVaultUnlockedGraph
import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.vaultUnlockedDestinations import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.vaultUnlockedGraph
/** /**
* Controls root level [NavHost] for the app. * Controls root level [NavHost] for the app.
@ -40,15 +40,15 @@ fun RootNavScreen(
navController = navController, navController = navController,
startDestination = SPLASH_ROUTE, startDestination = SPLASH_ROUTE,
) { ) {
splashDestinations() splashDestination()
authDestinations(navController) authGraph(navController)
vaultUnlockedDestinations(navController) vaultUnlockedGraph()
} }
val targetRoute = when (state) { val targetRoute = when (state) {
RootNavState.Auth -> AUTH_ROUTE RootNavState.Auth -> AUTH_GRAPH_ROUTE
RootNavState.Splash -> SPLASH_ROUTE RootNavState.Splash -> SPLASH_ROUTE
RootNavState.VaultUnlocked -> VAULT_UNLOCKED_ROUTE RootNavState.VaultUnlocked -> VAULT_UNLOCKED_GRAPH_ROUTE
} }
val currentRoute = navController.currentDestination?.rootLevelRoute() val currentRoute = navController.currentDestination?.rootLevelRoute()
@ -70,9 +70,9 @@ fun RootNavScreen(
} }
when (state) { when (state) {
RootNavState.Auth -> navController.navigateToAuth(rootNavOptions) RootNavState.Auth -> navController.navigateToAuthGraph(rootNavOptions)
RootNavState.Splash -> navController.navigateToSplash(rootNavOptions) RootNavState.Splash -> navController.navigateToSplash(rootNavOptions)
RootNavState.VaultUnlocked -> navController.navigateToVaultUnlocked(rootNavOptions) RootNavState.VaultUnlocked -> navController.navigateToVaultUnlockedGraph(rootNavOptions)
} }
} }

View file

@ -10,7 +10,7 @@ const val SPLASH_ROUTE: String = "splash"
/** /**
* Add splash destinations to the nav graph. * Add splash destinations to the nav graph.
*/ */
fun NavGraphBuilder.splashDestinations() { fun NavGraphBuilder.splashDestination() {
composable(SPLASH_ROUTE) { SplashScreen() } composable(SPLASH_ROUTE) { SplashScreen() }
} }

View file

@ -2,28 +2,27 @@ package com.x8bit.bitwarden.ui.platform.feature.vaultunlocked
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.NavOptions import androidx.navigation.NavOptions
import androidx.navigation.navigation import androidx.navigation.navigation
import com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar.VAULT_UNLOCKED_NAV_BAR_ROUTE import com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar.VAULT_UNLOCKED_NAV_BAR_ROUTE
import com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar.vaultUnlockedNavBarDestination import com.x8bit.bitwarden.ui.platform.feature.vaultunlockednavbar.vaultUnlockedNavBarDestination
const val VAULT_UNLOCKED_ROUTE: String = "VaultUnlocked" const val VAULT_UNLOCKED_GRAPH_ROUTE: String = "vault_unlocked_graph"
/** /**
* Navigate to the vault unlocked screen. * Navigate to the vault unlocked screen.
*/ */
fun NavController.navigateToVaultUnlocked(navOptions: NavOptions? = null) { fun NavController.navigateToVaultUnlockedGraph(navOptions: NavOptions? = null) {
navigate(VAULT_UNLOCKED_ROUTE, navOptions) navigate(VAULT_UNLOCKED_GRAPH_ROUTE, navOptions)
} }
/** /**
* Add vault unlocked destinations to the root nav graph. * Add vault unlocked destinations to the root nav graph.
*/ */
fun NavGraphBuilder.vaultUnlockedDestinations(navController: NavHostController) { fun NavGraphBuilder.vaultUnlockedGraph() {
navigation( navigation(
startDestination = VAULT_UNLOCKED_NAV_BAR_ROUTE, startDestination = VAULT_UNLOCKED_NAV_BAR_ROUTE,
route = VAULT_UNLOCKED_ROUTE, route = VAULT_UNLOCKED_GRAPH_ROUTE,
) { ) {
vaultUnlockedNavBarDestination() vaultUnlockedNavBarDestination()
} }

View file

@ -66,7 +66,7 @@ class RootNavScreenTest : BaseComposeTest() {
rootNavStateFlow.value = RootNavState.Auth rootNavStateFlow.value = RootNavState.Auth
composeTestRule.runOnIdle { composeTestRule.runOnIdle {
fakeNavHostController.assertLastNavigation( fakeNavHostController.assertLastNavigation(
route = "auth", route = "auth_graph",
navOptions = expectedNavOptions, navOptions = expectedNavOptions,
) )
} }
@ -76,7 +76,7 @@ class RootNavScreenTest : BaseComposeTest() {
rootNavStateFlow.value = RootNavState.VaultUnlocked rootNavStateFlow.value = RootNavState.VaultUnlocked
composeTestRule.runOnIdle { composeTestRule.runOnIdle {
fakeNavHostController.assertLastNavigation( fakeNavHostController.assertLastNavigation(
route = "VaultUnlocked", route = "vault_unlocked_graph",
navOptions = expectedNavOptions, navOptions = expectedNavOptions,
) )
} }