Updated on 2026-08-14
This commit is contained in:
parent
3b4b45dc99
commit
33c966c934
7 changed files with 37 additions and 11 deletions
|
|
@ -81,7 +81,7 @@ private fun LazyListScope.contentItems(
|
|||
count = txHistoryItems.itemCount,
|
||||
key = txHistoryItems.itemKey { item ->
|
||||
when (item) {
|
||||
is TxHistoryState.TxHistoryItemState.GroupTitle -> item.title
|
||||
is TxHistoryState.TxHistoryItemState.GroupTitle -> item.itemKey
|
||||
is TxHistoryState.TxHistoryItemState.Title -> item.onExploreClick.hashCode()
|
||||
is TxHistoryState.TxHistoryItemState.Transaction -> item.state.txHash
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState.TxHistoryItemState
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* Transactions block group title
|
||||
|
|
@ -38,7 +39,9 @@ internal fun TxHistoryGroupTitle(config: TxHistoryItemState.GroupTitle, modifier
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockGroupTitle_Light() {
|
||||
TangemTheme(isDark = false) {
|
||||
TxHistoryGroupTitle(config = TxHistoryItemState.GroupTitle(title = "Today"))
|
||||
TxHistoryGroupTitle(
|
||||
config = TxHistoryItemState.GroupTitle(title = "Today", itemKey = UUID.randomUUID().toString()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +49,8 @@ private fun Preview_TransactionsBlockGroupTitle_Light() {
|
|||
@Composable
|
||||
private fun Preview_TransactionsBlockGroupTitle_Dark() {
|
||||
TangemTheme(isDark = true) {
|
||||
TxHistoryGroupTitle(config = TxHistoryItemState.GroupTitle(title = "Today"))
|
||||
TxHistoryGroupTitle(
|
||||
config = TxHistoryItemState.GroupTitle(title = "Today", itemKey = UUID.randomUUID().toString()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -49,8 +49,12 @@ sealed interface TxHistoryState {
|
|||
* Group title item
|
||||
*
|
||||
* @property title title
|
||||
* @property itemKey key to use in compose
|
||||
*/
|
||||
data class GroupTitle(val title: String) : TxHistoryItemState
|
||||
data class GroupTitle(
|
||||
val title: String,
|
||||
val itemKey: String,
|
||||
) : TxHistoryItemState
|
||||
|
||||
/**
|
||||
* Transaction item
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.flow.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import java.util.UUID
|
||||
|
||||
internal class TokenDetailsTxHistoryItemFlowConverter(
|
||||
private val currentStateProvider: Provider<TokenDetailsState>,
|
||||
|
|
@ -75,7 +76,10 @@ internal class TokenDetailsTxHistoryItemFlowConverter(
|
|||
// If [afterDate] is the first transaction in the flow, add the group title
|
||||
val afterDate = after.getTimestamp()?.toDateFormat() ?: return@insertSeparators null
|
||||
if (before is TxHistoryItemState.Title) {
|
||||
return@insertSeparators TxHistoryItemState.GroupTitle(afterDate)
|
||||
return@insertSeparators TxHistoryItemState.GroupTitle(
|
||||
title = afterDate,
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -84,7 +88,10 @@ internal class TokenDetailsTxHistoryItemFlowConverter(
|
|||
*/
|
||||
val beforeDate = before.getTimestamp()?.toDateFormat() ?: return@insertSeparators null
|
||||
return@insertSeparators if (beforeDate != afterDate) {
|
||||
TxHistoryItemState.GroupTitle(afterDate)
|
||||
TxHistoryItemState.GroupTitle(
|
||||
title = afterDate,
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,7 +418,10 @@ internal object WalletPreviewData {
|
|||
contentItems = MutableStateFlow(
|
||||
PagingData.from(
|
||||
listOf(
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle("Today"),
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle(
|
||||
title = "Today",
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
|
|
@ -432,7 +435,10 @@ internal object WalletPreviewData {
|
|||
onClick = {},
|
||||
),
|
||||
),
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle("Yesterday"),
|
||||
TxHistoryState.TxHistoryItemState.GroupTitle(
|
||||
title = "Yesterday",
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
),
|
||||
TxHistoryState.TxHistoryItemState.Transaction(
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.flow.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* Convert from [Flow] of [TxHistoryItem] to [TxHistoryState]
|
||||
|
|
@ -83,7 +84,10 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
// If [afterDate] is the first transaction in the flow, add the group title
|
||||
val afterDate = after.getTimestamp()?.toDateFormat() ?: return@insertSeparators null
|
||||
if (before is TxHistoryItemState.Title) {
|
||||
return@insertSeparators TxHistoryItemState.GroupTitle(afterDate)
|
||||
return@insertSeparators TxHistoryItemState.GroupTitle(
|
||||
title = afterDate,
|
||||
itemKey = UUID.randomUUID().toString(),
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -92,7 +96,7 @@ internal class WalletTxHistoryItemFlowConverter(
|
|||
*/
|
||||
val beforeDate = before.getTimestamp()?.toDateFormat() ?: return@insertSeparators null
|
||||
return@insertSeparators if (beforeDate != afterDate) {
|
||||
TxHistoryItemState.GroupTitle(afterDate)
|
||||
TxHistoryItemState.GroupTitle(title = afterDate, itemKey = UUID.randomUUID().toString())
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ spr-client = "3.6.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "release-app_5.2-391"
|
||||
tangemBlockchainSdk = "release-app_5.2-392"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "release-app_5.2-311"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue