PM-19807: Remove IconResource class (#4963)

This commit is contained in:
David Perez
2025-04-02 15:21:58 +00:00
committed by GitHub
parent b82b1ad570
commit 8e7de92609
28 changed files with 161 additions and 224 deletions
@@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
@@ -62,8 +61,9 @@ import com.x8bit.bitwarden.ui.platform.components.divider.BitwardenHorizontalDiv
import com.x8bit.bitwarden.ui.platform.components.field.color.bitwardenTextFieldColors
import com.x8bit.bitwarden.ui.platform.components.field.toolbar.BitwardenCutCopyTextToolbar
import com.x8bit.bitwarden.ui.platform.components.field.toolbar.BitwardenEmptyTextToolbar
import com.x8bit.bitwarden.ui.platform.components.icon.BitwardenIcon
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.model.TextToolbarType
import com.x8bit.bitwarden.ui.platform.components.model.TooltipData
import com.x8bit.bitwarden.ui.platform.components.row.BitwardenRowOfActions
@@ -83,7 +83,7 @@ import kotlinx.collections.immutable.toImmutableList
* @param tooltip the optional tooltip to be displayed in the label.
* @param placeholder the optional placeholder to be displayed when the text field is in focus and
* the [value] is empty.
* @param leadingIconResource the optional resource for the leading icon on the text field.
* @param leadingIconData the optional resource for the leading icon on the text field.
* @param supportingText optional supporting text that will appear below the text input.
* @param singleLine when `true`, this text field becomes a single line that horizontally scrolls
* instead of wrapping onto multiple lines.
@@ -112,7 +112,7 @@ fun BitwardenTextField(
modifier: Modifier = Modifier,
tooltip: TooltipData? = null,
placeholder: String? = null,
leadingIconResource: IconResource? = null,
leadingIconData: IconData? = null,
supportingText: String? = null,
singleLine: Boolean = true,
readOnly: Boolean = false,
@@ -137,7 +137,7 @@ fun BitwardenTextField(
onValueChange = onValueChange,
tooltip = tooltip,
placeholder = placeholder,
leadingIconResource = leadingIconResource,
leadingIconData = leadingIconData,
supportingContent = supportingText?.let {
{
Text(
@@ -181,7 +181,7 @@ fun BitwardenTextField(
* @param supportingContentPadding The padding to be placed on the [supportingContent].
* @param placeholder the optional placeholder to be displayed when the text field is in focus and
* the [value] is empty.
* @param leadingIconResource the optional resource for the leading icon on the text field.
* @param leadingIconData the optional resource for the leading icon on the text field.
* @param singleLine when `true`, this text field becomes a single line that horizontally scrolls
* instead of wrapping onto multiple lines.
* @param readOnly `true` if the input should be read-only and not accept user interactions.
@@ -212,7 +212,7 @@ fun BitwardenTextField(
tooltip: TooltipData? = null,
supportingContentPadding: PaddingValues = PaddingValues(vertical = 12.dp, horizontal = 16.dp),
placeholder: String? = null,
leadingIconResource: IconResource? = null,
leadingIconData: IconData? = null,
singleLine: Boolean = true,
readOnly: Boolean = false,
enabled: Boolean = true,
@@ -321,11 +321,11 @@ fun BitwardenTextField(
}
},
value = textFieldValue,
leadingIcon = leadingIconResource?.let { iconResource ->
leadingIcon = leadingIconData?.let { iconData ->
{
Icon(
painter = iconResource.iconPainter,
contentDescription = iconResource.contentDescription,
BitwardenIcon(
iconData = iconData,
tint = BitwardenTheme.colorScheme.icon.primary,
)
}
},
@@ -7,6 +7,7 @@ import androidx.compose.ui.graphics.Color
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.bumptech.glide.integration.compose.placeholder
import com.x8bit.bitwarden.ui.platform.base.util.nullableTestTag
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
@@ -16,7 +17,6 @@ import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
* @param iconData Label for the text field.
* @param tint the color to be applied as the tint for the icon.
* @param modifier A [Modifier] for the composable.
* @param contentDescription A description of the switch's UI for accessibility purposes.
*/
@OptIn(ExperimentalGlideComposeApi::class)
@Composable
@@ -24,15 +24,14 @@ fun BitwardenIcon(
iconData: IconData,
tint: Color,
modifier: Modifier = Modifier,
contentDescription: String? = null,
) {
when (iconData) {
is IconData.Network -> {
GlideImage(
model = iconData.uri,
failure = placeholder(iconData.fallbackIconRes),
contentDescription = contentDescription,
modifier = modifier,
contentDescription = iconData.contentDescription?.invoke(),
modifier = modifier.nullableTestTag(tag = iconData.testTag),
) {
it.placeholder(iconData.fallbackIconRes)
}
@@ -41,9 +40,9 @@ fun BitwardenIcon(
is IconData.Local -> {
Icon(
painter = rememberVectorPainter(id = iconData.iconRes),
contentDescription = contentDescription,
contentDescription = iconData.contentDescription?.invoke(),
tint = tint,
modifier = modifier,
modifier = modifier.nullableTestTag(tag = iconData.testTag),
)
}
}
@@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -32,7 +31,6 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.row.BitwardenBasicDialo
import com.x8bit.bitwarden.ui.platform.components.icon.BitwardenIcon
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
@@ -74,7 +72,7 @@ fun BitwardenListItem(
supportingLabel: String? = null,
supportingLabelTestTag: String? = null,
startIconTestTag: String? = null,
trailingLabelIcons: ImmutableList<IconResource> = persistentListOf(),
trailingLabelIcons: ImmutableList<IconData> = persistentListOf(),
) {
var shouldShowDialog by rememberSaveable { mutableStateOf(false) }
Row(
@@ -91,7 +89,6 @@ fun BitwardenListItem(
) {
BitwardenIcon(
iconData = startIcon,
contentDescription = null,
tint = BitwardenTheme.colorScheme.icon.primary,
modifier = Modifier
.nullableTestTag(tag = startIconTestTag)
@@ -113,15 +110,12 @@ fun BitwardenListItem(
.weight(weight = 1f, fill = false),
)
trailingLabelIcons.forEach { iconResource ->
trailingLabelIcons.forEach { iconData ->
Spacer(modifier = Modifier.width(8.dp))
Icon(
painter = iconResource.iconPainter,
contentDescription = iconResource.contentDescription,
BitwardenIcon(
iconData = iconData,
tint = BitwardenTheme.colorScheme.icon.primary,
modifier = Modifier
.nullableTestTag(tag = iconResource.testTag)
.size(size = 16.dp),
modifier = Modifier.size(size = 16.dp),
)
}
}
@@ -1,13 +1,26 @@
package com.x8bit.bitwarden.ui.platform.components.model
import android.os.Parcelable
import androidx.annotation.DrawableRes
import com.x8bit.bitwarden.ui.platform.base.util.Text
import kotlinx.parcelize.Parcelize
/**
* A class to denote the type of icon being passed.
*/
@Parcelize
sealed class IconData : Parcelable {
/**
* The icon content description.
*/
abstract val contentDescription: Text?
/**
* The icon test tag.
*/
abstract val testTag: String?
/**
* Data class representing the resources required for an icon.
*
@@ -15,7 +28,9 @@ sealed class IconData : Parcelable {
*/
@Parcelize
data class Local(
val iconRes: Int,
@DrawableRes val iconRes: Int,
override val contentDescription: Text? = null,
override val testTag: String? = null,
) : IconData()
/**
@@ -27,6 +42,8 @@ sealed class IconData : Parcelable {
@Parcelize
data class Network(
val uri: String,
val fallbackIconRes: Int,
@DrawableRes val fallbackIconRes: Int,
override val contentDescription: Text? = null,
override val testTag: String? = null,
) : IconData()
}
@@ -1,54 +0,0 @@
package com.x8bit.bitwarden.ui.platform.components.model
import android.os.Parcelable
import androidx.annotation.DrawableRes
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.painter.Painter
import com.x8bit.bitwarden.ui.platform.base.util.Text
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import kotlinx.parcelize.Parcelize
/**
* Data class representing the resources required for an icon.
*
* @property iconPainter Painter for the icon.
* @property contentDescription String for the icon's content description.
* @property testTag The optional test tag to associate with this icon.
*/
data class IconResource(
val iconPainter: Painter,
val contentDescription: String,
val testTag: String? = null,
)
/**
* Data class representing the resources required for an icon and is friendly to use in ViewModels.
*
* @property iconRes Resource for the icon.
* @property contentDescription The icon's content description.
* @property testTag The optional test tag to associate with this icon.
*/
@Parcelize
data class IconRes(
@DrawableRes
val iconRes: Int,
val contentDescription: Text,
val testTag: String? = null,
) : Parcelable
/**
* A helper method to convert a list of [IconRes] to a list of [IconResource].
*/
@Composable
fun List<IconRes>.toIconResources(): List<IconResource> = this.map { it.toIconResource() }
/**
* A helper method to convert an [IconRes] to an [IconResource].
*/
@Composable
fun IconRes.toIconResource(): IconResource =
IconResource(
iconPainter = rememberVectorPainter(id = iconRes),
contentDescription = contentDescription(),
testTag = testTag,
)
@@ -25,7 +25,6 @@ import com.x8bit.bitwarden.ui.platform.components.dialog.BitwardenTwoButtonDialo
import com.x8bit.bitwarden.ui.platform.components.dialog.row.BitwardenBasicDialogRow
import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenListItem
import com.x8bit.bitwarden.ui.platform.components.listitem.SelectionItemData
import com.x8bit.bitwarden.ui.platform.components.model.toIconResources
import com.x8bit.bitwarden.ui.platform.feature.search.handlers.SearchHandlers
import com.x8bit.bitwarden.ui.platform.feature.search.model.AutofillSelectionOption
import com.x8bit.bitwarden.ui.platform.feature.search.util.searchItemTestTag
@@ -130,10 +129,7 @@ fun SearchContent(
searchHandlers.onItemClick(it.id, it.cipherType)
}
},
trailingLabelIcons = it
.extraIconList
.toIconResources()
.toPersistentList(),
trailingLabelIcons = it.extraIconList,
selectionDataList = it
.overflowOptions
.map { option ->
@@ -38,7 +38,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.Text
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.concat
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.feature.search.model.AutofillSelectionOption
import com.x8bit.bitwarden.ui.platform.feature.search.model.SearchType
import com.x8bit.bitwarden.ui.platform.feature.search.util.filterAndOrganize
@@ -54,6 +53,7 @@ import com.x8bit.bitwarden.ui.vault.model.TotpData
import com.x8bit.bitwarden.ui.vault.model.VaultItemCipherType
import com.x8bit.bitwarden.ui.vault.util.toVaultItemCipherType
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
@@ -884,7 +884,7 @@ data class SearchState(
val subtitleTestTag: String,
val totpCode: String?,
val iconData: IconData,
val extraIconList: List<IconRes>,
val extraIconList: ImmutableList<IconData>,
val overflowOptions: List<ListingItemOverflowAction>,
val overflowTestTag: String?,
val autofillSelectionOptions: List<AutofillSelectionOption>,
@@ -22,7 +22,6 @@ import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.tools.feature.send.handlers.SendHandlers
import kotlinx.collections.immutable.toImmutableList
private const val SEND_TYPES_COUNT: Int = 2
@@ -112,7 +111,7 @@ fun SendContent(
startIcon = IconData.Local(it.type.iconRes),
label = it.name,
supportingLabel = it.deletionDate,
trailingLabelIcons = it.iconList.toImmutableList(),
trailingLabelIcons = it.iconList,
showMoreOptions = !policyDisablesSend,
onClick = { sendHandlers.onSendClick(it) },
onCopyClick = { sendHandlers.onCopySendClick(it) },
@@ -15,9 +15,6 @@ import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenListItem
import com.x8bit.bitwarden.ui.platform.components.listitem.SelectionItemData
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
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.IconResource
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.platform.util.persistentListOfNotNull
import kotlinx.collections.immutable.ImmutableList
@@ -48,7 +45,7 @@ fun SendListItem(
label: String,
supportingLabel: String,
startIcon: IconData,
trailingLabelIcons: ImmutableList<IconRes>,
trailingLabelIcons: ImmutableList<IconData>,
showMoreOptions: Boolean,
onClick: () -> Unit,
onEditClick: () -> Unit,
@@ -64,14 +61,7 @@ fun SendListItem(
label = label,
supportingLabel = supportingLabel,
startIcon = startIcon,
trailingLabelIcons = trailingLabelIcons
.map {
IconResource(
iconPainter = rememberVectorPainter(it.iconRes),
contentDescription = it.contentDescription(),
)
}
.toPersistentList(),
trailingLabelIcons = trailingLabelIcons,
onClick = onClick,
selectionDataList = persistentListOfNotNull(
SelectionItemData(
@@ -20,10 +20,11 @@ import com.x8bit.bitwarden.data.vault.repository.model.SendData
import com.x8bit.bitwarden.ui.platform.base.BaseViewModel
import com.x8bit.bitwarden.ui.platform.base.util.Text
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.tools.feature.send.util.toViewState
import com.x8bit.bitwarden.ui.vault.feature.item.VaultItemScreen
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
@@ -409,7 +410,7 @@ data class SendState(
val name: String,
val deletionDate: String,
val type: Type,
val iconList: List<IconRes>,
val iconList: ImmutableList<IconData>,
val shareUrl: String,
val hasPassword: Boolean,
) : Parcelable {
@@ -1,15 +1,17 @@
package com.x8bit.bitwarden.ui.tools.feature.send.util
import com.bitwarden.send.SendView
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.tools.feature.send.model.SendStatusIcon
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import java.time.Clock
/**
* Creates the list of trailing label icons to be displayed for a [SendView].
*/
fun SendView.toLabelIcons(clock: Clock = Clock.systemDefaultZone()): List<IconRes> =
fun SendView.toLabelIcons(clock: Clock = Clock.systemDefaultZone()): ImmutableList<IconData> =
listOfNotNull(
SendStatusIcon.DISABLED.takeIf { disabled },
SendStatusIcon.PASSWORD.takeIf { hasPassword },
@@ -20,12 +22,13 @@ fun SendView.toLabelIcons(clock: Clock = Clock.systemDefaultZone()): List<IconRe
SendStatusIcon.PENDING_DELETE.takeIf { deletionDate.isBefore(clock.instant()) },
)
.map {
IconRes(
IconData.Local(
iconRes = it.iconRes,
contentDescription = it.contentDescription,
testTag = it.testTag,
)
}
.toImmutableList()
/**
* Creates the list of overflow actions to be displayed for a [SendView].
@@ -299,7 +299,6 @@ private fun ItemHeaderIcon(
) {
BitwardenIcon(
iconData = iconData,
contentDescription = null,
tint = if (applyBackgroundFill) {
BitwardenTheme.colorScheme.illustration.outline
} else {
@@ -5,13 +5,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordField
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.vault.feature.item.VaultItemState
/**
@@ -84,9 +84,9 @@ fun CustomField(
BitwardenTextField(
label = customField.name,
value = customField.vaultLinkedFieldType.label.invoke(),
leadingIconResource = IconResource(
iconPainter = rememberVectorPainter(id = R.drawable.ic_linked),
contentDescription = stringResource(id = R.string.field_type_linked),
leadingIconData = IconData.Local(
iconRes = R.drawable.ic_linked,
contentDescription = R.string.field_type_linked.asText(),
),
onValueChange = { },
readOnly = true,
@@ -27,7 +27,6 @@ import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenGroupItem
import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenListItem
import com.x8bit.bitwarden.ui.platform.components.listitem.SelectionItemData
import com.x8bit.bitwarden.ui.platform.components.model.toIconResources
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.toPersistentList
@@ -226,10 +225,7 @@ fun VaultItemListingContent(
vaultItemClick(it.id, it.type)
}
},
trailingLabelIcons = it
.extraIconList
.toIconResources()
.toPersistentList(),
trailingLabelIcons = it.extraIconList,
selectionDataList = it
.overflowOptions
.map { option ->
@@ -62,7 +62,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.toAndroidAppUriString
import com.x8bit.bitwarden.ui.platform.base.util.toHostOrPathOrNull
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.platform.feature.search.SearchTypeData
import com.x8bit.bitwarden.ui.platform.feature.search.model.SearchType
import com.x8bit.bitwarden.ui.platform.feature.search.util.filterAndOrganize
@@ -2215,7 +2214,7 @@ data class VaultItemListingState(
val subtitleTestTag: String,
val iconData: IconData,
val iconTestTag: String?,
val extraIconList: List<IconRes>,
val extraIconList: ImmutableList<IconData>,
val overflowOptions: List<ListingItemOverflowAction>,
val optionsTestTag: String,
val isAutofill: Boolean,
@@ -2,9 +2,11 @@ package com.x8bit.bitwarden.ui.vault.feature.util
import com.bitwarden.vault.CipherType
import com.bitwarden.vault.CipherView
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import com.x8bit.bitwarden.ui.vault.model.VaultTrailingIcon
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
/**
* Creates the list of overflow actions to be displayed for a [CipherView].
@@ -71,7 +73,7 @@ fun CipherView.toOverflowActions(
/**
* Checks if the list is empty and if not returns an icon in a list.
*/
fun CipherView.toLabelIcons(): List<IconRes> {
fun CipherView.toLabelIcons(): ImmutableList<IconData> {
return listOfNotNull(
VaultTrailingIcon.COLLECTION.takeIf {
this.collectionIds.isNotEmpty() || this.organizationId?.isNotEmpty() == true
@@ -79,10 +81,11 @@ fun CipherView.toLabelIcons(): List<IconRes> {
VaultTrailingIcon.ATTACHMENT.takeIf { this.attachments?.isNotEmpty() == true },
)
.map {
IconRes(
IconData.Local(
iconRes = it.iconRes,
contentDescription = it.contentDescription,
testTag = it.testTag,
)
}
.toImmutableList()
}
@@ -18,12 +18,10 @@ import com.x8bit.bitwarden.ui.platform.base.util.toListItemCardStyle
import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenGroupItem
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.model.toIconResources
import com.x8bit.bitwarden.ui.platform.components.util.rememberVectorPainter
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import com.x8bit.bitwarden.ui.vault.feature.vault.handlers.VaultHandlers
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toPersistentList
private const val TOTP_TYPES_COUNT: Int = 1
private const val TRASH_TYPES_COUNT: Int = 1
@@ -92,10 +90,7 @@ fun VaultContent(
VaultEntryListItem(
startIcon = favoriteItem.startIcon,
startIconTestTag = favoriteItem.startIconTestTag,
trailingLabelIcons = favoriteItem
.extraIconList
.toIconResources()
.toPersistentList(),
trailingLabelIcons = favoriteItem.extraIconList,
label = favoriteItem.name(),
supportingLabel = favoriteItem.supportingLabel?.invoke(),
onClick = { vaultHandlers.vaultItemClick(favoriteItem) },
@@ -269,10 +264,7 @@ fun VaultContent(
VaultEntryListItem(
startIcon = noFolderItem.startIcon,
startIconTestTag = noFolderItem.startIconTestTag,
trailingLabelIcons = noFolderItem
.extraIconList
.toIconResources()
.toPersistentList(),
trailingLabelIcons = noFolderItem.extraIconList,
label = noFolderItem.name(),
supportingLabel = noFolderItem.supportingLabel?.invoke(),
onClick = { vaultHandlers.vaultItemClick(noFolderItem) },
@@ -8,7 +8,6 @@ import com.x8bit.bitwarden.ui.platform.components.listitem.BitwardenListItem
import com.x8bit.bitwarden.ui.platform.components.listitem.SelectionItemData
import com.x8bit.bitwarden.ui.platform.components.model.CardStyle
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.ImmutableList
@@ -39,7 +38,7 @@ fun VaultEntryListItem(
onOverflowOptionClick: (ListingItemOverflowAction.VaultAction) -> Unit,
cardStyle: CardStyle,
modifier: Modifier = Modifier,
trailingLabelIcons: ImmutableList<IconResource> = persistentListOf(),
trailingLabelIcons: ImmutableList<IconData> = persistentListOf(),
supportingLabel: String? = null,
) {
BitwardenListItem(
@@ -35,7 +35,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.concat
import com.x8bit.bitwarden.ui.platform.base.util.hexToColor
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.platform.components.snackbar.BitwardenSnackbarData
import com.x8bit.bitwarden.ui.platform.manager.snackbar.SnackbarRelay
import com.x8bit.bitwarden.ui.platform.manager.snackbar.SnackbarRelayManager
@@ -57,6 +56,8 @@ import com.x8bit.bitwarden.ui.vault.model.VaultItemListingType
import com.x8bit.bitwarden.ui.vault.util.shortName
import com.x8bit.bitwarden.ui.vault.util.toVaultItemCipherType
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
@@ -1005,7 +1006,7 @@ data class VaultState(
/**
* The icons shown after the item name.
*/
abstract val extraIconList: List<IconRes>
abstract val extraIconList: ImmutableList<IconData>
/**
* An optional supporting label for the vault item that provides additional information.
@@ -1040,7 +1041,7 @@ data class VaultState(
override val name: Text,
override val startIcon: IconData = IconData.Local(R.drawable.ic_globe),
override val startIconTestTag: String = "LoginCipherIcon",
override val extraIconList: List<IconRes> = emptyList(),
override val extraIconList: ImmutableList<IconData> = persistentListOf(),
override val overflowOptions: List<ListingItemOverflowAction.VaultAction>,
override val shouldShowMasterPasswordReprompt: Boolean,
val username: Text?,
@@ -1061,7 +1062,7 @@ data class VaultState(
override val name: Text,
override val startIcon: IconData = IconData.Local(R.drawable.ic_payment_card),
override val startIconTestTag: String = "CardCipherIcon",
override val extraIconList: List<IconRes> = emptyList(),
override val extraIconList: ImmutableList<IconData> = persistentListOf(),
override val overflowOptions: List<ListingItemOverflowAction.VaultAction>,
override val shouldShowMasterPasswordReprompt: Boolean,
private val brand: VaultCardBrand? = null,
@@ -1093,7 +1094,7 @@ data class VaultState(
override val name: Text,
override val startIcon: IconData = IconData.Local(R.drawable.ic_id_card),
override val startIconTestTag: String = "IdentityCipherIcon",
override val extraIconList: List<IconRes> = emptyList(),
override val extraIconList: ImmutableList<IconData> = persistentListOf(),
override val overflowOptions: List<ListingItemOverflowAction.VaultAction>,
override val shouldShowMasterPasswordReprompt: Boolean,
val fullName: Text?,
@@ -1112,7 +1113,7 @@ data class VaultState(
override val name: Text,
override val startIcon: IconData = IconData.Local(R.drawable.ic_note),
override val startIconTestTag: String = "SecureNoteCipherIcon",
override val extraIconList: List<IconRes> = emptyList(),
override val extraIconList: ImmutableList<IconData> = persistentListOf(),
override val overflowOptions: List<ListingItemOverflowAction.VaultAction>,
override val shouldShowMasterPasswordReprompt: Boolean,
) : VaultItem() {
@@ -1133,7 +1134,7 @@ data class VaultState(
override val name: Text,
override val startIcon: IconData = IconData.Local(R.drawable.ic_ssh_key),
override val startIconTestTag: String = "SshKeyCipherIcon",
override val extraIconList: List<IconRes> = emptyList(),
override val extraIconList: ImmutableList<IconData> = persistentListOf(),
override val overflowOptions: List<ListingItemOverflowAction.VaultAction>,
override val shouldShowMasterPasswordReprompt: Boolean,
val publicKey: Text,
@@ -67,7 +67,6 @@ fun VaultVerificationCodeItem(
) {
BitwardenIcon(
iconData = startIcon,
contentDescription = null,
tint = BitwardenTheme.colorScheme.icon.primary,
modifier = Modifier.size(24.dp),
)
@@ -6,9 +6,9 @@ import com.bitwarden.vault.CipherType
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.feature.search.SearchState
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.persistentListOf
/**
* Create a mock [SearchState.DisplayItem] with a given [number].
@@ -31,13 +31,13 @@ fun createMockDisplayItemForCipher(
uri = "https://vault.bitwarden.com/icons/www.mockuri.com/icon.png",
fallbackIconRes = fallbackIconRes,
),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -85,13 +85,13 @@ fun createMockDisplayItemForCipher(
subtitle = null,
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_note),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -128,13 +128,13 @@ fun createMockDisplayItemForCipher(
subtitle = "mockBrand-$number, *er-$number",
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_payment_card),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -177,13 +177,13 @@ fun createMockDisplayItemForCipher(
subtitle = "mockFirstName-${number}mockLastName-$number",
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_id_card),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -217,8 +217,8 @@ fun createMockDisplayItemForCipher(
subtitle = "mockPublicKey-$number",
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_ssh_key),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
@@ -262,13 +262,13 @@ fun createMockDisplayItemForSend(
subtitle = "Oct 27, 2023, 12:00 PM",
subtitleTestTag = "SendDateLabel",
iconData = IconData.Local(R.drawable.ic_file),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_key,
contentDescription = R.string.password.asText(),
testTag = "PasswordProtectedSendIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_max_access_count_reached,
contentDescription = R.string.maximum_access_count_reached.asText(),
testTag = "MaxAccessSendIcon",
@@ -302,13 +302,13 @@ fun createMockDisplayItemForSend(
subtitle = "Oct 27, 2023, 12:00 PM",
subtitleTestTag = "SendDateLabel",
iconData = IconData.Local(R.drawable.ic_file_text),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_key,
contentDescription = R.string.password.asText(),
testTag = "PasswordProtectedSendIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_max_access_count_reached,
contentDescription = R.string.maximum_access_count_reached.asText(),
testTag = "MaxAccessSendIcon",
@@ -35,6 +35,7 @@ import io.mockk.just
import io.mockk.mockk
import io.mockk.runs
import io.mockk.verify
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update
import org.junit.Assert.assertEquals
@@ -782,7 +783,7 @@ private val DEFAULT_SEND_ITEM: SendState.ViewState.Content.SendItem =
name = "mockName-1",
deletionDate = "1",
type = SendState.ViewState.Content.SendItem.Type.FILE,
iconList = emptyList(),
iconList = persistentListOf(),
shareUrl = "www.test.com/#/send/mockAccessId-1/mockKey-1",
hasPassword = true,
)
@@ -797,7 +798,7 @@ private val DEFAULT_CONTENT_VIEW_STATE: SendState.ViewState.Content = SendState.
name = "mockName-2",
deletionDate = "1",
type = SendState.ViewState.Content.SendItem.Type.TEXT,
iconList = emptyList(),
iconList = persistentListOf(),
shareUrl = "www.test.com/#/send/mockAccessId-1/mockKey-1",
hasPassword = true,
),
@@ -4,12 +4,14 @@ import com.bitwarden.send.SendType
import com.bitwarden.send.SendView
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSendView
import com.x8bit.bitwarden.data.vault.repository.model.SendData
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.tools.feature.send.SendState
import com.x8bit.bitwarden.ui.tools.feature.send.model.SendStatusIcon
import io.mockk.every
import io.mockk.mockkStatic
import io.mockk.unmockkStatic
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
@@ -100,24 +102,24 @@ class SendDataExtensionsTest {
private const val DEFAULT_BASE_URL: String = "www.test.com/"
private val DEFAULT_SEND_STATUS_ICONS: List<IconRes> = listOf(
IconRes(
private val DEFAULT_SEND_STATUS_ICONS: ImmutableList<IconData> = persistentListOf(
IconData.Local(
iconRes = SendStatusIcon.DISABLED.iconRes,
contentDescription = SendStatusIcon.DISABLED.contentDescription,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.PASSWORD.iconRes,
contentDescription = SendStatusIcon.PASSWORD.contentDescription,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.iconRes,
contentDescription = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.contentDescription,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.EXPIRED.iconRes,
contentDescription = SendStatusIcon.EXPIRED.contentDescription,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.PENDING_DELETE.iconRes,
contentDescription = SendStatusIcon.PENDING_DELETE.contentDescription,
),
@@ -1,9 +1,11 @@
package com.x8bit.bitwarden.ui.tools.feature.send.util
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSendView
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.tools.feature.send.model.SendStatusIcon
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.Clock
@@ -58,7 +60,7 @@ class SendViewExtensionsTest {
val result = sendView.toLabelIcons(clock)
assertEquals(emptyList<IconRes>(), result)
assertEquals(emptyList<IconData.Local>(), result)
}
@Suppress("MaxLineLength")
@@ -114,28 +116,28 @@ class SendViewExtensionsTest {
}
}
private val ALL_SEND_STATUS_ICONS: List<IconRes> = listOf(
IconRes(
private val ALL_SEND_STATUS_ICONS: ImmutableList<IconData> = persistentListOf(
IconData.Local(
iconRes = SendStatusIcon.DISABLED.iconRes,
contentDescription = SendStatusIcon.DISABLED.contentDescription,
testTag = SendStatusIcon.DISABLED.testTag,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.PASSWORD.iconRes,
contentDescription = SendStatusIcon.PASSWORD.contentDescription,
testTag = SendStatusIcon.PASSWORD.testTag,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.iconRes,
contentDescription = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.contentDescription,
testTag = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.testTag,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.EXPIRED.iconRes,
contentDescription = SendStatusIcon.EXPIRED.contentDescription,
testTag = SendStatusIcon.EXPIRED.testTag,
),
IconRes(
IconData.Local(
iconRes = SendStatusIcon.PENDING_DELETE.iconRes,
contentDescription = SendStatusIcon.PENDING_DELETE.contentDescription,
testTag = SendStatusIcon.PENDING_DELETE.testTag,
@@ -32,7 +32,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.base.util.toHostOrPathOrNull
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.platform.feature.search.model.SearchType
import com.x8bit.bitwarden.ui.platform.manager.biometrics.BiometricsManager
import com.x8bit.bitwarden.ui.platform.manager.exit.ExitManager
@@ -2275,24 +2274,24 @@ private fun createDisplayItem(number: Int): VaultItemListingState.DisplayItem =
subtitle = "mockSubtitle-$number",
subtitleTestTag = "SendDateLabel",
iconData = IconData.Local(R.drawable.ic_payment_card),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_send_disabled,
contentDescription = R.string.disabled.asText(),
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_key,
contentDescription = R.string.password.asText(),
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_max_access_count_reached,
contentDescription = R.string.maximum_access_count_reached.asText(),
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_expired,
contentDescription = R.string.expired.asText(),
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_pending_delete,
contentDescription = R.string.pending_delete.asText(),
),
@@ -2323,7 +2322,7 @@ private fun createCipherDisplayItem(number: Int): VaultItemListingState.DisplayI
subtitle = "mockSubtitle-$number",
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_vault),
extraIconList = emptyList(),
extraIconList = persistentListOf(),
overflowOptions = listOf(
ListingItemOverflowAction.VaultAction.EditClick(
cipherId = "mockId-$number",
@@ -5,9 +5,9 @@ import com.bitwarden.vault.CipherType
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.asText
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.VaultItemListingState
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import kotlinx.collections.immutable.persistentListOf
/**
* Create a mock [VaultItemListingState.DisplayItem] with a given [number].
@@ -35,13 +35,13 @@ fun createMockDisplayItemForCipher(
uri = "https://vault.bitwarden.com/icons/www.mockuri.com/icon.png",
fallbackIconRes = R.drawable.ic_globe,
),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -92,13 +92,13 @@ fun createMockDisplayItemForCipher(
subtitle = subtitle,
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_note),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -138,13 +138,13 @@ fun createMockDisplayItemForCipher(
subtitle = subtitle,
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_payment_card),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -190,13 +190,13 @@ fun createMockDisplayItemForCipher(
subtitle = subtitle,
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_id_card),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -233,13 +233,13 @@ fun createMockDisplayItemForCipher(
subtitle = subtitle,
subtitleTestTag = "CipherSubTitleLabel",
iconData = IconData.Local(R.drawable.ic_ssh_key),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",
@@ -286,13 +286,13 @@ fun createMockDisplayItemForSend(
subtitle = "Oct 27, 2023, 12:00 PM",
subtitleTestTag = "SendDateLabel",
iconData = IconData.Local(R.drawable.ic_file),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_key,
contentDescription = R.string.password.asText(),
testTag = "PasswordProtectedSendIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_max_access_count_reached,
contentDescription = R.string.maximum_access_count_reached.asText(),
testTag = "MaxAccessSendIcon",
@@ -329,13 +329,13 @@ fun createMockDisplayItemForSend(
subtitle = "Oct 27, 2023, 12:00 PM",
subtitleTestTag = "SendDateLabel",
iconData = IconData.Local(R.drawable.ic_file_text),
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_key,
contentDescription = R.string.password.asText(),
testTag = "PasswordProtectedSendIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_send_max_access_count_reached,
contentDescription = R.string.maximum_access_count_reached.asText(),
testTag = "MaxAccessSendIcon",
@@ -7,7 +7,7 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockIdentityVie
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockLoginView
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSecureNoteView
import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockUriView
import com.x8bit.bitwarden.ui.platform.components.model.IconRes
import com.x8bit.bitwarden.ui.platform.components.model.IconData
import com.x8bit.bitwarden.ui.vault.feature.itemlisting.model.ListingItemOverflowAction
import com.x8bit.bitwarden.ui.vault.model.VaultTrailingIcon
import org.junit.jupiter.api.Assertions.assertEquals
@@ -396,7 +396,7 @@ class CipherViewExtensionsTest {
)
val expected = listOf(VaultTrailingIcon.COLLECTION).map {
IconRes(
IconData.Local(
iconRes = it.iconRes,
contentDescription = it.contentDescription,
testTag = it.testTag,
@@ -416,7 +416,7 @@ class CipherViewExtensionsTest {
)
val expected = listOf(VaultTrailingIcon.COLLECTION).map {
IconRes(
IconData.Local(
iconRes = it.iconRes,
contentDescription = it.contentDescription,
testTag = it.testTag,
@@ -436,7 +436,7 @@ class CipherViewExtensionsTest {
)
val expected = listOf(VaultTrailingIcon.ATTACHMENT).map {
IconRes(
IconData.Local(
iconRes = it.iconRes,
contentDescription = it.contentDescription,
testTag = it.testTag,
@@ -456,7 +456,7 @@ class CipherViewExtensionsTest {
VaultTrailingIcon.COLLECTION,
VaultTrailingIcon.ATTACHMENT,
).map {
IconRes(
IconData.Local(
iconRes = it.iconRes,
contentDescription = it.contentDescription,
testTag = it.testTag,
@@ -476,7 +476,7 @@ class CipherViewExtensionsTest {
attachments = null,
)
val expected = listOf<IconRes>()
val expected = listOf<IconData>()
val result = cipher.toLabelIcons()
@@ -17,7 +17,6 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.createMockSshKeyView
import com.x8bit.bitwarden.data.vault.repository.model.VaultData
import com.x8bit.bitwarden.ui.platform.base.util.asText
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.util.toLabelIcons
import com.x8bit.bitwarden.ui.vault.feature.util.toOverflowActions
@@ -27,6 +26,7 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkStatic
import kotlinx.collections.immutable.persistentListOf
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.Clock
@@ -1003,13 +1003,13 @@ private fun createMockSshKeyVaultItem(number: Int): VaultState.ViewState.VaultIt
),
startIcon = IconData.Local(iconRes = R.drawable.ic_ssh_key),
startIconTestTag = "SshKeyCipherIcon",
extraIconList = listOf(
IconRes(
extraIconList = persistentListOf(
IconData.Local(
iconRes = R.drawable.ic_collections,
contentDescription = R.string.collections.asText(),
testTag = "CipherInCollectionIcon",
),
IconRes(
IconData.Local(
iconRes = R.drawable.ic_paperclip,
contentDescription = R.string.attachments.asText(),
testTag = "CipherWithAttachmentsIcon",