From 6f212066e3518b35be670d11642c3a094d48cb1d Mon Sep 17 00:00:00 2001 From: Andrew Haisting <142518658+ahaisting-livefront@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:33:16 -0500 Subject: [PATCH] Rename other navigation extensions per new naming convention (#134) --- .../ui/auth/feature/auth/AuthNavigation.kt | 12 ++++---- .../platform/feature/rootnav/RootNavScreen.kt | 28 +++++++++---------- .../feature/splash/SplashNavigation.kt | 2 +- .../vaultunlocked/VaultUnlockedNavigation.kt | 11 ++++---- .../feature/rootnav/RootNavScreenTest.kt | 4 +-- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt index 3998238a7..63124919e 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/auth/AuthNavigation.kt @@ -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.navigateToLogin -const val AUTH_ROUTE: String = "auth" +const val AUTH_GRAPH_ROUTE: String = "auth_graph" /** * Add auth destinations to the nav graph. */ -fun NavGraphBuilder.authDestinations(navController: NavHostController) { +fun NavGraphBuilder.authGraph(navController: NavHostController) { navigation( startDestination = LANDING_ROUTE, - route = AUTH_ROUTE, + route = AUTH_GRAPH_ROUTE, ) { createAccountDestinations(onNavigateBack = { navController.popBackStack() }) 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 - * via [authDestinations]. + * via [authGraph]. */ -fun NavController.navigateToAuth( +fun NavController.navigateToAuthGraph( navOptions: NavOptions? = null, ) { - navigate(AUTH_ROUTE, navOptions) + navigate(AUTH_GRAPH_ROUTE, navOptions) } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt index a34a56d8a..b214b0170 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt @@ -10,15 +10,15 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions -import com.x8bit.bitwarden.ui.auth.feature.auth.AUTH_ROUTE -import com.x8bit.bitwarden.ui.auth.feature.auth.authDestinations -import com.x8bit.bitwarden.ui.auth.feature.auth.navigateToAuth +import com.x8bit.bitwarden.ui.auth.feature.auth.AUTH_GRAPH_ROUTE +import com.x8bit.bitwarden.ui.auth.feature.auth.authGraph +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.navigateToSplash -import com.x8bit.bitwarden.ui.platform.feature.splash.splashDestinations -import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.VAULT_UNLOCKED_ROUTE -import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.navigateToVaultUnlocked -import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.vaultUnlockedDestinations +import com.x8bit.bitwarden.ui.platform.feature.splash.splashDestination +import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.VAULT_UNLOCKED_GRAPH_ROUTE +import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.navigateToVaultUnlockedGraph +import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.vaultUnlockedGraph /** * Controls root level [NavHost] for the app. @@ -40,15 +40,15 @@ fun RootNavScreen( navController = navController, startDestination = SPLASH_ROUTE, ) { - splashDestinations() - authDestinations(navController) - vaultUnlockedDestinations(navController) + splashDestination() + authGraph(navController) + vaultUnlockedGraph() } val targetRoute = when (state) { - RootNavState.Auth -> AUTH_ROUTE + RootNavState.Auth -> AUTH_GRAPH_ROUTE RootNavState.Splash -> SPLASH_ROUTE - RootNavState.VaultUnlocked -> VAULT_UNLOCKED_ROUTE + RootNavState.VaultUnlocked -> VAULT_UNLOCKED_GRAPH_ROUTE } val currentRoute = navController.currentDestination?.rootLevelRoute() @@ -70,9 +70,9 @@ fun RootNavScreen( } when (state) { - RootNavState.Auth -> navController.navigateToAuth(rootNavOptions) + RootNavState.Auth -> navController.navigateToAuthGraph(rootNavOptions) RootNavState.Splash -> navController.navigateToSplash(rootNavOptions) - RootNavState.VaultUnlocked -> navController.navigateToVaultUnlocked(rootNavOptions) + RootNavState.VaultUnlocked -> navController.navigateToVaultUnlockedGraph(rootNavOptions) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt index 90aed312b..bf1114b33 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt @@ -10,7 +10,7 @@ const val SPLASH_ROUTE: String = "splash" /** * Add splash destinations to the nav graph. */ -fun NavGraphBuilder.splashDestinations() { +fun NavGraphBuilder.splashDestination() { composable(SPLASH_ROUTE) { SplashScreen() } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt index f0a81f5f0..0e24514d9 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt @@ -2,28 +2,27 @@ package com.x8bit.bitwarden.ui.platform.feature.vaultunlocked import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder -import androidx.navigation.NavHostController import androidx.navigation.NavOptions 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.vaultUnlockedNavBarDestination -const val VAULT_UNLOCKED_ROUTE: String = "VaultUnlocked" +const val VAULT_UNLOCKED_GRAPH_ROUTE: String = "vault_unlocked_graph" /** * Navigate to the vault unlocked screen. */ -fun NavController.navigateToVaultUnlocked(navOptions: NavOptions? = null) { - navigate(VAULT_UNLOCKED_ROUTE, navOptions) +fun NavController.navigateToVaultUnlockedGraph(navOptions: NavOptions? = null) { + navigate(VAULT_UNLOCKED_GRAPH_ROUTE, navOptions) } /** * Add vault unlocked destinations to the root nav graph. */ -fun NavGraphBuilder.vaultUnlockedDestinations(navController: NavHostController) { +fun NavGraphBuilder.vaultUnlockedGraph() { navigation( startDestination = VAULT_UNLOCKED_NAV_BAR_ROUTE, - route = VAULT_UNLOCKED_ROUTE, + route = VAULT_UNLOCKED_GRAPH_ROUTE, ) { vaultUnlockedNavBarDestination() } diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreenTest.kt index a790dfb92..1737963d6 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreenTest.kt @@ -66,7 +66,7 @@ class RootNavScreenTest : BaseComposeTest() { rootNavStateFlow.value = RootNavState.Auth composeTestRule.runOnIdle { fakeNavHostController.assertLastNavigation( - route = "auth", + route = "auth_graph", navOptions = expectedNavOptions, ) } @@ -76,7 +76,7 @@ class RootNavScreenTest : BaseComposeTest() { rootNavStateFlow.value = RootNavState.VaultUnlocked composeTestRule.runOnIdle { fakeNavHostController.assertLastNavigation( - route = "VaultUnlocked", + route = "vault_unlocked_graph", navOptions = expectedNavOptions, ) }