Updated on 2026-08-14
This commit is contained in:
parent
9625042e8d
commit
cedc1663f0
4 changed files with 26 additions and 12 deletions
|
|
@ -2,6 +2,8 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory
|
|||
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressLinkUM
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressStatusUM
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateIconUM
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateInfoUM
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.ui.components.currency.icon.converter.CryptoCurrencyToIconStateConverter
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -18,13 +20,12 @@ import com.tangem.domain.tokens.model.CryptoCurrency
|
|||
import com.tangem.domain.tokens.model.Quote
|
||||
import com.tangem.domain.tokens.model.analytics.TokenExchangeAnalyticsEvent
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus.Companion.isFailed
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatusModel
|
||||
import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionListModel
|
||||
import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionModel
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.ExchangeStatusNotifications
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeStatusState
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateIconUM
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateInfoUM
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeUM
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
|
|
@ -115,7 +116,7 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
Timber.e("UpdateTxStatus isn't required. Current status isn't changed")
|
||||
return tx
|
||||
}
|
||||
val hasFailed = statusModel.status == ExchangeStatus.Failed
|
||||
val hasFailed = statusModel.status.isFailed()
|
||||
val notifications = getNotification(statusModel.status, statusModel.txExternalUrl, statusModel.refundCurrency)
|
||||
val showProviderLink = getShowProviderLink(notifications, statusModel)
|
||||
return tx.copy(
|
||||
|
|
@ -185,7 +186,9 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
refundToken: CryptoCurrency?,
|
||||
): ExchangeStatusNotifications? {
|
||||
return when (status) {
|
||||
ExchangeStatus.Failed -> {
|
||||
ExchangeStatus.Failed,
|
||||
ExchangeStatus.TxFailed,
|
||||
-> {
|
||||
if (txUrl == null) return null
|
||||
ExchangeStatusNotifications.Failed {
|
||||
analyticsEventsHandler.send(
|
||||
|
|
@ -221,7 +224,10 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
private fun getIconState(status: ExchangeStatus?): ExpressTransactionStateIconUM {
|
||||
return when (status) {
|
||||
ExchangeStatus.Verifying -> ExpressTransactionStateIconUM.Warning
|
||||
ExchangeStatus.Failed, ExchangeStatus.Cancelled -> ExpressTransactionStateIconUM.Error
|
||||
ExchangeStatus.Failed,
|
||||
ExchangeStatus.TxFailed,
|
||||
ExchangeStatus.Cancelled,
|
||||
-> ExpressTransactionStateIconUM.Error
|
||||
else -> ExpressTransactionStateIconUM.None
|
||||
}
|
||||
}
|
||||
|
|
@ -243,7 +249,7 @@ internal class TokenDetailsSwapTransactionsStateConverter(
|
|||
val isConfirming = status == ExchangeStatus.Confirming
|
||||
val isVerifying = status == ExchangeStatus.Verifying
|
||||
val isExchanging = status == ExchangeStatus.Exchanging
|
||||
val isFailed = status == ExchangeStatus.Failed
|
||||
val isFailed = status.isFailed()
|
||||
val isSending = status == ExchangeStatus.Sending
|
||||
val isRefunded = status == ExchangeStatus.Refunded
|
||||
val isPaused = status == ExchangeStatus.Paused
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.tangem.core.ui.extensions.stringResourceSafe
|
|||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus.Companion.isFailed
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeStatusState
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -117,8 +118,10 @@ private fun ExchangeStatusStep(
|
|||
isDone = false,
|
||||
)
|
||||
}
|
||||
state.status == ExchangeStatus.Failed || state.status == ExchangeStatus.Refunded ||
|
||||
state.status == ExchangeStatus.Paused -> {
|
||||
state.status.isFailed() ||
|
||||
state.status == ExchangeStatus.Refunded ||
|
||||
state.status == ExchangeStatus.Paused
|
||||
-> {
|
||||
ExchangeStep(
|
||||
iconRes = R.drawable.ic_close_24,
|
||||
color = TangemTheme.colors.icon.warning,
|
||||
|
|
@ -155,7 +158,7 @@ private fun ExchangeStatusStepText(stepStatus: ExchangeStatusState) {
|
|||
status == ExchangeStatus.Cancelled || status == ExchangeStatus.Refunded || status == ExchangeStatus.Paused -> {
|
||||
TangemTheme.colors.icon.warning
|
||||
}
|
||||
status == ExchangeStatus.Failed && !stepStatus.isDone -> TangemTheme.colors.icon.warning
|
||||
status.isFailed() && !stepStatus.isDone -> TangemTheme.colors.icon.warning
|
||||
status == ExchangeStatus.Verifying && !stepStatus.isDone -> TangemTheme.colors.icon.attention
|
||||
stepStatus.isDone -> TangemTheme.colors.text.primary1
|
||||
!stepStatus.isActive -> TangemTheme.colors.text.disabled
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.tangem.core.ui.extensions.TextReference
|
|||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus.Companion.isFailed
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.ExchangeStatusNotifications
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeUM
|
||||
|
||||
|
|
@ -97,9 +98,9 @@ private fun Notification(state: ExchangeStatusNotifications, activeStatus: Excha
|
|||
is ExchangeStatusNotifications.CommonNotification -> {
|
||||
com.tangem.core.ui.components.notifications.Notification(
|
||||
config = notification.config,
|
||||
iconTint = when (activeStatus) {
|
||||
ExchangeStatus.Verifying -> TangemTheme.colors.icon.attention
|
||||
ExchangeStatus.Failed -> TangemTheme.colors.icon.warning
|
||||
iconTint = when {
|
||||
activeStatus == ExchangeStatus.Verifying -> TangemTheme.colors.icon.attention
|
||||
activeStatus.isFailed() -> TangemTheme.colors.icon.warning
|
||||
else -> null
|
||||
},
|
||||
containerColor = TangemTheme.colors.background.action,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue