Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-05 13:41:34 +04:00
parent 47acce67c1
commit e326873ac1
4 changed files with 48 additions and 8 deletions

View file

@ -15,6 +15,7 @@ import com.tangem.features.tangempay.entity.TangemPayTxHistoryDetailsUM
import com.tangem.features.tangempay.entity.TangemPayTxHistoryDetailsUM.ButtonState
import com.tangem.utils.StringsSigns
import com.tangem.utils.converter.Converter
import com.tangem.utils.extensions.isPositive
import com.tangem.utils.extensions.isZero
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
@ -51,7 +52,10 @@ internal object TangemPayTxHistoryDetailsConverter :
private fun TangemPayTxHistoryItem.extractIcon(): ImageReference {
return when (this) {
is TangemPayTxHistoryItem.Collateral -> ImageReference.Res(R.drawable.ic_arrow_up_24)
is TangemPayTxHistoryItem.Collateral -> when (this.type) {
TangemPayTxHistoryItem.Type.Deposit -> ImageReference.Res(R.drawable.ic_arrow_down_24)
TangemPayTxHistoryItem.Type.Withdrawal -> ImageReference.Res(R.drawable.ic_arrow_up_24)
}
is TangemPayTxHistoryItem.Fee -> ImageReference.Res(R.drawable.ic_percent_24)
is TangemPayTxHistoryItem.Payment -> ImageReference.Res(R.drawable.ic_arrow_up_24)
is TangemPayTxHistoryItem.Spend -> {
@ -69,7 +73,10 @@ internal object TangemPayTxHistoryDetailsConverter :
return when (this) {
is TangemPayTxHistoryItem.Spend -> stringReference(this.enrichedMerchantName ?: this.merchantName)
is TangemPayTxHistoryItem.Payment -> resourceReference(R.string.tangem_pay_withdrawal)
is TangemPayTxHistoryItem.Collateral -> resourceReference(R.string.tangem_pay_withdrawal)
is TangemPayTxHistoryItem.Collateral -> when (this.type) {
TangemPayTxHistoryItem.Type.Deposit -> resourceReference(R.string.tangem_pay_deposit)
TangemPayTxHistoryItem.Type.Withdrawal -> resourceReference(R.string.tangem_pay_withdrawal)
}
is TangemPayTxHistoryItem.Fee -> {
this.description?.let(::stringReference) ?: resourceReference(R.string.tangem_pay_fee_title)
}
@ -113,7 +120,11 @@ internal object TangemPayTxHistoryDetailsConverter :
amountPrefix + amount
}
is TangemPayTxHistoryItem.Collateral -> {
val amountPrefix = if (this.amount.isZero()) "" else StringsSigns.MINUS
val amountPrefix = when {
this.amount.isZero() -> ""
this.amount.isPositive() -> StringsSigns.PLUS
else -> StringsSigns.MINUS
}
val amount = this.amount.abs().format {
fiat(
fiatCurrencyCode = this@extractAmount.currency.currencyCode,
@ -131,7 +142,10 @@ internal object TangemPayTxHistoryDetailsConverter :
is TangemPayTxHistoryItem.Spend,
is TangemPayTxHistoryItem.Payment,
-> themedColor { TangemTheme.colors.text.primary1 }
is TangemPayTxHistoryItem.Collateral -> themedColor { TangemTheme.colors.text.primary1 }
is TangemPayTxHistoryItem.Collateral -> when (this.type) {
TangemPayTxHistoryItem.Type.Deposit -> themedColor { TangemTheme.colors.text.accent }
TangemPayTxHistoryItem.Type.Withdrawal -> themedColor { TangemTheme.colors.text.primary1 }
}
}
}

View file

@ -14,6 +14,7 @@ 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 com.tangem.utils.extensions.isZero
import org.joda.time.DateTimeZone
@ -96,7 +97,11 @@ internal class TangemPayTxHistoryItemsConverter(
private fun convertCollateral(
collateral: TangemPayTxHistoryItem.Collateral,
): TangemPayTransactionState.Content.Collateral {
val amountPrefix = if (collateral.amount.isZero()) "" else StringsSigns.MINUS
val amountPrefix = when {
collateral.amount.isZero() -> ""
collateral.amount.isPositive() -> StringsSigns.PLUS
else -> StringsSigns.MINUS
}
val amount = amountPrefix + collateral.amount.abs().format {
fiat(fiatCurrencyCode = collateral.currency.currencyCode, fiatCurrencySymbol = collateral.currency.symbol)
}
@ -104,10 +109,19 @@ internal class TangemPayTxHistoryItemsConverter(
id = collateral.id,
onClick = { txHistoryUiActions.onTransactionClick(collateral) },
amount = amount,
amountColor = themedColor { TangemTheme.colors.text.primary1 },
title = resourceReference(R.string.tangem_pay_withdrawal),
amountColor = when (collateral.type) {
TangemPayTxHistoryItem.Type.Deposit -> themedColor { TangemTheme.colors.text.accent }
TangemPayTxHistoryItem.Type.Withdrawal -> themedColor { TangemTheme.colors.text.primary1 }
},
title = when (collateral.type) {
TangemPayTxHistoryItem.Type.Deposit -> resourceReference(R.string.tangem_pay_deposit)
TangemPayTxHistoryItem.Type.Withdrawal -> resourceReference(R.string.tangem_pay_withdrawal)
},
subtitle = resourceReference(R.string.common_transfer),
icon = ImageReference.Res(R.drawable.ic_arrow_up_24),
icon = when (collateral.type) {
TangemPayTxHistoryItem.Type.Deposit -> ImageReference.Res(R.drawable.ic_arrow_down_24)
TangemPayTxHistoryItem.Type.Withdrawal -> ImageReference.Res(R.drawable.ic_arrow_up_24)
},
time = DateTimeFormatters.formatDate(collateral.date, DateTimeFormatters.timeFormatter),
)
}