BIT-1234: Add Account button should appear in switcher on Login (#402)

This commit is contained in:
Brian Yencho
2024-06-20 17:08:07 +01:00
committed by Álison Fernandes
parent 6f85d80f9f
commit fb7bc78d95
4 changed files with 42 additions and 4 deletions
@@ -152,11 +152,10 @@ fun LoginScreen(
onLogoutAccountClick = remember(viewModel) {
{ viewModel.trySendAction(LoginAction.LogoutAccountClick(it)) }
},
onAddAccountClick = {
// Not available
onAddAccountClick = remember(viewModel) {
{ viewModel.trySendAction(LoginAction.AddAccountClick) }
},
onDismissRequest = { isAccountMenuVisible = false },
isAddAccountAvailable = false,
topAppBarScrollBehavior = scrollBehavior,
modifier = Modifier
.padding(innerPadding)
@@ -70,6 +70,7 @@ class LoginViewModel @Inject constructor(
override fun handleAction(action: LoginAction) {
when (action) {
LoginAction.AddAccountClick -> handleAddAccountClicked()
is LoginAction.LockAccountClick -> handleLockAccountClicked(action)
is LoginAction.LogoutAccountClick -> handleLogoutAccountClicked(action)
is LoginAction.SwitchAccountClick -> handleSwitchAccountClicked(action)
@@ -90,6 +91,11 @@ class LoginViewModel @Inject constructor(
}
}
private fun handleAddAccountClicked() {
// Since we are already in the login flow we can just go back to the Landing Screen
sendEvent(LoginEvent.NavigateBack)
}
private fun handleLockAccountClicked(action: LoginAction.LockAccountClick) {
vaultRepository.lockVaultIfNecessary(userId = action.accountSummary.userId)
}
@@ -247,6 +253,11 @@ sealed class LoginEvent {
*/
sealed class LoginAction {
/**
* The user has clicked the add account button.
*/
data object AddAccountClick : LoginAction()
/**
* Indicates the user has clicked on the given [accountSummary] information in order to lock
* the associated account's vault.