mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 17:05:44 +03:00
Rename Login navigation components to Auth (#23)
This commit is contained in:
parent
c048d36f0e
commit
915e9d5fd6
4 changed files with 17 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
|||
package com.x8bit.bitwarden.ui.feature.login
|
||||
package com.x8bit.bitwarden.ui.feature.auth
|
||||
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
|
@ -10,15 +10,15 @@ import com.x8bit.bitwarden.ui.feature.createaccount.navigateToCreateAccount
|
|||
import com.x8bit.bitwarden.ui.feature.landing.LANDING_ROUTE
|
||||
import com.x8bit.bitwarden.ui.feature.landing.landingDestination
|
||||
|
||||
const val LOGIN_ROUTE: String = "login"
|
||||
const val AUTH_ROUTE: String = "auth"
|
||||
|
||||
/**
|
||||
* Add login destinations to the nav graph.
|
||||
* Add auth destinations to the nav graph.
|
||||
*/
|
||||
fun NavGraphBuilder.loginDestinations(navController: NavHostController) {
|
||||
fun NavGraphBuilder.authDestinations(navController: NavHostController) {
|
||||
navigation(
|
||||
startDestination = LANDING_ROUTE,
|
||||
route = LOGIN_ROUTE,
|
||||
route = AUTH_ROUTE,
|
||||
) {
|
||||
createAccountDestinations()
|
||||
landingDestination(
|
||||
|
@ -28,10 +28,10 @@ fun NavGraphBuilder.loginDestinations(navController: NavHostController) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Navigate to the login screen. Note this will only work if login destination was added
|
||||
* via [loginDestinations].
|
||||
* Navigate to the auth screen. Note this will only work if auth destination was added
|
||||
* via [authDestinations].
|
||||
*/
|
||||
fun NavController.navigateToLogin(
|
||||
fun NavController.navigateToAuth(
|
||||
navOptions: NavOptions? = null,
|
||||
) {
|
||||
navigate(LANDING_ROUTE, navOptions)
|
|
@ -12,8 +12,8 @@ import androidx.navigation.compose.composable
|
|||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navOptions
|
||||
import com.x8bit.bitwarden.ui.components.PlaceholderComposable
|
||||
import com.x8bit.bitwarden.ui.feature.login.loginDestinations
|
||||
import com.x8bit.bitwarden.ui.feature.login.navigateToLogin
|
||||
import com.x8bit.bitwarden.ui.feature.auth.authDestinations
|
||||
import com.x8bit.bitwarden.ui.feature.auth.navigateToAuth
|
||||
|
||||
/**
|
||||
* Controls root level [NavHost] for the app.
|
||||
|
@ -30,7 +30,7 @@ fun RootNavScreen(
|
|||
startDestination = SplashRoute,
|
||||
) {
|
||||
splashDestinations()
|
||||
loginDestinations(navController)
|
||||
authDestinations(navController)
|
||||
}
|
||||
|
||||
// When state changes, navigate to different root navigation state
|
||||
|
@ -41,7 +41,7 @@ fun RootNavScreen(
|
|||
}
|
||||
}
|
||||
when (state) {
|
||||
RootNavState.Login -> navController.navigateToLogin(rootNavOptions)
|
||||
RootNavState.Auth -> navController.navigateToAuth(rootNavOptions)
|
||||
RootNavState.Splash -> navController.navigateToSplash(rootNavOptions)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class RootNavViewModel @Inject constructor() :
|
|||
viewModelScope.launch {
|
||||
@Suppress("MagicNumber")
|
||||
delay(1000)
|
||||
mutableStateFlow.value = RootNavState.Login
|
||||
mutableStateFlow.value = RootNavState.Auth
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ class RootNavViewModel @Inject constructor() :
|
|||
*/
|
||||
sealed class RootNavState {
|
||||
/**
|
||||
* Show the login screen.
|
||||
* Show the auth screens.
|
||||
*/
|
||||
data object Login : RootNavState()
|
||||
data object Auth : RootNavState()
|
||||
|
||||
/**
|
||||
* Show the splash screen.
|
||||
|
|
|
@ -16,11 +16,11 @@ class RootNavViewModelTests : BaseViewModelTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `state should move from splash to login`() = runTest {
|
||||
fun `state should move from splash to auth`() = runTest {
|
||||
val viewModel = RootNavViewModel()
|
||||
viewModel.stateFlow.test {
|
||||
assert(awaitItem() is RootNavState.Splash)
|
||||
assert(awaitItem() is RootNavState.Login)
|
||||
assert(awaitItem() is RootNavState.Auth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue