mirror of
https://github.com/bitwarden/android.git
synced 2024-11-22 09:25:58 +03:00
Add explicit title to reset password screen dialogs (#1364)
This commit is contained in:
parent
0379e68a5c
commit
1ede84d22c
4 changed files with 14 additions and 15 deletions
|
@ -31,7 +31,6 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenMediumTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
|
||||
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
|
||||
|
@ -59,7 +58,7 @@ fun ResetPasswordScreen(
|
|||
is ResetPasswordState.DialogState.Error -> {
|
||||
BitwardenBasicDialog(
|
||||
visibilityState = BasicDialogState.Shown(
|
||||
title = dialog.title ?: R.string.an_error_has_occurred.asText(),
|
||||
title = dialog.title,
|
||||
message = dialog.message,
|
||||
),
|
||||
onDismissRequest = remember(viewModel) {
|
||||
|
|
|
@ -101,7 +101,7 @@ class ResetPasswordViewModel @Inject constructor(
|
|||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.validation_field_required
|
||||
.asText(R.string.master_password.asText()),
|
||||
),
|
||||
|
@ -126,7 +126,7 @@ class ResetPasswordViewModel @Inject constructor(
|
|||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.master_password_length_val_message_x
|
||||
.asText(MIN_PASSWORD_LENGTH),
|
||||
),
|
||||
|
@ -218,7 +218,7 @@ class ResetPasswordViewModel @Inject constructor(
|
|||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.generic_error_message.asText(),
|
||||
),
|
||||
)
|
||||
|
@ -243,7 +243,7 @@ class ResetPasswordViewModel @Inject constructor(
|
|||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.generic_error_message.asText(),
|
||||
),
|
||||
)
|
||||
|
@ -256,7 +256,7 @@ class ResetPasswordViewModel @Inject constructor(
|
|||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.invalid_master_password.asText(),
|
||||
),
|
||||
)
|
||||
|
@ -309,7 +309,7 @@ class ResetPasswordViewModel @Inject constructor(
|
|||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.master_password_confirmation_val_message.asText(),
|
||||
),
|
||||
)
|
||||
|
@ -365,7 +365,7 @@ data class ResetPasswordState(
|
|||
*/
|
||||
@Parcelize
|
||||
data class Error(
|
||||
val title: Text? = null,
|
||||
val title: Text?,
|
||||
val message: Text,
|
||||
) : DialogState()
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.junit.Test
|
|||
class ResetPasswordScreenTest : BaseComposeTest() {
|
||||
private val mutableEventFlow = bufferedMutableSharedFlow<ResetPasswordEvent>()
|
||||
private val mutableStateFlow = MutableStateFlow(DEFAULT_STATE)
|
||||
val viewModel = mockk<ResetPasswordViewModel>(relaxed = true) {
|
||||
private val viewModel = mockk<ResetPasswordViewModel>(relaxed = true) {
|
||||
every { eventFlow } returns mutableEventFlow
|
||||
every { stateFlow } returns mutableStateFlow
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(
|
||||
DEFAULT_STATE.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.validation_field_required
|
||||
.asText(R.string.master_password.asText()),
|
||||
),
|
||||
|
@ -116,7 +116,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
|
|||
DEFAULT_STATE.copy(
|
||||
resetReason = ForcePasswordResetReason.ADMIN_FORCE_PASSWORD_RESET,
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.master_password_length_val_message_x
|
||||
.asText(MIN_PASSWORD_LENGTH),
|
||||
),
|
||||
|
@ -141,7 +141,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(
|
||||
DEFAULT_STATE.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.master_password_confirmation_val_message.asText(),
|
||||
),
|
||||
passwordInput = password,
|
||||
|
@ -171,7 +171,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(
|
||||
DEFAULT_STATE.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.generic_error_message.asText(),
|
||||
),
|
||||
currentPasswordInput = currentPassword,
|
||||
|
@ -203,7 +203,7 @@ class ResetPasswordViewModelTest : BaseViewModelTest() {
|
|||
assertEquals(
|
||||
DEFAULT_STATE.copy(
|
||||
dialogState = ResetPasswordState.DialogState.Error(
|
||||
title = null,
|
||||
title = R.string.an_error_has_occurred.asText(),
|
||||
message = R.string.invalid_master_password.asText(),
|
||||
),
|
||||
currentPasswordInput = currentPassword,
|
||||
|
|
Loading…
Reference in a new issue