Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-20 17:22:27 +02:00
parent b04f28cf04
commit 109edf4608
7 changed files with 13 additions and 6 deletions

View file

@ -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,

View file

@ -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
}

View file

@ -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,

View file

@ -35,6 +35,8 @@ internal class SwapAmountChangeAmountTypeTransformer(
field = field,
cryptoCurrencyStatus = prevState.secondaryCryptoCurrencyStatus,
isAmountEmpty = true,
).copy(
shouldShowApproximatePrefix = swapRateType == ExpressRateType.Float,
)
} ?: prevState.secondaryAmount
} else {

View file

@ -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,

View file

@ -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) {

View file

@ -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,