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 327257cd2..3f2de1ba3 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 @@ -9,7 +9,6 @@ import com.x8bit.bitwarden.ui.auth.feature.createaccount.createAccountDestinatio import com.x8bit.bitwarden.ui.auth.feature.createaccount.navigateToCreateAccount import com.x8bit.bitwarden.ui.auth.feature.landing.LANDING_ROUTE import com.x8bit.bitwarden.ui.auth.feature.landing.landingDestinations -import com.x8bit.bitwarden.ui.auth.feature.landing.navigateToLanding import com.x8bit.bitwarden.ui.auth.feature.login.loginDestinations import com.x8bit.bitwarden.ui.auth.feature.login.navigateToLogin @@ -29,7 +28,7 @@ fun NavGraphBuilder.authDestinations(navController: NavHostController) { onNavigateToLogin = { emailAddress -> navController.navigateToLogin(emailAddress) }, ) loginDestinations( - onNavigateToLanding = { navController.navigateToLanding() }, + onNavigateBack = { navController.popBackStack() }, ) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginNavigation.kt index 9640349eb..2c037b62d 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginNavigation.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginNavigation.kt @@ -34,7 +34,7 @@ fun NavController.navigateToLogin( * Add the Login screen to the nav graph. */ fun NavGraphBuilder.loginDestinations( - onNavigateToLanding: () -> Unit, + onNavigateBack: () -> Unit, ) { composable( route = LOGIN_ROUTE, @@ -43,7 +43,7 @@ fun NavGraphBuilder.loginDestinations( ), ) { LoginScreen( - onNavigateToLanding = { onNavigateToLanding() }, + onNavigateBack = onNavigateBack, ) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreen.kt index 5e100fa13..8bfd527b4 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreen.kt @@ -32,7 +32,7 @@ import com.x8bit.bitwarden.ui.platform.components.BitwardenTextField @Composable @Suppress("LongMethod") fun LoginScreen( - onNavigateToLanding: () -> Unit, + onNavigateBack: () -> Unit, viewModel: LoginViewModel = hiltViewModel(), intentHandler: IntentHandler = IntentHandler(context = LocalContext.current), ) { @@ -40,7 +40,7 @@ fun LoginScreen( val context = LocalContext.current EventsEffect(viewModel = viewModel) { event -> when (event) { - LoginEvent.NavigateToLanding -> onNavigateToLanding() + LoginEvent.NavigateBack -> onNavigateBack() is LoginEvent.NavigateToCaptcha -> intentHandler.startActivity(intent = event.intent) is LoginEvent.ShowErrorDialog -> { // TODO Show proper error Dialog diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt index 9cdbd6f0a..3227c77ec 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModel.kt @@ -104,7 +104,7 @@ class LoginViewModel @Inject constructor( } private fun handleNotYouButtonClicked() { - sendEvent(LoginEvent.NavigateToLanding) + sendEvent(LoginEvent.NavigateBack) } private fun handleSingleSignOnClicked() { @@ -131,9 +131,9 @@ data class LoginState( */ sealed class LoginEvent { /** - * Navigates to the Landing screen. + * Navigates back to the previous screen. */ - data object NavigateToLanding : LoginEvent() + data object NavigateBack : LoginEvent() /** * Navigates to the captcha verification screen. diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt index 941c33610..b8199c514 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginScreenTest.kt @@ -31,7 +31,7 @@ class LoginScreenTest : BaseComposeTest() { } composeTestRule.setContent { LoginScreen( - onNavigateToLanding = {}, + onNavigateBack = {}, viewModel = viewModel, ) } @@ -56,7 +56,7 @@ class LoginScreenTest : BaseComposeTest() { } composeTestRule.setContent { LoginScreen( - onNavigateToLanding = {}, + onNavigateBack = {}, viewModel = viewModel, ) } @@ -67,10 +67,10 @@ class LoginScreenTest : BaseComposeTest() { } @Test - fun `NavigateToLanding should call onNavigateToLanding`() { - var onNavigateToLandingCalled = false + fun `NavigateBack should call onNavigateBack`() { + var onNavigateBackCalled = false val viewModel = mockk(relaxed = true) { - every { eventFlow } returns flowOf(LoginEvent.NavigateToLanding) + every { eventFlow } returns flowOf(LoginEvent.NavigateBack) every { stateFlow } returns MutableStateFlow( LoginState( emailAddress = "", @@ -81,11 +81,11 @@ class LoginScreenTest : BaseComposeTest() { } composeTestRule.setContent { LoginScreen( - onNavigateToLanding = { onNavigateToLandingCalled = true }, + onNavigateBack = { onNavigateBackCalled = true }, viewModel = viewModel, ) } - assertTrue(onNavigateToLandingCalled) + assertTrue(onNavigateBackCalled) } @Test @@ -106,7 +106,7 @@ class LoginScreenTest : BaseComposeTest() { } composeTestRule.setContent { LoginScreen( - onNavigateToLanding = {}, + onNavigateBack = {}, intentHandler = intentHandler, viewModel = viewModel, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt index 57862c09b..e4abbe767 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/auth/feature/login/LoginViewModelTest.kt @@ -161,7 +161,7 @@ class LoginViewModelTest : BaseViewModelTest() { } @Test - fun `NotYouButtonClick should emit NavigateToLanding`() = runTest { + fun `NotYouButtonClick should emit NavigateBack`() = runTest { val viewModel = LoginViewModel( authRepository = mockk { every { captchaTokenResultFlow } returns flowOf() @@ -171,7 +171,7 @@ class LoginViewModelTest : BaseViewModelTest() { viewModel.eventFlow.test { viewModel.actionChannel.trySend(LoginAction.NotYouButtonClick) assertEquals( - LoginEvent.NavigateToLanding, + LoginEvent.NavigateBack, awaitItem(), ) }