Updated on 2026-08-14
This commit is contained in:
parent
8d02828096
commit
cd7a23cbd6
5 changed files with 23 additions and 7 deletions
|
|
@ -6,6 +6,7 @@ import com.tangem.domain.visa.model.TangemPayTxHistoryItem
|
|||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.isPositive
|
||||
import com.tangem.utils.extensions.isZero
|
||||
import com.tangem.utils.extensions.orZero
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import timber.log.Timber
|
||||
|
|
@ -37,6 +38,7 @@ internal class TangemPayTxHistoryItemConverter(moshi: Moshi) :
|
|||
date = spend.authorizedAt.withLocalZone(),
|
||||
amount = spend.amount,
|
||||
currency = Currency.getInstance(spend.currency),
|
||||
authorizedAmount = spend.authorizedAmount.orZero(),
|
||||
localAmount = spend.localAmount,
|
||||
localCurrency = spend.localCurrency?.let(Currency::getInstance),
|
||||
enrichedMerchantName = spend.enrichedMerchantName,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ sealed class TangemPayTxHistoryItem {
|
|||
override val date: SerializedDateTime,
|
||||
override val amount: SerializedBigDecimal,
|
||||
override val currency: SerializedCurrency,
|
||||
val authorizedAmount: SerializedBigDecimal,
|
||||
val localAmount: SerializedBigDecimal?,
|
||||
val localCurrency: SerializedCurrency?,
|
||||
val enrichedMerchantName: String?,
|
||||
|
|
|
|||
|
|
@ -115,13 +115,17 @@ internal object TangemPayTxHistoryDetailsConverter :
|
|||
this.amount.isPositive() -> StringsSigns.MINUS
|
||||
else -> StringsSigns.PLUS
|
||||
}
|
||||
val amount = this.amount.abs().format {
|
||||
val amount = when (this.status) {
|
||||
TangemPayTxHistoryItem.Status.DECLINED -> this.authorizedAmount
|
||||
else -> this.amount
|
||||
}
|
||||
val formattedAmount = amount.abs().format {
|
||||
fiat(
|
||||
fiatCurrencyCode = this@extractAmount.currency.currencyCode,
|
||||
fiatCurrencySymbol = this@extractAmount.currency.symbol,
|
||||
)
|
||||
}
|
||||
amountPrefix + amount
|
||||
amountPrefix + formattedAmount
|
||||
}
|
||||
is TangemPayTxHistoryItem.Collateral -> {
|
||||
val amountPrefix = when {
|
||||
|
|
|
|||
|
|
@ -41,13 +41,17 @@ internal class TangemPayTxHistoryItemsConverter(
|
|||
spend.status == TangemPayTxHistoryItem.Status.DECLINED || spend.amount.isPositive() -> StringsSigns.MINUS
|
||||
else -> StringsSigns.PLUS
|
||||
}
|
||||
val amount = amountPrefix + spend.amount.abs().format {
|
||||
val amount = when (spend.status) {
|
||||
TangemPayTxHistoryItem.Status.DECLINED -> spend.authorizedAmount
|
||||
else -> spend.amount
|
||||
}
|
||||
val formattedAmount = amountPrefix + amount.abs().format {
|
||||
fiat(fiatCurrencyCode = spend.currency.currencyCode, fiatCurrencySymbol = spend.currency.symbol)
|
||||
}
|
||||
return TangemPayTransactionState.Content.Spend(
|
||||
id = spend.id,
|
||||
onClick = { txHistoryUiActions.onTransactionClick(spend) },
|
||||
amount = amount,
|
||||
amount = formattedAmount,
|
||||
amountColor = themedColor {
|
||||
when {
|
||||
spend.status == TangemPayTxHistoryItem.Status.DECLINED -> TangemTheme.colors.text.warning
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ internal object WalletScreenPreviewDataLegacy {
|
|||
|
||||
private val textContentTokensState = WalletTokensListState.ContentState.Content(
|
||||
items = persistentListOf(
|
||||
TokensListItemUM.GroupTitle(id = 1, text = stringReference("Network Bitcoin")),
|
||||
TokensListItemUM.GroupTitle(id = 111, text = stringReference("Network Bitcoin")),
|
||||
TokensListItemUM.Token(state = tokenItemState),
|
||||
TokensListItemUM.GroupTitle(id = 2, text = stringReference("Network Ethereum")),
|
||||
TokensListItemUM.GroupTitle(id = 222, text = stringReference("Network Ethereum")),
|
||||
TokensListItemUM.Token(
|
||||
state = tokenItemState.copy(
|
||||
id = "2",
|
||||
|
|
@ -210,7 +210,12 @@ internal object WalletScreenPreviewDataLegacy {
|
|||
isFlickering = false,
|
||||
onItemClick = { },
|
||||
),
|
||||
tangemPayState = TangemPayState.Empty,
|
||||
tangemPayState = TangemPayState.Card(
|
||||
lastFourDigits = stringReference("*1234"),
|
||||
balanceText = stringReference("$10"),
|
||||
balanceSymbol = stringReference("USDC"),
|
||||
onClick = {},
|
||||
),
|
||||
type = WalletType.Cold,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue