From 109edf4608fac62ac59cfeea7b01b7199ae231f8 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 20 Apr 2026 17:22:27 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../com/tangem/common/ui/amountScreen/ui/AmountBlockV2.kt | 4 ++-- .../features/swap/v2/impl/amount/entity/SwapAmountUM.kt | 2 +- .../impl/amount/model/converter/SwapAmountFieldConverter.kt | 2 ++ .../transformers/SwapAmountChangeAmountTypeTransformer.kt | 2 ++ .../SwapAmountSecondaryReadyStateTransformer.kt | 1 + .../swap/v2/impl/amount/ui/SwapAmountBlockContent.kt | 6 +++--- .../v2/impl/amount/ui/preview/SwapAmountContentPreview.kt | 2 ++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlockV2.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlockV2.kt index 0e42de4752..f7322e95af 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlockV2.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlockV2.kt @@ -40,7 +40,7 @@ fun AmountBlockV2( isClickDisabled: Boolean, isEditingDisabled: Boolean, modifier: Modifier = Modifier, - showApproximatePrefix: Boolean = false, + shouldShowApproximatePrefix: Boolean = false, onClick: (() -> Unit)? = null, extraContent: @Composable () -> Unit = {}, ) { @@ -73,7 +73,7 @@ fun AmountBlockV2( balance = amountState.availableBalanceCrypto, currencyTitle = currencyTitle, currencyIconState = amountState.tokenIconState, - firstAmount = if (showApproximatePrefix) StringsSigns.TILDE_SIGN + firstAmount else firstAmount, + firstAmount = if (shouldShowApproximatePrefix) StringsSigns.TILDE_SIGN + firstAmount else firstAmount, secondAmount = secondAmount, isClickDisabled = isClickDisabled, isEditingDisabled = isEditingDisabled, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt index c0f9222dd3..ea00127113 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/entity/SwapAmountUM.kt @@ -86,6 +86,7 @@ sealed class SwapAmountFieldUM { val subtitleEllipsisLeft: TextEllipsis, val subtitleEllipsisRight: TextEllipsis, val isClickEnabled: Boolean, + val shouldShowApproximatePrefix: Boolean, ) : SwapAmountFieldUM() } @@ -95,7 +96,6 @@ data class PriceImpact( val amountSignificance: AmountSignificance, val type: Type, ) { - enum class Type { NONE, LOW, MEDIUM, HIGH } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt index 0684369b44..2075721a9b 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt @@ -39,6 +39,7 @@ internal class SwapAmountFieldConverter( isSelected: Boolean, isAmountEmpty: Boolean = true, displayAmount: BigDecimal? = null, + showApproximatePrefix: Boolean = false, ): SwapAmountFieldUM { val walletTitle = if (isSingleWallet) { resourceReference(R.string.send_from_title) @@ -60,6 +61,7 @@ internal class SwapAmountFieldConverter( subtitleRight = subtitles.subtitleRight, subtitleEllipsisRight = subtitles.subtitleEllipsisRight, isClickEnabled = true, + shouldShowApproximatePrefix = showApproximatePrefix, amountField = AmountStateConverter( clickIntents = clickIntents, appCurrency = appCurrency, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountChangeAmountTypeTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountChangeAmountTypeTransformer.kt index c1fde5d967..aea60fd110 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountChangeAmountTypeTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountChangeAmountTypeTransformer.kt @@ -35,6 +35,8 @@ internal class SwapAmountChangeAmountTypeTransformer( field = field, cryptoCurrencyStatus = prevState.secondaryCryptoCurrencyStatus, isAmountEmpty = true, + ).copy( + shouldShowApproximatePrefix = swapRateType == ExpressRateType.Float, ) } ?: prevState.secondaryAmount } else { diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt index f9de0f0a59..e2788cc4f1 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt @@ -62,6 +62,7 @@ internal class SwapAmountSecondaryReadyStateTransformer( swapAmountType = SwapAmountType.To, cryptoCurrencyStatus = secondaryCryptoCurrencyStatus, isSelected = prevState.selectedAmountType == SwapAmountType.To, + showApproximatePrefix = selectedRateType == ExpressRateType.Float, ), secondaryCryptoCurrencyStatus = secondaryCryptoCurrencyStatus, swapCurrencies = swapCurrencies, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt index 5c2914a574..52c6ec8150 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountBlockContent.kt @@ -37,10 +37,10 @@ import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.domain.express.models.ExpressRateType import com.tangem.domain.swap.models.SwapAmountType import com.tangem.features.swap.v2.impl.R import com.tangem.features.swap.v2.impl.amount.entity.PriceImpact +import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM import com.tangem.features.swap.v2.impl.amount.ui.preview.SwapAmountContentPreview import com.tangem.features.swap.v2.impl.chooseprovider.ui.SwapChooseProviderContent @@ -121,13 +121,13 @@ private fun ConstraintLayoutScope.SwapAmountBlock( end.linkTo(parent.end) }, ) - val isFloatRate = amountUM.swapRateType == ExpressRateType.Float + val secondaryContent = amountUM.secondaryAmount as? SwapAmountFieldUM.Content AmountBlockV2( amountState = (amountUM.secondaryAmount.amountField as? AmountState.Data)?.copy( accountTitleUM = AccountTitleUM.Text(resourceReference(R.string.send_with_swap_recipient_amount_title)), availableBalanceCrypto = TextReference.EMPTY, ) ?: amountUM.secondaryAmount.amountField, - showApproximatePrefix = isFloatRate, + shouldShowApproximatePrefix = secondaryContent?.shouldShowApproximatePrefix == true, isClickDisabled = true, isEditingDisabled = false, modifier = Modifier.constrainAs(toAmountRef) { diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt index 26beb5a846..9be4de2099 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/preview/SwapAmountContentPreview.kt @@ -108,6 +108,7 @@ internal data object SwapAmountContentPreview { isClickEnabled = false, subtitleEllipsisLeft = TextEllipsis.OffsetEnd(3), subtitleEllipsisRight = TextEllipsis.OffsetEnd(1), + shouldShowApproximatePrefix = false, ), secondaryAmount = SwapAmountFieldUM.Content( amountType = SwapAmountType.To, @@ -120,6 +121,7 @@ internal data object SwapAmountContentPreview { isClickEnabled = false, subtitleEllipsisLeft = TextEllipsis.End, subtitleEllipsisRight = TextEllipsis.End, + shouldShowApproximatePrefix = true, ), appCurrency = AppCurrency.Default, swapDirection = SwapDirection.Direct,