diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt index 3285eb877..32a5b037c 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreen.kt @@ -496,19 +496,6 @@ private fun VaultItemListingScaffold( } } - BitwardenAccountSwitcher( - isVisible = isAccountMenuVisible, - accountSummaries = state.accountSummaries.toImmutableList(), - onSwitchAccountClick = vaultItemListingHandlers.switchAccountClick, - onLockAccountClick = vaultItemListingHandlers.lockAccountClick, - onLogoutAccountClick = vaultItemListingHandlers.logoutAccountClick, - onAddAccountClick = { - // Not available - }, - onDismissRequest = { isAccountMenuVisible = false }, - isAddAccountAvailable = false, - topAppBarScrollBehavior = scrollBehavior, - modifier = modifier, - ) + } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/unsyncedvaultitem/NotificationCenterActionItem.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/unsyncedvaultitem/NotificationCenterActionItem.kt new file mode 100644 index 000000000..9996b16c3 --- /dev/null +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/unsyncedvaultitem/NotificationCenterActionItem.kt @@ -0,0 +1,39 @@ +package com.x8bit.bitwarden.ui.vault.feature.unsyncedvaultitem + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import com.x8bit.bitwarden.R +import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton +import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme + +/** + * Displays an icon representing the Notification Center + * + * @param onClick An action to be invoked when the icon is clicked. + */ +@Composable +fun NotificationCenterActionItem( + onClick: () -> Unit, +) { + val contentDescription = stringResource(id = R.string.account) + + BitwardenStandardIconButton( + vectorIconRes = R.drawable.ic_search, + contentDescription = contentDescription, + onClick = onClick, + modifier = Modifier.testTag(tag = "NotificationCenter"), + ) +} + +@Preview(showBackground = true) +@Composable +private fun NotificationCenterActionItem_preview() { + BitwardenTheme { + NotificationCenterActionItem ( + onClick = {}, + ) + } +} 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 4ab87e99a..c406350b8 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 @@ -64,7 +64,10 @@ import com.x8bit.bitwarden.ui.platform.manager.exit.ExitManager import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction +import com.x8bit.bitwarden.ui.vault.feature.unsyncedvaultitem.NotificationCenter +import com.x8bit.bitwarden.ui.vault.feature.unsyncedvaultitem.NotificationCenterActionItem import com.x8bit.bitwarden.ui.vault.feature.vault.handlers.VaultHandlers +import com.x8bit.bitwarden.ui.vault.feature.vault.model.NotificationSummary import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -181,6 +184,13 @@ private fun VaultScreenScaffold( accountMenuVisible = shouldShowMenu onDimBottomNavBarRequest(shouldShowMenu) } + var notificationMenuVisible by rememberSaveable { + mutableStateOf(false) + } + val updateNotificationMenuVisibility = { shouldShowMenu: Boolean -> + notificationMenuVisible = shouldShowMenu + onDimBottomNavBarRequest(shouldShowMenu) + } var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) } val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior( state = rememberTopAppBarState(), @@ -231,6 +241,11 @@ private fun VaultScreenScaffold( ?.let { TopAppBarDividerStyle.STATIC } ?: TopAppBarDividerStyle.ON_SCROLL, actions = { + NotificationCenterActionItem( + onClick = { + updateNotificationMenuVisibility(!notificationMenuVisible) + }, + ) BitwardenAccountActionItem( initials = state.initials, color = state.avatarColor, @@ -360,6 +375,15 @@ private fun VaultScreenScaffold( topAppBarScrollBehavior = scrollBehavior, modifier = outerModifier, ) + + NotificationCenter( + isVisible = notificationMenuVisible, + notificationSummaries = state.notificationSummaries.toImmutableList(), + onNotificationClick = {}, + onDismissRequest = { updateAccountMenuVisibility(false) }, + topAppBarScrollBehavior = scrollBehavior, + modifier = outerModifier, + ) } } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt index c03f75d9d..6f0715a3a 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/vault/VaultViewModel.kt @@ -33,6 +33,7 @@ import com.x8bit.bitwarden.ui.platform.components.model.AccountSummary import com.x8bit.bitwarden.ui.platform.components.model.IconData import com.x8bit.bitwarden.ui.platform.components.model.IconRes import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction +import com.x8bit.bitwarden.ui.vault.feature.vault.model.NotificationSummary import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterData import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType import com.x8bit.bitwarden.ui.vault.feature.vault.util.initials @@ -75,6 +76,7 @@ class VaultViewModel @Inject constructor( initialState = run { val userState = requireNotNull(authRepository.userStateFlow.value) val accountSummaries = userState.toAccountSummaries() + val notificationSummaries = listOf() val activeAccountSummary = userState.toActiveAccountSummary() val vaultFilterData = userState.activeAccount.toVaultFilterData( isIndividualVaultDisabled = policyManager @@ -87,6 +89,7 @@ class VaultViewModel @Inject constructor( initials = activeAccountSummary.initials, avatarColorString = activeAccountSummary.avatarColorHex, accountSummaries = accountSummaries, + notificationSummaries = notificationSummaries, vaultFilterData = vaultFilterData, viewState = VaultState.ViewState.Loading, isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled, @@ -655,6 +658,7 @@ data class VaultState( private val avatarColorString: String, val initials: String, val accountSummaries: List, + val notificationSummaries: List, val vaultFilterData: VaultFilterData? = null, val viewState: ViewState, val dialog: DialogState? = null,