Simplify the usage of basic dialogs

This commit is contained in:
David Perez 2024-11-20 16:28:49 -06:00
parent 96bd25eae5
commit 2c46a8ff79
No known key found for this signature in database
GPG key ID: 3E29BD8B1BF090AC
30 changed files with 104 additions and 220 deletions

View file

@ -34,13 +34,11 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.auth.feature.accountsetup.handlers.rememberSetupAutoFillHandler
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.x8bit.bitwarden.ui.platform.components.image.BitwardenGifImage
@ -80,10 +78,8 @@ fun SetupAutoFillScreen(
when (state.dialogState) {
is SetupAutoFillDialogState.AutoFillFallbackDialog -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = R.string.bitwarden_autofill_go_to_settings.asText(),
),
title = null,
message = stringResource(id = R.string.bitwarden_autofill_go_to_settings),
onDismissRequest = handler.onDismissDialog,
)
}

View file

@ -43,7 +43,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
@ -328,10 +327,8 @@ private fun SetupUnlockScreenDialogs(
)
is SetupUnlockState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -27,10 +27,8 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -80,10 +78,11 @@ fun EnterpriseSignOnScreen(
when (val dialog = state.dialogState) {
is EnterpriseSignOnState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialog.title ?: R.string.an_error_has_occurred.asText(),
message = dialog.message,
),
title = dialog
.title
?.invoke()
?: stringResource(id = R.string.an_error_has_occurred),
message = dialog.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(EnterpriseSignOnAction.DialogDismiss) }
},

View file

@ -28,10 +28,8 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
@ -59,20 +57,15 @@ fun EnvironmentScreen(
}
}
BitwardenBasicDialog(
visibilityState = if (state.shouldShowErrorDialog) {
BasicDialogState.Shown(
title = R.string.an_error_has_occurred.asText(),
message = R.string.environment_page_urls_error.asText(),
)
} else {
BasicDialogState.Hidden
},
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(EnvironmentAction.ErrorDialogDismiss) }
},
)
if (state.shouldShowErrorDialog) {
BitwardenBasicDialog(
title = stringResource(id = R.string.an_error_has_occurred),
message = stringResource(id = R.string.environment_page_urls_error),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(EnvironmentAction.ErrorDialogDismiss) }
},
)
}
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
BitwardenScaffold(
modifier = Modifier

View file

@ -39,13 +39,11 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.platform.repository.model.Environment
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.account.BitwardenAccountSwitcher
import com.x8bit.bitwarden.ui.platform.components.account.BitwardenPlaceholderAccountActionItem
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.x8bit.bitwarden.ui.platform.components.dropdown.EnvironmentSelector
@ -111,10 +109,8 @@ fun LandingScreen(
is LandingState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.an_error_has_occurred.asText(),
message = dialog.message,
),
title = stringResource(id = R.string.an_error_has_occurred),
message = dialog.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(LandingAction.DialogDismiss) }
},

View file

@ -42,7 +42,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenOverflo
import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItemData
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -202,10 +201,8 @@ private fun LoginDialogs(
) {
when (dialogState) {
is LoginState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -36,7 +36,6 @@ import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -257,10 +256,8 @@ private fun LoginWithDeviceDialogs(
)
is LoginWithDeviceState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = state.title,
message = state.message,
),
title = state.title?.invoke(),
message = state.message(),
onDismissRequest = onDismissDialog,
)

View file

@ -21,10 +21,8 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -53,10 +51,8 @@ fun MasterPasswordHintScreen(
when (val dialogState = state.dialog) {
is MasterPasswordHintState.DialogState.PasswordHintSent -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.password_hint.asText(),
message = R.string.password_hint_alert.asText(),
),
title = stringResource(id = R.string.password_hint),
message = stringResource(id = R.string.password_hint_alert),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(MasterPasswordHintAction.DismissDialog) }
},
@ -73,10 +69,11 @@ fun MasterPasswordHintScreen(
is MasterPasswordHintState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title ?: R.string.an_error_has_occurred.asText(),
message = dialogState.message,
),
title = dialogState
.title
?.invoke()
?: stringResource(id = R.string.an_error_has_occurred),
message = dialogState.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(MasterPasswordHintAction.DismissDialog) }
},

View file

@ -28,7 +28,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -137,10 +136,8 @@ private fun RemovePasswordDialogs(
when (dialogState) {
is RemovePasswordState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)
}

View file

@ -32,7 +32,6 @@ import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetRea
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
@ -55,10 +54,8 @@ fun ResetPasswordScreen(
when (val dialog = state.dialogState) {
is ResetPasswordState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialog.title,
message = dialog.message,
),
title = dialog.title?.invoke(),
message = dialog.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(ResetPasswordAction.DialogDismiss) }
},

View file

@ -31,7 +31,6 @@ import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -191,10 +190,8 @@ private fun SetPasswordDialogs(
when (dialogState) {
is SetPasswordState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)
}

View file

@ -34,7 +34,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -215,10 +214,8 @@ private fun TrustedDeviceDialogs(
) {
when (dialogState) {
is TrustedDeviceState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = handlers.onDismissDialog,
)

View file

@ -41,13 +41,11 @@ import com.x8bit.bitwarden.ui.auth.feature.twofactorlogin.util.description
import com.x8bit.bitwarden.ui.auth.feature.twofactorlogin.util.title
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.LivecycleEventEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenOverflowActionItem
import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItemData
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -187,10 +185,11 @@ private fun TwoFactorLoginDialogs(
) {
when (dialogState) {
is TwoFactorLoginState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title ?: R.string.an_error_has_occurred.asText(),
message = dialogState.message,
),
title = dialogState
.title
?.invoke()
?: stringResource(R.string.an_error_has_occurred),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -55,7 +55,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenOverflo
import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItemData
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLogoutConfirmationDialog
@ -142,10 +141,8 @@ fun VaultUnlockScreen(
// Dynamic dialogs
when (val dialog = state.dialog) {
is VaultUnlockState.VaultUnlockDialog.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialog.title,
message = dialog.message,
),
title = dialog.title(),
message = dialog.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(VaultUnlockAction.DismissDialog) }
},
@ -157,10 +154,8 @@ fun VaultUnlockScreen(
VaultUnlockState.VaultUnlockDialog.BiometricsNoLongerSupported -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.biometrics_no_longer_supported_title.asText(),
message = R.string.biometrics_no_longer_supported.asText(),
),
title = stringResource(id = R.string.biometrics_no_longer_supported_title),
message = stringResource(id = R.string.biometrics_no_longer_supported),
onDismissRequest = remember {
{
viewModel.trySendAction(

View file

@ -25,7 +25,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenSearchTopAppBa
import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -152,10 +151,8 @@ private fun SearchDialogs(
) {
when (dialogState) {
is SearchState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -43,7 +43,6 @@ import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenActionCard
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.card.actionCardExitAnimation
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLogoutConfirmationDialog
@ -423,10 +422,8 @@ private fun AccountSecurityDialogs(
)
is AccountSecurityDialog.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)
@ -593,10 +590,8 @@ private fun SessionCustomTimeoutRow(
if (shouldShowViolatesPoliciesDialog) {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.warning.asText(),
message = R.string.vault_timeout_to_large.asText(),
),
title = stringResource(id = R.string.warning),
message = stringResource(id = R.string.vault_timeout_to_large),
onDismissRequest = {
shouldShowViolatesPoliciesDialog = false
vaultTimeoutPolicyMinutes?.let {

View file

@ -35,7 +35,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledErrorButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedErrorButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenMasterPasswordDialog
@ -74,20 +73,16 @@ fun DeleteAccountScreen(
when (val dialog = state.dialog) {
DeleteAccountState.DeleteAccountDialog.DeleteSuccess -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = R.string.your_account_has_been_permanently_deleted.asText(),
),
title = null,
message = stringResource(id = R.string.your_account_has_been_permanently_deleted),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(DeleteAccountAction.AccountDeletionConfirm) }
},
)
is DeleteAccountState.DeleteAccountDialog.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.an_error_has_occurred.asText(),
message = dialog.message,
),
title = stringResource(id = R.string.an_error_has_occurred),
message = dialog.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(DeleteAccountAction.DismissDialog) }
},

View file

@ -33,7 +33,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledErrorButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -103,20 +102,16 @@ private fun DeleteAccountConfirmationDialogs(
when (dialogState) {
is DeleteAccountConfirmationState.DeleteAccountConfirmationDialog.DeleteSuccess -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = dialogState.message,
),
title = null,
message = dialogState.message(),
onDismissRequest = onDeleteAccountAcknowledge,
)
}
is DeleteAccountConfirmationState.DeleteAccountConfirmationDialog.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title(),
message = dialogState.message(),
onDismissRequest = onDismissDialog,
)
}

View file

@ -36,7 +36,6 @@ import com.x8bit.bitwarden.ui.platform.components.button.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.x8bit.bitwarden.ui.platform.components.scaffold.BitwardenScaffold
@ -295,10 +294,8 @@ private fun LoginApprovalDialogs(
)
is LoginApprovalState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = state.title,
message = state.message,
),
title = state.title?.invoke(),
message = state.message(),
onDismissRequest = onDismissError,
)

View file

@ -31,13 +31,11 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.platform.repository.model.UriMatchType
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.badge.NotificationBadge
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenActionCard
import com.x8bit.bitwarden.ui.platform.components.card.actionCardExitAnimation
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenSelectionDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
@ -102,10 +100,8 @@ fun AutoFillScreen(
if (shouldShowAutofillFallbackDialog) {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = R.string.bitwarden_autofill_go_to_settings.asText(),
),
title = null,
message = stringResource(id = R.string.bitwarden_autofill_go_to_settings),
onDismissRequest = { shouldShowAutofillFallbackDialog = false },
)
}

View file

@ -38,7 +38,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenOutlinedButton
import com.x8bit.bitwarden.ui.platform.components.card.BitwardenInfoCalloutCard
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
@ -123,10 +122,8 @@ fun ExportVaultScreen(
when (val dialog = state.dialogState) {
is ExportVaultState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialog.title,
message = dialog.message,
),
title = dialog.title?.invoke(),
message = dialog.message(),
onDismissRequest = remember(viewModel) {
{ viewModel.trySendAction(ExportVaultAction.DialogDismiss) }
},

View file

@ -24,14 +24,12 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenOverflowActionItem
import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItemData
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
@ -172,10 +170,8 @@ private fun FolderAddEditItemDialogs(
}
is FolderAddEditState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.an_error_has_occurred.asText(),
message = dialogState.message,
),
title = stringResource(id = R.string.an_error_has_occurred),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -28,7 +28,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenSearchA
import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItemData
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -200,10 +199,8 @@ private fun SendDialogs(
) {
when (dialogState) {
is SendState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -31,7 +31,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItem
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialog
@ -254,10 +253,8 @@ private fun AddSendDialogs(
) {
when (dialogState) {
is AddSendState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -23,7 +23,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.autofill.fido2.manager.Fido2CompletionManager
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon
import com.x8bit.bitwarden.ui.platform.components.appbar.action.BitwardenOverflowActionItem
@ -31,7 +30,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItem
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenMasterPasswordDialog
@ -386,30 +384,24 @@ private fun VaultAddEditItemDialogs(
is VaultAddEditState.DialogState.Generic -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)
}
is VaultAddEditState.DialogState.InitialAutofillPrompt -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.bitwarden_autofill_service.asText(),
message = R.string.bitwarden_autofill_service_alert2.asText(),
),
title = stringResource(id = R.string.bitwarden_autofill_service),
message = stringResource(id = R.string.bitwarden_autofill_service_alert2),
onDismissRequest = onAutofillDismissRequest,
)
}
is VaultAddEditState.DialogState.Fido2Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.an_error_has_occurred.asText(),
message = dialogState.message,
),
title = stringResource(id = R.string.an_error_has_occurred),
message = dialogState.message(),
onDismissRequest = onFido2ErrorDismiss,
)
}
@ -430,10 +422,8 @@ private fun VaultAddEditItemDialogs(
is VaultAddEditState.DialogState.Fido2MasterPasswordError -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = R.string.invalid_master_password.asText(),
),
title = null,
message = stringResource(id = R.string.invalid_master_password),
onDismissRequest = onRetryFido2PasswordVerification,
)
}
@ -447,10 +437,8 @@ private fun VaultAddEditItemDialogs(
is VaultAddEditState.DialogState.Fido2PinError -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = R.string.invalid_pin.asText(),
),
title = null,
message = stringResource(id = R.string.invalid_pin),
onDismissRequest = onRetryFido2PinVerification,
)
}
@ -465,9 +453,10 @@ private fun VaultAddEditItemDialogs(
is VaultAddEditState.DialogState.Fido2PinSetUpError -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = R.string.validation_field_required.asText(R.string.pin.asText()),
title = null,
message = stringResource(
id = R.string.validation_field_required,
stringResource(id = R.string.pin),
),
onDismissRequest = onRetryPinSetUpFido2Verification,
)

View file

@ -22,7 +22,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.NavigationIcon
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -124,10 +123,8 @@ private fun AttachmentsDialogs(
) {
when (dialogState) {
is AttachmentsState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -30,7 +30,6 @@ import com.x8bit.bitwarden.ui.platform.components.appbar.action.OverflowMenuItem
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenMasterPasswordDialog
@ -291,10 +290,8 @@ private fun VaultItemDialogs(
) {
when (dialog) {
is VaultItemState.DialogState.Generic -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = null,
message = dialog.message,
),
title = null,
message = dialog.message(),
onDismissRequest = onDismissRequest,
)

View file

@ -306,10 +306,8 @@ private fun VaultItemListingDialogs(
)
is VaultItemListingState.DialogState.Fido2OperationFail -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title(),
message = dialogState.message(),
onDismissRequest = onDismissFido2ErrorDialog,
)
@ -334,10 +332,8 @@ private fun VaultItemListingDialogs(
is VaultItemListingState.DialogState.Fido2MasterPasswordError -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = {
onRetryFido2PasswordVerification(dialogState.selectedCipherId)
},
@ -358,10 +354,8 @@ private fun VaultItemListingDialogs(
is VaultItemListingState.DialogState.Fido2PinError -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = {
onRetryFido2PinVerification(dialogState.selectedCipherId)
},
@ -380,10 +374,8 @@ private fun VaultItemListingDialogs(
is VaultItemListingState.DialogState.Fido2PinSetUpError -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title?.invoke(),
message = dialogState.message(),
onDismissRequest = {
onRetryPinSetUpFido2Verification(dialogState.selectedCipherId)
},

View file

@ -18,12 +18,10 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.appbar.BitwardenTopAppBar
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenTextButton
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.LoadingDialogState
@ -85,10 +83,8 @@ private fun VaultMoveToOrganizationScaffold(
when (val dialog = state.dialogState) {
is VaultMoveToOrganizationState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = R.string.an_error_has_occurred.asText(),
message = dialog.message,
),
title = stringResource(id = R.string.an_error_has_occurred),
message = dialog.message(),
onDismissRequest = dismissClick,
)
}

View file

@ -40,7 +40,6 @@ import com.x8bit.bitwarden.ui.platform.components.card.BitwardenActionCard
import com.x8bit.bitwarden.ui.platform.components.card.actionCardExitAnimation
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenErrorContent
import com.x8bit.bitwarden.ui.platform.components.content.BitwardenLoadingContent
import com.x8bit.bitwarden.ui.platform.components.dialog.BasicDialogState
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenLoadingDialog
import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenMasterPasswordDialog
@ -358,10 +357,8 @@ private fun VaultDialogs(
)
is VaultState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
title = dialogState.title(),
message = dialogState.message(),
onDismissRequest = vaultHandlers.dialogDismiss,
)