Updated on 2026-08-14

This commit is contained in:
Tangem 2023-09-26 14:56:05 +05:00
parent b74e2b9168
commit 3ef300ee56
3 changed files with 19 additions and 26 deletions

View file

@ -4,7 +4,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.ui.Modifier
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.itemContentType
@ -57,36 +56,29 @@ private fun LazyListScope.contentItems(
txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>,
modifier: Modifier = Modifier,
) {
txHistoryItems.itemKey { item ->
when (item) {
is TxHistoryState.TxHistoryItemState.GroupTitle -> item.title
is TxHistoryState.TxHistoryItemState.Title -> item.onExploreClick.hashCode()
is TxHistoryState.TxHistoryItemState.Transaction -> item.state.txHash
}
}
txHistoryItems.itemContentType { it::class.java }
itemsIndexed(
items = txHistoryItems.itemSnapshotList.items,
key = { _, item ->
items(
count = txHistoryItems.itemCount,
key = txHistoryItems.itemKey { item ->
when (item) {
is TxHistoryState.TxHistoryItemState.GroupTitle -> item.title
is TxHistoryState.TxHistoryItemState.Title -> item.onExploreClick.hashCode()
is TxHistoryState.TxHistoryItemState.Transaction -> item.state.txHash
}
},
) { index, item ->
TxHistoryListItem(
state = item,
modifier = modifier
.animateItemPlacement()
.roundedShapeItemDecoration(
currentIndex = index,
lastIndex = txHistoryItems.itemSnapshotList.lastIndex,
),
)
}
contentType = txHistoryItems.itemContentType { it::class.java },
itemContent = { index ->
val item = txHistoryItems[index]!!
TxHistoryListItem(
state = item,
modifier = modifier
.animateItemPlacement()
.roundedShapeItemDecoration(
currentIndex = index,
lastIndex = txHistoryItems.itemSnapshotList.lastIndex,
),
)
},
)
}
@OptIn(ExperimentalFoundationApi::class)

View file

@ -39,6 +39,7 @@ class DefaultTxHistoryRepository(
return Pager(
config = PagingConfig(
pageSize = pageSize,
initialLoadSize = pageSize,
),
pagingSourceFactory = {
TxHistoryPagingSource(

View file

@ -10,7 +10,7 @@ import com.tangem.domain.txhistory.repository.TxHistoryRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
private const val DEFAULT_PAGE_SIZE = 20
private const val DEFAULT_PAGE_SIZE = 50
class GetTxHistoryItemsUseCase(private val repository: TxHistoryRepository) {