Updated on 2026-08-14
This commit is contained in:
commit
0bedc513a7
7 changed files with 14 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ import com.tangem.core.ui.format.bigdecimal.uncapped
|
|||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.core.ui.test.BaseAmountBlockTestTags
|
||||
import com.tangem.utils.StringsSigns
|
||||
|
||||
@Composable
|
||||
fun AmountBlockV2(
|
||||
|
|
@ -39,6 +40,7 @@ fun AmountBlockV2(
|
|||
isClickDisabled: Boolean,
|
||||
isEditingDisabled: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
shouldShowApproximatePrefix: Boolean = false,
|
||||
onClick: (() -> Unit)? = null,
|
||||
extraContent: @Composable () -> Unit = {},
|
||||
) {
|
||||
|
|
@ -71,7 +73,7 @@ fun AmountBlockV2(
|
|||
balance = amountState.availableBalanceCrypto,
|
||||
currencyTitle = currencyTitle,
|
||||
currencyIconState = amountState.tokenIconState,
|
||||
firstAmount = firstAmount,
|
||||
firstAmount = if (shouldShowApproximatePrefix) StringsSigns.TILDE_SIGN + firstAmount else firstAmount,
|
||||
secondAmount = secondAmount,
|
||||
isClickDisabled = isClickDisabled,
|
||||
isEditingDisabled = isEditingDisabled,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ internal class SwapAmountChangeAmountTypeTransformer(
|
|||
field = field,
|
||||
cryptoCurrencyStatus = prevState.secondaryCryptoCurrencyStatus,
|
||||
isAmountEmpty = true,
|
||||
).copy(
|
||||
shouldShowApproximatePrefix = swapRateType == ExpressRateType.Float,
|
||||
)
|
||||
} ?: prevState.secondaryAmount
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import com.tangem.core.ui.res.TangemThemePreview
|
|||
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
|
||||
|
|
@ -120,11 +121,13 @@ private fun ConstraintLayoutScope.SwapAmountBlock(
|
|||
end.linkTo(parent.end)
|
||||
},
|
||||
)
|
||||
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,
|
||||
shouldShowApproximatePrefix = secondaryContent?.shouldShowApproximatePrefix == true,
|
||||
isClickDisabled = true,
|
||||
isEditingDisabled = false,
|
||||
modifier = Modifier.constrainAs(toAmountRef) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue