Updated on 2026-08-14
This commit is contained in:
parent
03b0f2b2ce
commit
9b5ad39c51
5 changed files with 65 additions and 6 deletions
|
|
@ -30,7 +30,7 @@ internal object TangemPayTxHistoryItemConverter :
|
|||
merchantName = spend.merchantName,
|
||||
enrichedMerchantCategory = spend.enrichedMerchantCategory,
|
||||
merchantCategory = spend.merchantCategory,
|
||||
status = spend.status,
|
||||
status = TangemPayTxHistoryItemStatusConverter.convert(spend.status),
|
||||
enrichedMerchantIconUrl = spend.enrichedMerchantIcon,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.tangem.data.visa.utils
|
||||
|
||||
import com.tangem.domain.visa.model.TangemPayTxHistoryItem
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
internal object TangemPayTxHistoryItemStatusConverter : Converter<String, TangemPayTxHistoryItem.Status> {
|
||||
override fun convert(value: String): TangemPayTxHistoryItem.Status {
|
||||
return when (value.uppercase()) {
|
||||
"PENDING" -> TangemPayTxHistoryItem.Status.PENDING
|
||||
"RESERVED" -> TangemPayTxHistoryItem.Status.RESERVED
|
||||
"COMPLETED" -> TangemPayTxHistoryItem.Status.COMPLETED
|
||||
"DECLINED" -> TangemPayTxHistoryItem.Status.DECLINED
|
||||
else -> TangemPayTxHistoryItem.Status.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ sealed class TangemPayTxHistoryItem {
|
|||
val merchantName: String,
|
||||
val enrichedMerchantCategory: String?,
|
||||
val merchantCategory: String,
|
||||
val status: String,
|
||||
val status: Status,
|
||||
val enrichedMerchantIconUrl: String?,
|
||||
) : TangemPayTxHistoryItem()
|
||||
|
||||
|
|
@ -36,4 +36,12 @@ sealed class TangemPayTxHistoryItem {
|
|||
override val amount: BigDecimal,
|
||||
override val currency: Currency,
|
||||
) : TangemPayTxHistoryItem()
|
||||
|
||||
enum class Status {
|
||||
PENDING,
|
||||
RESERVED,
|
||||
COMPLETED,
|
||||
DECLINED,
|
||||
UNKNOWN,
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,30 @@ internal class PreviewTangemPayTxHistoryComponent(txHistoryUM: TangemPayTxHistor
|
|||
iconUrl = null,
|
||||
),
|
||||
),
|
||||
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
|
||||
transaction = TangemPayTransactionState.Content.Payment(
|
||||
id = "signiferumque",
|
||||
amount = "-126.20 USD",
|
||||
amountColor = { TangemTheme.colors.text.primary1 },
|
||||
time = "12:04",
|
||||
onClick = {},
|
||||
title = stringReference("Wallmart"),
|
||||
subtitle = stringReference("Supermarket"),
|
||||
isIncome = false,
|
||||
),
|
||||
),
|
||||
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
|
||||
transaction = TangemPayTransactionState.Content.Payment(
|
||||
id = "signiferumque",
|
||||
amount = "+126.20 USD",
|
||||
amountColor = { TangemTheme.colors.text.accent },
|
||||
time = "12:04",
|
||||
onClick = {},
|
||||
title = stringReference("Wallmart"),
|
||||
subtitle = stringReference("Supermarket"),
|
||||
isIncome = true,
|
||||
),
|
||||
),
|
||||
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
|
||||
transaction = TangemPayTransactionState.Content.Spend(
|
||||
id = "signiferumque",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.tangem.core.ui.utils.DateTimeFormatters
|
|||
import com.tangem.domain.visa.model.TangemPayTxHistoryItem
|
||||
import com.tangem.features.tangempay.entity.TangemPayTransactionState
|
||||
import com.tangem.features.tangempay.utils.TangemPayTxHistoryUiActions
|
||||
import com.tangem.utils.StringsSigns
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.isPositive
|
||||
import org.joda.time.DateTimeZone
|
||||
|
|
@ -25,14 +26,23 @@ internal class TangemPayTxHistoryItemsConverter(
|
|||
|
||||
private fun convertSpend(spend: TangemPayTxHistoryItem.Spend): TangemPayTransactionState.Content.Spend {
|
||||
val localDate = spend.date.withZone(DateTimeZone.getDefault())
|
||||
val amount = spend.amount.format {
|
||||
val amountPrefix = when (spend.status) {
|
||||
TangemPayTxHistoryItem.Status.DECLINED -> ""
|
||||
else -> StringsSigns.MINUS
|
||||
}
|
||||
val amount = amountPrefix + spend.amount.format {
|
||||
fiat(fiatCurrencyCode = spend.currency.currencyCode, fiatCurrencySymbol = spend.currency.symbol)
|
||||
}
|
||||
return TangemPayTransactionState.Content.Spend(
|
||||
id = spend.id,
|
||||
onClick = { txHistoryUiActions.onTransactionClick(spend) },
|
||||
amount = amount,
|
||||
amountColor = { TangemTheme.colors.text.primary1 },
|
||||
amountColor = {
|
||||
when (spend.status) {
|
||||
TangemPayTxHistoryItem.Status.DECLINED -> TangemTheme.colors.text.warning
|
||||
else -> TangemTheme.colors.text.primary1
|
||||
}
|
||||
},
|
||||
title = stringReference(spend.enrichedMerchantName ?: spend.merchantName),
|
||||
subtitle = stringReference(spend.enrichedMerchantCategory ?: spend.merchantCategory),
|
||||
time = DateTimeFormatters.formatDate(localDate, DateTimeFormatters.timeFormatter),
|
||||
|
|
@ -41,7 +51,8 @@ internal class TangemPayTxHistoryItemsConverter(
|
|||
}
|
||||
|
||||
private fun convertPayment(payment: TangemPayTxHistoryItem.Payment): TangemPayTransactionState.Content.Payment {
|
||||
val amount = payment.amount.format {
|
||||
val amountPrefix = if (payment.amount.isPositive()) StringsSigns.PLUS else StringsSigns.MINUS
|
||||
val amount = amountPrefix + payment.amount.format {
|
||||
fiat(fiatCurrencyCode = payment.currency.currencyCode, fiatCurrencySymbol = payment.currency.symbol)
|
||||
}
|
||||
val title = if (payment.amount.isPositive()) "Deposit" else "Withdrawal"
|
||||
|
|
@ -64,7 +75,7 @@ internal class TangemPayTxHistoryItemsConverter(
|
|||
}
|
||||
|
||||
private fun convertFee(fee: TangemPayTxHistoryItem.Fee): TangemPayTransactionState.Content.Fee {
|
||||
val amount = fee.amount.format {
|
||||
val amount = StringsSigns.MINUS + fee.amount.format {
|
||||
fiat(fiatCurrencyCode = fee.currency.currencyCode, fiatCurrencySymbol = fee.currency.symbol)
|
||||
}
|
||||
return TangemPayTransactionState.Content.Fee(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue