From cedc1663f0af934b07157fd327695720da73d07a Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 11 Feb 2025 13:03:13 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../domain/models/domain/ExchangeStatus.kt | 4 ++++ ...kenDetailsSwapTransactionsStateConverter.kt | 18 ++++++++++++------ .../express/exchange/ExchangeStatusBlock.kt | 9 ++++++--- .../ExchangeStatusBottomSheetContent.kt | 7 ++++--- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeStatus.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeStatus.kt index bf429e9a75..aff7c81ecd 100644 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeStatus.kt +++ b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeStatus.kt @@ -83,4 +83,8 @@ enum class ExchangeStatus { val isAutoDisposable: Boolean get() = this == Finished + + companion object { + fun ExchangeStatus?.isFailed(): Boolean = this == Failed || this == TxFailed + } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt index ba05cd229d..e8e7415770 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSwapTransactionsStateConverter.kt @@ -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 diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBlock.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBlock.kt index 33fcbc4cf8..eb95cd174f 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBlock.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBlock.kt @@ -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 diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBottomSheetContent.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBottomSheetContent.kt index 034b9b4a0b..c91628293c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBottomSheetContent.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/express/exchange/ExchangeStatusBottomSheetContent.kt @@ -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,