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) onDimBottomNavBarRequest(shouldShowMenu)
} }
var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) } var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) }
val scrollBehavior = val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
state = rememberTopAppBarState(), state = rememberTopAppBarState(),
canScroll = { !accountMenuVisible }, canScroll = { !accountMenuVisible },
) )
// Dynamic dialogs // Dynamic dialogs
when (val dialog = state.dialog) { VaultDialogs(dialogState = state.dialog, vaultHandlers = vaultHandlers)
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
}
// Static dialogs // Static dialogs
if (shouldShowExitConfirmationDialog) { 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
}
}