diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt index f9a5410cd..9fc446795 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultScreen.kt @@ -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 + } +}