BitwardenListItem should use persistable lists (#676)

This commit is contained in:
David Perez 2024-01-18 21:50:09 -06:00 committed by Álison Fernandes
parent a1e55297e9
commit b77de7ba4d
3 changed files with 17 additions and 14 deletions

View file

@ -33,7 +33,7 @@ import com.x8bit.bitwarden.R
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.PersistentList
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
/**
@ -55,10 +55,10 @@ fun BitwardenListItem(
label: String,
startIcon: IconData,
onClick: () -> Unit,
selectionDataList: PersistentList<SelectionItemData>,
selectionDataList: ImmutableList<SelectionItemData>,
modifier: Modifier = Modifier,
supportingLabel: String? = null,
trailingLabelIcons: List<IconResource> = emptyList(),
trailingLabelIcons: ImmutableList<IconResource> = persistentListOf(),
) {
var shouldShowDialog by rememberSaveable { mutableStateOf(false) }
Row(

View file

@ -1,10 +1,10 @@
package com.x8bit.bitwarden.ui.platform.util
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.toPersistentList
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
/**
* Creates an immutable [PersistentList] of the given [elements] excluding the null ones.
* Creates an immutable [ImmutableList] of the given [elements] excluding the null ones.
*/
fun <T : Any> persistentListOfNotNull(vararg elements: T?): PersistentList<T> =
elements.filterNotNull().toPersistentList()
fun <T : Any> persistentListOfNotNull(vararg elements: T?): ImmutableList<T> =
elements.filterNotNull().toImmutableList()

View file

@ -19,6 +19,7 @@ import com.x8bit.bitwarden.ui.platform.components.model.IconResource
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
import com.x8bit.bitwarden.ui.platform.util.persistentListOfNotNull
import com.x8bit.bitwarden.ui.tools.feature.send.model.SendStatusIcon
import kotlinx.collections.immutable.toPersistentList
/**
* A Composable function that displays a row send item.
@ -56,12 +57,14 @@ fun SendListItem(
label = label,
supportingLabel = supportingLabel,
startIcon = startIcon,
trailingLabelIcons = trailingLabelIcons.map {
trailingLabelIcons = trailingLabelIcons
.map {
IconResource(
iconPainter = painterResource(it.iconRes),
contentDescription = it.contentDescription(),
)
},
}
.toPersistentList(),
onClick = onClick,
selectionDataList = persistentListOfNotNull(
SelectionItemData(