Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-20 14:05:56 +05:00
parent 3ea0fbb8a3
commit fcc995a98a
7 changed files with 56 additions and 7 deletions

View file

@ -14,6 +14,7 @@ internal data class TangemPayTxHistoryDetailsUM(
val transactionSubtitle: TextReference,
val transactionAmount: String,
val transactionAmountColor: ColorReference,
val localTransactionText: String?,
val labelState: LabelUM?,
val notification: NotificationConfig?,
val buttons: ImmutableList<ButtonState>,

View file

@ -6,6 +6,7 @@ import com.tangem.core.ui.components.notifications.NotificationConfig
import com.tangem.core.ui.extensions.*
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.format.bigdecimal.price
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.utils.DateTimeFormatters
import com.tangem.domain.visa.model.TangemPayTxHistoryItem
@ -30,9 +31,10 @@ internal object TangemPayTxHistoryDetailsConverter :
transactionTitle = transaction.extractTransactionTitle(),
transactionSubtitle = transaction.extractTransactionSubtitle(),
transactionAmount = transaction.extractAmount(),
transactionAmountColor = value.item.extractAmountColor(),
labelState = value.item.extractLabel(),
notification = value.item.extractNotification(),
transactionAmountColor = transaction.extractAmountColor(),
localTransactionText = transaction.extractLocalAmount(),
labelState = transaction.extractLabel(),
notification = transaction.extractNotification(),
buttons = value.extractButtonsState(),
dismiss = value.onDismiss,
)
@ -76,8 +78,11 @@ internal object TangemPayTxHistoryDetailsConverter :
return when (this) {
is TangemPayTxHistoryItem.Fee -> resourceReference(R.string.tangem_pay_fee_subtitle)
is TangemPayTxHistoryItem.Payment -> resourceReference(R.string.common_transfer)
is TangemPayTxHistoryItem.Spend -> stringReference(this.enrichedMerchantCategory ?: this.merchantCategory)
is TangemPayTxHistoryItem.Collateral -> resourceReference(R.string.common_transfer)
is TangemPayTxHistoryItem.Spend -> {
val subtitle = merchantCategory ?: enrichedMerchantCategory
subtitle?.let(::stringReference) ?: resourceReference(R.string.tangem_pay_other)
}
}
}
@ -130,6 +135,29 @@ internal object TangemPayTxHistoryDetailsConverter :
}
}
private fun TangemPayTxHistoryItem.extractLocalAmount(): String? {
return when (this) {
is TangemPayTxHistoryItem.Collateral,
is TangemPayTxHistoryItem.Fee,
is TangemPayTxHistoryItem.Payment,
-> null
is TangemPayTxHistoryItem.Spend -> {
val localCurrency = this.localCurrency
val localAmount = this.localAmount
if (localCurrency != null && localAmount != null && localCurrency != currency) {
localAmount.format {
fiat(
fiatCurrencyCode = localCurrency.currencyCode,
fiatCurrencySymbol = localCurrency.symbol,
).price()
}
} else {
null
}
}
}
}
private fun TangemPayTxHistoryItem.extractLabel(): LabelUM? {
return when (this) {
is TangemPayTxHistoryItem.Fee,

View file

@ -39,6 +39,7 @@ internal class TangemPayTxHistoryItemsConverter(
val amount = amountPrefix + spend.amount.format {
fiat(fiatCurrencyCode = spend.currency.currencyCode, fiatCurrencySymbol = spend.currency.symbol)
}
val subtitle = spend.merchantCategory ?: spend.enrichedMerchantCategory
return TangemPayTransactionState.Content.Spend(
id = spend.id,
onClick = { txHistoryUiActions.onTransactionClick(spend) },
@ -50,7 +51,7 @@ internal class TangemPayTxHistoryItemsConverter(
}
},
title = stringReference(spend.enrichedMerchantName ?: spend.merchantName),
subtitle = stringReference(spend.enrichedMerchantCategory ?: spend.merchantCategory),
subtitle = subtitle?.let(::stringReference) ?: resourceReference(R.string.tangem_pay_other),
time = DateTimeFormatters.formatDate(localDate, DateTimeFormatters.timeFormatter),
icon = spend.enrichedMerchantIconUrl?.let(ImageReference::Url)
?: ImageReference.Res(R.drawable.ic_category_24),

View file

@ -32,6 +32,7 @@ import com.tangem.features.tangempay.entity.TangemPayTxHistoryDetailsUM
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
@Suppress("LongMethod")
@Composable
internal fun TangemPayTxHistoryDetailsContent(state: TangemPayTxHistoryDetailsUM) {
TangemModalBottomSheet<TangemBottomSheetConfigContent.Empty>(
@ -80,6 +81,14 @@ internal fun TangemPayTxHistoryDetailsContent(state: TangemPayTxHistoryDetailsUM
style = TangemTheme.typography.head,
color = state.transactionAmountColor.resolveReference(),
)
state.localTransactionText?.let { localTransaction ->
Text(
modifier = Modifier.padding(top = 4.dp),
text = localTransaction,
style = TangemTheme.typography.body2,
color = TangemTheme.colors.text.tertiary,
)
}
state.labelState?.let { Label(state = state.labelState, modifier = Modifier.padding(top = 12.dp)) }
SpacerH32()
state.notification?.let {
@ -155,6 +164,7 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionSubtitle = stringReference("Food and drinks"),
transactionAmount = "-$5.86",
transactionAmountColor = themedColor { TangemTheme.colors.text.primary1 },
localTransactionText = null,
labelState = LabelUM(
text = resourceReference(R.string.tangem_pay_status_pending),
style = LabelStyle.REGULAR,
@ -176,6 +186,7 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionSubtitle = stringReference("Food and drinks"),
transactionAmount = "-$5.86",
transactionAmountColor = themedColor { TangemTheme.colors.text.warning },
localTransactionText = null,
labelState = LabelUM(
text = resourceReference(R.string.tangem_pay_status_declined),
style = LabelStyle.WARNING,
@ -200,6 +211,7 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionSubtitle = stringReference("Food and drinks"),
transactionAmount = "-$5.86",
transactionAmountColor = themedColor { TangemTheme.colors.text.primary1 },
localTransactionText = "€ 5.36",
labelState = LabelUM(
text = resourceReference(R.string.tangem_pay_status_completed),
style = LabelStyle.ACCENT,
@ -220,6 +232,7 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionSubtitle = stringReference("Service fee"),
transactionAmount = "-$5.86",
transactionAmountColor = themedColor { TangemTheme.colors.text.primary1 },
localTransactionText = null,
labelState = null,
notification = NotificationConfig(
title = stringReference("This fee goes to cover the cost of handling your transfer."),
@ -241,6 +254,7 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionSubtitle = stringReference("Transfers"),
transactionAmount = "+$20",
transactionAmountColor = themedColor { TangemTheme.colors.text.accent },
localTransactionText = null,
labelState = null,
notification = null,
buttons = persistentListOf(
@ -258,6 +272,7 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionSubtitle = stringReference("Transfers"),
transactionAmount = "-$5.86",
transactionAmountColor = themedColor { TangemTheme.colors.text.primary1 },
localTransactionText = null,
labelState = null,
notification = null,
buttons = persistentListOf(