Clean up VaultScreen Dialogs (#1356)

This commit is contained in:
David Perez 2024-05-10 12:59:21 -05:00 committed by Álison Fernandes
parent 2d80a215c5
commit 8e1ecd1e6c

View file

@ -173,34 +173,13 @@ private fun VaultScreenScaffold(
onDimBottomNavBarRequest(shouldShowMenu)
}
var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) }
val scrollBehavior =
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
state = rememberTopAppBarState(),
canScroll = { !accountMenuVisible },
)
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
state = rememberTopAppBarState(),
canScroll = { !accountMenuVisible },
)
// Dynamic dialogs
when (val dialog = state.dialog) {
is VaultState.DialogState.Syncing -> {
BitwardenLoadingDialog(
visibilityState = LoadingDialogState.Shown(
text = R.string.syncing.asText(),
),
)
}
is VaultState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialog.title,
message = dialog.message,
),
onDismissRequest = vaultHandlers.dialogDismiss,
)
}
null -> Unit
}
VaultDialogs(dialogState = state.dialog, vaultHandlers = vaultHandlers)
// Static dialogs
if (shouldShowExitConfirmationDialog) {
@ -355,3 +334,27 @@ private fun VaultScreenScaffold(
}
}
}
@Composable
private fun VaultDialogs(
dialogState: VaultState.DialogState?,
vaultHandlers: VaultHandlers,
) {
when (dialogState) {
is VaultState.DialogState.Syncing -> BitwardenLoadingDialog(
visibilityState = LoadingDialogState.Shown(
text = R.string.syncing.asText(),
),
)
is VaultState.DialogState.Error -> BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialogState.title,
message = dialogState.message,
),
onDismissRequest = vaultHandlers.dialogDismiss,
)
null -> Unit
}
}