Updated on 2026-08-14
This commit is contained in:
parent
65ead13295
commit
6227d835b0
17 changed files with 250 additions and 93 deletions
|
|
@ -16,16 +16,39 @@ import com.tangem.core.ui.extensions.TextReference
|
|||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
private const val ROUNDED_LIST_WITH_DIVIDERS_HEADER_KEY = "ROUNDED_LIST_WITH_DIVIDERS_HEADER_KEY"
|
||||
private const val ROUNDED_LIST_WITH_DIVIDERS_FOOTER_KEY = "ROUNDED_LIST_WITH_DIVIDERS_FOOTER_KEY"
|
||||
|
||||
@Composable
|
||||
fun RoundedListWithDividers(rows: List<RoundedListWithDividersItemData>, modifier: Modifier = Modifier) {
|
||||
fun RoundedListWithDividers(
|
||||
rows: ImmutableList<RoundedListWithDividersItemData>,
|
||||
modifier: Modifier = Modifier,
|
||||
headerContent: (@Composable () -> Unit)? = null,
|
||||
footerContent: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
LazyColumn(modifier = modifier) {
|
||||
this.roundedListItems(rows)
|
||||
this.roundedListWithDividersItems(
|
||||
rows = rows,
|
||||
headerContent = headerContent,
|
||||
footerContent = footerContent,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun LazyListScope.roundedListItems(rows: List<RoundedListWithDividersItemData>) {
|
||||
fun LazyListScope.roundedListWithDividersItems(
|
||||
rows: ImmutableList<RoundedListWithDividersItemData>,
|
||||
headerContent: (@Composable () -> Unit)? = null,
|
||||
footerContent: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
if (headerContent != null) {
|
||||
item(key = ROUNDED_LIST_WITH_DIVIDERS_HEADER_KEY) {
|
||||
headerContent()
|
||||
}
|
||||
}
|
||||
|
||||
itemsIndexed(
|
||||
items = rows,
|
||||
key = { _, item -> item.id },
|
||||
|
|
@ -40,6 +63,12 @@ fun LazyListScope.roundedListItems(rows: List<RoundedListWithDividersItemData>)
|
|||
RoundedListDivider()
|
||||
}
|
||||
}
|
||||
|
||||
if (footerContent != null) {
|
||||
item(key = ROUNDED_LIST_WITH_DIVIDERS_FOOTER_KEY) {
|
||||
footerContent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue