diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml
index 8e7c5ebd52..15e0b5cfc4 100644
--- a/core/res/src/main/res/values/strings.xml
+++ b/core/res/src/main/res/values/strings.xml
@@ -1326,6 +1326,7 @@
Explore transaction
Service fees
Fee
+ Get Help
Completed
Declined
Pending
diff --git a/core/ui/src/main/res/drawable/ic_explore_20.xml b/core/ui/src/main/res/drawable/ic_explore_20.xml
new file mode 100644
index 0000000000..f125f461b3
--- /dev/null
+++ b/core/ui/src/main/res/drawable/ic_explore_20.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/data/visa/src/main/kotlin/com/tangem/data/visa/utils/TangemPayTxHistoryItemConverter.kt b/data/visa/src/main/kotlin/com/tangem/data/visa/utils/TangemPayTxHistoryItemConverter.kt
index 0d3fa873de..4b13cb8946 100644
--- a/data/visa/src/main/kotlin/com/tangem/data/visa/utils/TangemPayTxHistoryItemConverter.kt
+++ b/data/visa/src/main/kotlin/com/tangem/data/visa/utils/TangemPayTxHistoryItemConverter.kt
@@ -10,14 +10,16 @@ import java.util.Currency
internal class TangemPayTxHistoryItemConverter(moshi: Moshi) :
Converter {
- private val spendAdapter = moshi.adapter(TangemPayTxHistoryResponse.Spend::class.java)
- private val paymentAdapter = moshi.adapter(TangemPayTxHistoryResponse.Payment::class.java)
- private val feeAdapter = moshi.adapter(TangemPayTxHistoryResponse.Fee::class.java)
+ private val spendAdapter by lazy { moshi.adapter(TangemPayTxHistoryResponse.Spend::class.java) }
+ private val paymentAdapter by lazy { moshi.adapter(TangemPayTxHistoryResponse.Payment::class.java) }
+ private val feeAdapter by lazy { moshi.adapter(TangemPayTxHistoryResponse.Fee::class.java) }
+ private val collateralAdapter by lazy { moshi.adapter(TangemPayTxHistoryResponse.Collateral::class.java) }
override fun convert(value: TangemPayTxHistoryResponse.Transaction): TangemPayTxHistoryItem? {
return value.spend?.let { convertSpend(id = value.id, spend = it) }
?: value.payment?.let { convertPayment(id = value.id, payment = it) }
?: value.fee?.let { convertFee(id = value.id, fee = it) }
+ ?: value.collateral?.let { convertCollateral(id = value.id, collateral = it) }
?: run {
Timber.wtf("unknown type of transaction: $value")
null
@@ -63,4 +65,22 @@ internal class TangemPayTxHistoryItemConverter(moshi: Moshi) :
amount = fee.amount,
)
}
+
+ private fun convertCollateral(
+ id: String,
+ collateral: TangemPayTxHistoryResponse.Collateral,
+ ): TangemPayTxHistoryItem.Collateral? {
+ val date = collateral.postedAt ?: return run {
+ Timber.e("Collateral transaction postedAt is null: $collateral")
+ return@run null
+ }
+ return TangemPayTxHistoryItem.Collateral(
+ id = id,
+ jsonRepresentation = collateralAdapter.toJson(collateral),
+ date = date,
+ currency = Currency.getInstance("usd"),
+ amount = collateral.amount,
+ transactionHash = collateral.transactionHash,
+ )
+ }
}
\ No newline at end of file
diff --git a/domain/visa/models/src/main/kotlin/com/tangem/domain/visa/model/TangemPayTxHistoryItem.kt b/domain/visa/models/src/main/kotlin/com/tangem/domain/visa/model/TangemPayTxHistoryItem.kt
index d5a102ee64..4f8798a4f0 100644
--- a/domain/visa/models/src/main/kotlin/com/tangem/domain/visa/model/TangemPayTxHistoryItem.kt
+++ b/domain/visa/models/src/main/kotlin/com/tangem/domain/visa/model/TangemPayTxHistoryItem.kt
@@ -47,6 +47,16 @@ sealed class TangemPayTxHistoryItem {
override val currency: SerializedCurrency,
) : TangemPayTxHistoryItem()
+ @Serializable
+ data class Collateral(
+ override val id: String,
+ override val jsonRepresentation: String,
+ override val date: SerializedDateTime,
+ override val amount: SerializedBigDecimal,
+ override val currency: SerializedCurrency,
+ val transactionHash: String,
+ ) : TangemPayTxHistoryItem()
+
enum class Status {
PENDING,
RESERVED,
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/PreviewTangemPayTxHistoryComponent.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/PreviewTangemPayTxHistoryComponent.kt
index 49dccbf15e..7f04f563e2 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/PreviewTangemPayTxHistoryComponent.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/txHistory/PreviewTangemPayTxHistoryComponent.kt
@@ -2,8 +2,11 @@ package com.tangem.features.tangempay.components.txHistory
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
+import com.tangem.core.ui.extensions.ImageReference
import com.tangem.core.ui.extensions.stringReference
+import com.tangem.core.ui.extensions.themedColor
import com.tangem.core.ui.res.TangemTheme
+import com.tangem.features.tangempay.details.impl.R
import com.tangem.features.tangempay.entity.TangemPayTransactionState
import com.tangem.features.tangempay.entity.TangemPayTxHistoryUM
import com.tangem.features.tangempay.ui.tangemPayTxHistoryItems
@@ -33,47 +36,47 @@ internal class PreviewTangemPayTxHistoryComponent(txHistoryUM: TangemPayTxHistor
id = "signiferumque",
onClick = {},
amount = "-4.99 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "16:41",
title = stringReference("StarbucksStarbucksStarbucksStarbucks"),
subtitle = stringReference("Food&Drinks"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Payment(
id = "signiferumque",
amount = "-126.20 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "12:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- isIncome = false,
+ icon = ImageReference.Res(R.drawable.ic_arrow_up_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Payment(
id = "signiferumque",
amount = "+126.20 USD",
- amountColor = { TangemTheme.colors.text.accent },
+ amountColor = themedColor { TangemTheme.colors.text.accent },
time = "12:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- isIncome = true,
+ icon = ImageReference.Res(R.drawable.ic_arrow_down_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-126.20 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "12:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.GroupTitle(title = "Yesterday", itemKey = "Yesterday"),
@@ -81,96 +84,96 @@ internal class PreviewTangemPayTxHistoryComponent(txHistoryUM: TangemPayTxHistor
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-4.99 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "21:41",
onClick = {},
title = stringReference("Starbucks"),
subtitle = stringReference("Food&Drinks"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-126.20 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "10:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-4.99 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "19:41",
onClick = {},
title = stringReference("Starbucks"),
subtitle = stringReference("Food&Drinks"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-126.20 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "18:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-4.99 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "17:41",
onClick = {},
title = stringReference("Starbucks"),
subtitle = stringReference("Food&Drinks"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-126.20 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "16:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-4.99 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "15:41",
onClick = {},
title = stringReference("Starbucks"),
subtitle = stringReference("Food&Drinks"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
TangemPayTxHistoryUM.TangemPayTxHistoryItemUM.Transaction(
transaction = TangemPayTransactionState.Content.Spend(
id = "signiferumque",
amount = "-126.20 USD",
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
time = "14:04",
onClick = {},
title = stringReference("Wallmart"),
subtitle = stringReference("Supermarket"),
- iconUrl = null,
+ icon = ImageReference.Res(R.drawable.ic_category_24),
),
),
),
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTransactionState.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTransactionState.kt
index 675103d42e..f14463cd0c 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTransactionState.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTransactionState.kt
@@ -1,7 +1,7 @@
package com.tangem.features.tangempay.entity
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.graphics.Color
+import com.tangem.core.ui.extensions.ColorReference
+import com.tangem.core.ui.extensions.ImageReference
import com.tangem.core.ui.extensions.TextReference
internal sealed interface TangemPayTransactionState {
@@ -14,40 +14,53 @@ internal sealed interface TangemPayTransactionState {
val onClick: () -> Unit
val amount: String
- val amountColor: @Composable (() -> Color)
+ val amountColor: ColorReference
val title: TextReference
val subtitle: TextReference
+ val icon: ImageReference
val time: String
data class Spend(
override val id: String,
override val onClick: () -> Unit,
override val amount: String,
- override val amountColor: @Composable (() -> Color),
+ override val amountColor: ColorReference,
override val title: TextReference,
override val subtitle: TextReference,
+ override val icon: ImageReference,
override val time: String,
- val iconUrl: String?,
) : Content
data class Payment(
override val id: String,
override val onClick: () -> Unit,
override val amount: String,
- override val amountColor: @Composable (() -> Color),
+ override val amountColor: ColorReference,
override val title: TextReference,
override val subtitle: TextReference,
+ override val icon: ImageReference,
override val time: String,
- val isIncome: Boolean,
) : Content
data class Fee(
override val id: String,
override val onClick: () -> Unit,
override val amount: String,
- override val amountColor: @Composable (() -> Color),
+ override val amountColor: ColorReference,
override val title: TextReference,
override val subtitle: TextReference,
+ override val icon: ImageReference,
+ override val time: String,
+ ) : Content
+
+ data class Collateral(
+ override val id: String,
+ override val onClick: () -> Unit,
+ override val amount: String,
+ override val amountColor: ColorReference,
+ override val title: TextReference,
+ override val subtitle: TextReference,
+ override val icon: ImageReference,
override val time: String,
) : Content
}
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTxHistoryDetailsUM.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTxHistoryDetailsUM.kt
index 2ca794500d..be9817c6f1 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTxHistoryDetailsUM.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayTxHistoryDetailsUM.kt
@@ -5,6 +5,7 @@ import com.tangem.core.ui.components.notifications.NotificationConfig
import com.tangem.core.ui.extensions.ColorReference
import com.tangem.core.ui.extensions.ImageReference
import com.tangem.core.ui.extensions.TextReference
+import kotlinx.collections.immutable.ImmutableList
internal data class TangemPayTxHistoryDetailsUM(
val title: TextReference,
@@ -15,9 +16,9 @@ internal data class TangemPayTxHistoryDetailsUM(
val transactionAmountColor: ColorReference,
val labelState: LabelUM?,
val notification: NotificationConfig?,
- val buttonState: ButtonState,
+ val buttons: ImmutableList,
val dismiss: () -> Unit,
) {
- data class ButtonState(val text: TextReference, val onClick: () -> Unit)
+ data class ButtonState(val text: TextReference, val onClick: () -> Unit, val startIcon: ImageReference.Res? = null)
}
\ No newline at end of file
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryDetailsConverter.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryDetailsConverter.kt
index edf1708a96..747cd54186 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryDetailsConverter.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryDetailsConverter.kt
@@ -11,9 +11,12 @@ import com.tangem.core.ui.utils.DateTimeFormatters
import com.tangem.domain.visa.model.TangemPayTxHistoryItem
import com.tangem.features.tangempay.details.impl.R
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 kotlinx.collections.immutable.ImmutableList
+import kotlinx.collections.immutable.persistentListOf
internal object TangemPayTxHistoryDetailsConverter :
Converter {
@@ -30,7 +33,7 @@ internal object TangemPayTxHistoryDetailsConverter :
transactionAmountColor = value.item.extractAmountColor(),
labelState = value.item.extractLabel(),
notification = value.item.extractNotification(),
- buttonState = value.extractButtonState(),
+ buttons = value.extractButtonsState(),
dismiss = value.onDismiss,
)
}
@@ -44,6 +47,7 @@ internal object TangemPayTxHistoryDetailsConverter :
private fun TangemPayTxHistoryItem.extractIcon(): ImageReference {
return when (this) {
+ is TangemPayTxHistoryItem.Collateral -> ImageReference.Res(R.drawable.ic_arrow_down_24)
is TangemPayTxHistoryItem.Fee -> ImageReference.Res(R.drawable.ic_percent_24)
is TangemPayTxHistoryItem.Payment -> {
if (this.amount.isPositive()) {
@@ -72,6 +76,7 @@ internal object TangemPayTxHistoryDetailsConverter :
} else {
resourceReference(R.string.tangem_pay_withdrawal)
}
+ is TangemPayTxHistoryItem.Collateral -> resourceReference(R.string.tangem_pay_deposit)
}
}
@@ -80,6 +85,7 @@ internal object TangemPayTxHistoryDetailsConverter :
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)
}
}
@@ -96,7 +102,9 @@ internal object TangemPayTxHistoryDetailsConverter :
}
StringsSigns.MINUS + amount
}
- is TangemPayTxHistoryItem.Payment -> {
+ is TangemPayTxHistoryItem.Payment,
+ is TangemPayTxHistoryItem.Collateral,
+ -> {
val amount = this.amount.format {
fiat(
fiatCurrencyCode = this@extractAmount.currency.currencyCode,
@@ -124,6 +132,7 @@ internal object TangemPayTxHistoryDetailsConverter :
TangemTheme.colors.text.primary1
}
}
+ is TangemPayTxHistoryItem.Collateral -> themedColor { TangemTheme.colors.text.accent }
}
}
@@ -131,6 +140,7 @@ internal object TangemPayTxHistoryDetailsConverter :
return when (this) {
is TangemPayTxHistoryItem.Fee,
is TangemPayTxHistoryItem.Payment,
+ is TangemPayTxHistoryItem.Collateral,
-> null
is TangemPayTxHistoryItem.Spend -> when (this.status) {
TangemPayTxHistoryItem.Status.COMPLETED -> LabelUM(
@@ -156,6 +166,7 @@ internal object TangemPayTxHistoryDetailsConverter :
private fun TangemPayTxHistoryItem.extractNotification(): NotificationConfig? {
return when (this) {
is TangemPayTxHistoryItem.Payment -> null
+ is TangemPayTxHistoryItem.Collateral -> null
is TangemPayTxHistoryItem.Fee -> NotificationConfig(
title = resourceReference(R.string.tangem_pay_transaction_fee_notification_text),
subtitle = TextReference.EMPTY,
@@ -176,19 +187,36 @@ internal object TangemPayTxHistoryDetailsConverter :
}
}
- private fun Input.extractButtonState(): TangemPayTxHistoryDetailsUM.ButtonState {
+ private fun Input.extractButtonsState(): ImmutableList {
return when (this.item) {
- is TangemPayTxHistoryItem.Fee -> TangemPayTxHistoryDetailsUM.ButtonState(
- text = resourceReference(R.string.tangem_pay_dispute),
- onClick = this.onDisputeClick,
+ is TangemPayTxHistoryItem.Fee -> persistentListOf(
+ ButtonState(
+ text = resourceReference(R.string.tangem_pay_dispute),
+ onClick = this.onDisputeClick,
+ ),
)
- is TangemPayTxHistoryItem.Spend -> TangemPayTxHistoryDetailsUM.ButtonState(
- text = resourceReference(R.string.tangem_pay_dispute),
- onClick = this.onDisputeClick,
+ is TangemPayTxHistoryItem.Spend -> persistentListOf(
+ ButtonState(
+ text = resourceReference(R.string.tangem_pay_dispute),
+ onClick = this.onDisputeClick,
+ ),
)
- is TangemPayTxHistoryItem.Payment -> TangemPayTxHistoryDetailsUM.ButtonState(
- text = resourceReference(R.string.tangem_pay_explore_transaction),
- onClick = { this.onExplorerClick(this.item.transactionHash) },
+ is TangemPayTxHistoryItem.Payment -> persistentListOf(
+ ButtonState(
+ text = resourceReference(R.string.tangem_pay_explore_transaction),
+ onClick = { this.onExplorerClick(this.item.transactionHash) },
+ ),
+ )
+ is TangemPayTxHistoryItem.Collateral -> persistentListOf(
+ ButtonState(
+ text = resourceReference(R.string.tangem_pay_explore_transaction),
+ startIcon = ImageReference.Res(R.drawable.ic_explore_20),
+ onClick = { this.onExplorerClick(this.item.transactionHash) },
+ ),
+ ButtonState(
+ text = resourceReference(R.string.tangem_pay_get_help),
+ onClick = this.onDisputeClick,
+ ),
)
}
}
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryItemsConverter.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryItemsConverter.kt
index 1c45dc31c5..bc80b34d69 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryItemsConverter.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/transformers/TangemPayTxHistoryItemsConverter.kt
@@ -1,11 +1,15 @@
package com.tangem.features.tangempay.model.transformers
+import com.tangem.core.ui.extensions.ImageReference
+import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
+import com.tangem.core.ui.extensions.themedColor
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.utils.DateTimeFormatters
import com.tangem.domain.visa.model.TangemPayTxHistoryItem
+import com.tangem.features.tangempay.details.impl.R
import com.tangem.features.tangempay.entity.TangemPayTransactionState
import com.tangem.features.tangempay.utils.TangemPayTxHistoryUiActions
import com.tangem.utils.StringsSigns
@@ -22,6 +26,7 @@ internal class TangemPayTxHistoryItemsConverter(
is TangemPayTxHistoryItem.Spend -> convertSpend(spend = value)
is TangemPayTxHistoryItem.Payment -> convertPayment(payment = value)
is TangemPayTxHistoryItem.Fee -> convertFee(fee = value)
+ is TangemPayTxHistoryItem.Collateral -> convertCollateral(collateral = value)
}
}
@@ -38,7 +43,7 @@ internal class TangemPayTxHistoryItemsConverter(
id = spend.id,
onClick = { txHistoryUiActions.onTransactionClick(spend) },
amount = amount,
- amountColor = {
+ amountColor = themedColor {
when (spend.status) {
TangemPayTxHistoryItem.Status.DECLINED -> TangemTheme.colors.text.warning
else -> TangemTheme.colors.text.primary1
@@ -47,14 +52,16 @@ internal class TangemPayTxHistoryItemsConverter(
title = stringReference(spend.enrichedMerchantName ?: spend.merchantName),
subtitle = stringReference(spend.enrichedMerchantCategory ?: spend.merchantCategory),
time = DateTimeFormatters.formatDate(localDate, DateTimeFormatters.timeFormatter),
- iconUrl = spend.enrichedMerchantIconUrl,
+ icon = spend.enrichedMerchantIconUrl?.let(ImageReference::Url)
+ ?: ImageReference.Res(R.drawable.ic_category_24),
)
}
private fun convertPayment(payment: TangemPayTxHistoryItem.Payment): TangemPayTransactionState.Content.Payment {
+ val isIncome = payment.amount.isPositive()
val amountPrefix = when {
payment.amount.isZero() -> ""
- payment.amount.isPositive() -> StringsSigns.PLUS
+ isIncome -> StringsSigns.PLUS
else -> StringsSigns.MINUS
}
val amount = amountPrefix + payment.amount.format {
@@ -65,17 +72,13 @@ internal class TangemPayTxHistoryItemsConverter(
id = payment.id,
onClick = { txHistoryUiActions.onTransactionClick(payment) },
amount = amount,
- amountColor = {
- if (payment.amount.isPositive()) {
- TangemTheme.colors.text.accent
- } else {
- TangemTheme.colors.text.primary1
- }
+ amountColor = themedColor {
+ if (payment.amount.isPositive()) TangemTheme.colors.text.accent else TangemTheme.colors.text.primary1
},
title = stringReference(title),
subtitle = stringReference("Transfers"),
time = DateTimeFormatters.formatDate(payment.date, DateTimeFormatters.timeFormatter),
- isIncome = payment.amount.isPositive(),
+ icon = ImageReference.Res(if (isIncome) R.drawable.ic_arrow_down_24 else R.drawable.ic_arrow_up_24),
)
}
@@ -87,10 +90,29 @@ internal class TangemPayTxHistoryItemsConverter(
id = fee.id,
onClick = { txHistoryUiActions.onTransactionClick(fee) },
amount = amount,
- amountColor = { TangemTheme.colors.text.primary1 },
+ amountColor = themedColor { TangemTheme.colors.text.primary1 },
title = stringReference("Fee"),
subtitle = stringReference("Service fees"),
+ icon = ImageReference.Res(R.drawable.ic_percent_24),
time = DateTimeFormatters.formatDate(fee.date, DateTimeFormatters.timeFormatter),
)
}
+
+ private fun convertCollateral(
+ collateral: TangemPayTxHistoryItem.Collateral,
+ ): TangemPayTransactionState.Content.Collateral {
+ val amount = StringsSigns.MINUS + collateral.amount.format {
+ fiat(fiatCurrencyCode = collateral.currency.currencyCode, fiatCurrencySymbol = collateral.currency.symbol)
+ }
+ return TangemPayTransactionState.Content.Collateral(
+ id = collateral.id,
+ onClick = { txHistoryUiActions.onTransactionClick(collateral) },
+ amount = amount,
+ amountColor = themedColor { TangemTheme.colors.text.accent },
+ title = resourceReference(R.string.tangem_pay_deposit),
+ subtitle = resourceReference(R.string.common_transfer),
+ icon = ImageReference.Res(R.drawable.ic_arrow_down_24),
+ time = DateTimeFormatters.formatDate(collateral.date, DateTimeFormatters.timeFormatter),
+ )
+ }
}
\ No newline at end of file
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayTxHistoryUi.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayTxHistoryUi.kt
index deddf2a265..c22493816b 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayTxHistoryUi.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayTxHistoryUi.kt
@@ -28,6 +28,7 @@ import com.tangem.core.ui.components.buttons.actions.ActionButton
import com.tangem.core.ui.components.list.InfiniteListHandler
import com.tangem.core.ui.components.transactions.TxHistoryGroupTitle
import com.tangem.core.ui.decorations.roundedShapeItemDecoration
+import com.tangem.core.ui.extensions.ImageReference
import com.tangem.core.ui.extensions.orMaskWithStars
import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.extensions.stringResourceSafe
@@ -256,27 +257,14 @@ private fun TangemPayTransaction(
@Composable
private fun Icon(state: TangemPayTransactionState, modifier: Modifier = Modifier) {
when (state) {
- is TangemPayTransactionState.Content.Spend -> {
- if (state.iconUrl != null) {
- RemoteIcon(modifier = modifier, url = state.iconUrl)
- } else {
- LocalStaticIcon(
- modifier = modifier,
- id = R.drawable.ic_category_24,
- iconSize = TangemTheme.dimens.size20,
- )
- }
+ is TangemPayTransactionState.Content -> when (val iconReference = state.icon) {
+ is ImageReference.Url -> RemoteIcon(modifier = modifier, url = iconReference.url)
+ is ImageReference.Res -> LocalStaticIcon(
+ modifier = modifier,
+ id = iconReference.resId,
+ iconSize = TangemTheme.dimens.size20,
+ )
}
- is TangemPayTransactionState.Content.Fee -> LocalStaticIcon(
- modifier = modifier,
- id = R.drawable.ic_percent_24,
- iconSize = TangemTheme.dimens.size20,
- )
- is TangemPayTransactionState.Content.Payment -> LocalStaticIcon(
- modifier = modifier,
- id = if (state.isIncome) R.drawable.ic_arrow_down_24 else R.drawable.ic_arrow_up_24,
- iconSize = TangemTheme.dimens.size20,
- )
is TangemPayTransactionState.Loading -> CircleShimmer(modifier = modifier)
}
}
@@ -330,7 +318,7 @@ private fun Amount(state: TangemPayTransactionState, isBalanceHidden: Boolean, m
text = state.amount.orMaskWithStars(isBalanceHidden),
modifier = modifier,
textAlign = TextAlign.End,
- color = state.amountColor(),
+ color = state.amountColor.resolveReference(),
style = TangemTheme.typography.body2,
)
}
diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangempayTxDetailsUi.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangempayTxDetailsUi.kt
index 7d79f24a4e..4ce80b714b 100644
--- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangempayTxDetailsUi.kt
+++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangempayTxDetailsUi.kt
@@ -1,10 +1,7 @@
package com.tangem.features.tangempay.ui
import android.content.res.Configuration
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.*
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -14,7 +11,9 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.util.fastForEach
import com.tangem.core.ui.components.SecondaryButton
+import com.tangem.core.ui.components.SecondaryButtonIconStart
import com.tangem.core.ui.components.SpacerH32
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
@@ -25,16 +24,13 @@ import com.tangem.core.ui.components.label.entity.LabelStyle
import com.tangem.core.ui.components.label.entity.LabelUM
import com.tangem.core.ui.components.notifications.Notification
import com.tangem.core.ui.components.notifications.NotificationConfig
-import com.tangem.core.ui.extensions.ImageReference
-import com.tangem.core.ui.extensions.TextReference
-import com.tangem.core.ui.extensions.resolveReference
-import com.tangem.core.ui.extensions.resourceReference
-import com.tangem.core.ui.extensions.stringReference
-import com.tangem.core.ui.extensions.themedColor
+import com.tangem.core.ui.extensions.*
import com.tangem.core.ui.res.TangemTheme
import com.tangem.core.ui.res.TangemThemePreview
import com.tangem.features.tangempay.details.impl.R
import com.tangem.features.tangempay.entity.TangemPayTxHistoryDetailsUM
+import kotlinx.collections.immutable.ImmutableList
+import kotlinx.collections.immutable.persistentListOf
@Composable
internal fun TangemPayTxHistoryDetailsContent(state: TangemPayTxHistoryDetailsUM) {
@@ -93,19 +89,42 @@ internal fun TangemPayTxHistoryDetailsContent(state: TangemPayTxHistoryDetailsUM
iconTint = TangemTheme.colors.icon.secondary,
)
}
- ButtonContainer(
+ ButtonsContainer(
modifier = Modifier
.padding(vertical = 16.dp)
.fillMaxWidth(),
- buttonState = state.buttonState,
+ buttons = state.buttons,
)
}
}
}
@Composable
-private fun ButtonContainer(buttonState: TangemPayTxHistoryDetailsUM.ButtonState, modifier: Modifier = Modifier) {
- SecondaryButton(modifier = modifier, text = buttonState.text.resolveReference(), onClick = buttonState.onClick)
+private fun ButtonsContainer(
+ buttons: ImmutableList,
+ modifier: Modifier = Modifier,
+) {
+ Column(
+ modifier = modifier,
+ verticalArrangement = Arrangement.spacedBy(8.dp),
+ ) {
+ buttons.fastForEach { buttonState ->
+ if (buttonState.startIcon != null) {
+ SecondaryButtonIconStart(
+ modifier = Modifier.fillMaxWidth(),
+ text = buttonState.text.resolveReference(),
+ iconResId = buttonState.startIcon.resId,
+ onClick = buttonState.onClick,
+ )
+ } else {
+ SecondaryButton(
+ modifier = Modifier.fillMaxWidth(),
+ text = buttonState.text.resolveReference(),
+ onClick = buttonState.onClick,
+ )
+ }
+ }
+ }
}
@Composable
@@ -142,9 +161,11 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
icon = R.drawable.ic_clock_24,
),
notification = null,
- buttonState = TangemPayTxHistoryDetailsUM.ButtonState(
- text = stringReference("Dispute"),
- onClick = {},
+ buttons = persistentListOf(
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_dispute),
+ onClick = {},
+ ),
),
dismiss = {},
),
@@ -164,9 +185,11 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
subtitle = TextReference.EMPTY,
iconResId = R.drawable.ic_token_info_24,
),
- buttonState = TangemPayTxHistoryDetailsUM.ButtonState(
- text = stringReference("Dispute"),
- onClick = {},
+ buttons = persistentListOf(
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_dispute),
+ onClick = {},
+ ),
),
dismiss = {},
),
@@ -182,9 +205,11 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
style = LabelStyle.ACCENT,
),
notification = null,
- buttonState = TangemPayTxHistoryDetailsUM.ButtonState(
- text = stringReference("Dispute"),
- onClick = {},
+ buttons = persistentListOf(
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_dispute),
+ onClick = {},
+ ),
),
dismiss = {},
),
@@ -201,9 +226,11 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
subtitle = TextReference.EMPTY,
iconResId = R.drawable.ic_token_info_24,
),
- buttonState = TangemPayTxHistoryDetailsUM.ButtonState(
- text = stringReference("Dispute"),
- onClick = {},
+ buttons = persistentListOf(
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_dispute),
+ onClick = {},
+ ),
),
dismiss = {},
),
@@ -216,9 +243,11 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionAmountColor = themedColor { TangemTheme.colors.text.accent },
labelState = null,
notification = null,
- buttonState = TangemPayTxHistoryDetailsUM.ButtonState(
- text = stringReference("Explore transaction"),
- onClick = {},
+ buttons = persistentListOf(
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_explore_transaction),
+ onClick = {},
+ ),
),
dismiss = {},
),
@@ -231,9 +260,16 @@ private class TangemPayTxHistoryDetailsUMProvider : CollectionPreviewParameterPr
transactionAmountColor = themedColor { TangemTheme.colors.text.primary1 },
labelState = null,
notification = null,
- buttonState = TangemPayTxHistoryDetailsUM.ButtonState(
- text = stringReference("Explore transaction"),
- onClick = {},
+ buttons = persistentListOf(
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_explore_transaction),
+ startIcon = ImageReference.Res(R.drawable.ic_explore_20),
+ onClick = {},
+ ),
+ TangemPayTxHistoryDetailsUM.ButtonState(
+ text = resourceReference(R.string.tangem_pay_get_help),
+ onClick = {},
+ ),
),
dismiss = {},
),