mirror of
https://github.com/bitwarden/android.git
synced 2025-01-08 09:17:36 +03:00
Wire up button
This commit is contained in:
parent
b0194028a8
commit
3bed0f0804
4 changed files with 68 additions and 14 deletions
|
@ -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,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 = {},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.intent.IntentManager
|
||||||
import com.x8bit.bitwarden.ui.platform.manager.permissions.PermissionsManager
|
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.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.handlers.VaultHandlers
|
||||||
|
import com.x8bit.bitwarden.ui.vault.feature.vault.model.NotificationSummary
|
||||||
import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType
|
import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
|
@ -181,6 +184,13 @@ private fun VaultScreenScaffold(
|
||||||
accountMenuVisible = shouldShowMenu
|
accountMenuVisible = shouldShowMenu
|
||||||
onDimBottomNavBarRequest(shouldShowMenu)
|
onDimBottomNavBarRequest(shouldShowMenu)
|
||||||
}
|
}
|
||||||
|
var notificationMenuVisible by rememberSaveable {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
val updateNotificationMenuVisibility = { shouldShowMenu: Boolean ->
|
||||||
|
notificationMenuVisible = shouldShowMenu
|
||||||
|
onDimBottomNavBarRequest(shouldShowMenu)
|
||||||
|
}
|
||||||
var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
var shouldShowExitConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(
|
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(
|
||||||
state = rememberTopAppBarState(),
|
state = rememberTopAppBarState(),
|
||||||
|
@ -231,6 +241,11 @@ private fun VaultScreenScaffold(
|
||||||
?.let { TopAppBarDividerStyle.STATIC }
|
?.let { TopAppBarDividerStyle.STATIC }
|
||||||
?: TopAppBarDividerStyle.ON_SCROLL,
|
?: TopAppBarDividerStyle.ON_SCROLL,
|
||||||
actions = {
|
actions = {
|
||||||
|
NotificationCenterActionItem(
|
||||||
|
onClick = {
|
||||||
|
updateNotificationMenuVisibility(!notificationMenuVisible)
|
||||||
|
},
|
||||||
|
)
|
||||||
BitwardenAccountActionItem(
|
BitwardenAccountActionItem(
|
||||||
initials = state.initials,
|
initials = state.initials,
|
||||||
color = state.avatarColor,
|
color = state.avatarColor,
|
||||||
|
@ -360,6 +375,15 @@ private fun VaultScreenScaffold(
|
||||||
topAppBarScrollBehavior = scrollBehavior,
|
topAppBarScrollBehavior = scrollBehavior,
|
||||||
modifier = outerModifier,
|
modifier = outerModifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
NotificationCenter(
|
||||||
|
isVisible = notificationMenuVisible,
|
||||||
|
notificationSummaries = state.notificationSummaries.toImmutableList(),
|
||||||
|
onNotificationClick = {},
|
||||||
|
onDismissRequest = { updateAccountMenuVisibility(false) },
|
||||||
|
topAppBarScrollBehavior = scrollBehavior,
|
||||||
|
modifier = outerModifier,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.IconData
|
||||||
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
|
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.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.VaultFilterData
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
|
import com.x8bit.bitwarden.ui.vault.feature.vault.model.VaultFilterType
|
||||||
import com.x8bit.bitwarden.ui.vault.feature.vault.util.initials
|
import com.x8bit.bitwarden.ui.vault.feature.vault.util.initials
|
||||||
|
@ -75,6 +76,7 @@ class VaultViewModel @Inject constructor(
|
||||||
initialState = run {
|
initialState = run {
|
||||||
val userState = requireNotNull(authRepository.userStateFlow.value)
|
val userState = requireNotNull(authRepository.userStateFlow.value)
|
||||||
val accountSummaries = userState.toAccountSummaries()
|
val accountSummaries = userState.toAccountSummaries()
|
||||||
|
val notificationSummaries = listOf<NotificationSummary>()
|
||||||
val activeAccountSummary = userState.toActiveAccountSummary()
|
val activeAccountSummary = userState.toActiveAccountSummary()
|
||||||
val vaultFilterData = userState.activeAccount.toVaultFilterData(
|
val vaultFilterData = userState.activeAccount.toVaultFilterData(
|
||||||
isIndividualVaultDisabled = policyManager
|
isIndividualVaultDisabled = policyManager
|
||||||
|
@ -87,6 +89,7 @@ class VaultViewModel @Inject constructor(
|
||||||
initials = activeAccountSummary.initials,
|
initials = activeAccountSummary.initials,
|
||||||
avatarColorString = activeAccountSummary.avatarColorHex,
|
avatarColorString = activeAccountSummary.avatarColorHex,
|
||||||
accountSummaries = accountSummaries,
|
accountSummaries = accountSummaries,
|
||||||
|
notificationSummaries = notificationSummaries,
|
||||||
vaultFilterData = vaultFilterData,
|
vaultFilterData = vaultFilterData,
|
||||||
viewState = VaultState.ViewState.Loading,
|
viewState = VaultState.ViewState.Loading,
|
||||||
isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled,
|
isIconLoadingDisabled = settingsRepository.isIconLoadingDisabled,
|
||||||
|
@ -655,6 +658,7 @@ data class VaultState(
|
||||||
private val avatarColorString: String,
|
private val avatarColorString: String,
|
||||||
val initials: String,
|
val initials: String,
|
||||||
val accountSummaries: List<AccountSummary>,
|
val accountSummaries: List<AccountSummary>,
|
||||||
|
val notificationSummaries: List<NotificationSummary>,
|
||||||
val vaultFilterData: VaultFilterData? = null,
|
val vaultFilterData: VaultFilterData? = null,
|
||||||
val viewState: ViewState,
|
val viewState: ViewState,
|
||||||
val dialog: DialogState? = null,
|
val dialog: DialogState? = null,
|
||||||
|
|
Loading…
Reference in a new issue