mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Rename other navigation extensions per new naming convention (#134)
This commit is contained in:
parent
ab2a500607
commit
6f212066e3
5 changed files with 28 additions and 29 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() }
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue