mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
Clean up VaultScreen Dialogs (#1356)
This commit is contained in:
parent
2d80a215c5
commit
8e1ecd1e6c
1 changed files with 29 additions and 26 deletions
|
@ -173,34 +173,13 @@ private fun VaultScreenScaffold(
|
|||
onDimBottomNavBarRequest(shouldShowMenu)
|
||||
}
|
||||
var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
||||
val scrollBehavior =
|
||||
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue