Updated on 2026-08-14
This commit is contained in:
parent
bdbe12ecf0
commit
d83a31a9b0
17 changed files with 159 additions and 92 deletions
|
|
@ -9,11 +9,7 @@ import com.tangem.common.ui.amountScreen.models.AmountSegmentedButtonsConfig
|
|||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.amountScreen.models.EnterAmountBoundary
|
||||
import com.tangem.core.ui.components.currency.icon.converter.CryptoCurrencyToIconStateConverter
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.extensions.orMaskWithStars
|
||||
import com.tangem.core.ui.extensions.*
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
|
|
@ -61,7 +57,8 @@ class AmountStateConverter(
|
|||
return AmountState.Data(
|
||||
title = value.title,
|
||||
availableBalance = resourceReference(R.string.common_crypto_fiat_format, wrappedList(crypto, fiat)),
|
||||
availableBalanceShort = stringReference(crypto),
|
||||
availableBalanceCrypto = stringReference(crypto),
|
||||
availableBalanceFiat = stringReference(fiat),
|
||||
tokenName = stringReference(status.currency.name),
|
||||
tokenIconState = iconStateConverter.convert(status),
|
||||
amountTextField = amountFieldConverter.convert(value.value),
|
||||
|
|
@ -142,7 +139,15 @@ class AmountStateConverterV2(
|
|||
resourceReference(R.string.common_crypto_fiat_format, wrappedList(crypto, fiat))
|
||||
.orMaskWithStars(isBalanceHidden)
|
||||
},
|
||||
availableBalanceShort = stringReference(crypto).orMaskWithStars(isBalanceHidden),
|
||||
availableBalanceCrypto = stringReference(crypto).orMaskWithStars(isBalanceHidden),
|
||||
availableBalanceFiat = if (isBalanceHidden) {
|
||||
TextReference.EMPTY
|
||||
} else {
|
||||
combinedReference(
|
||||
stringReference(" $DOT "),
|
||||
stringReference(fiat),
|
||||
)
|
||||
},
|
||||
tokenName = stringReference(cryptoCurrencyStatus.currency.name),
|
||||
tokenIconState = iconStateConverter.convert(cryptoCurrencyStatus.currency),
|
||||
amountTextField = amountFieldConverter.convert(value.value),
|
||||
|
|
|
|||
|
|
@ -3,11 +3,7 @@ package com.tangem.common.ui.amountScreen.converters.field
|
|||
import com.tangem.common.ui.R
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.amountScreen.models.EnterAmountBoundary
|
||||
import com.tangem.core.ui.extensions.combinedReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.core.ui.extensions.orMaskWithStars
|
||||
import com.tangem.core.ui.extensions.*
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
|
|
@ -50,7 +46,15 @@ class AmountBoundaryUpdateTransformer(
|
|||
|
||||
return prevState.copy(
|
||||
availableBalance = availableBalance.orMaskWithStars(isBalanceHidden),
|
||||
availableBalanceShort = stringReference(crypto).orMaskWithStars(isBalanceHidden),
|
||||
availableBalanceCrypto = stringReference(crypto).orMaskWithStars(isBalanceHidden),
|
||||
availableBalanceFiat = if (isBalanceHidden) {
|
||||
TextReference.EMPTY
|
||||
} else {
|
||||
combinedReference(
|
||||
stringReference(" $DOT "),
|
||||
stringReference(fiat),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,8 @@ sealed class AmountState {
|
|||
* @param isPrimaryButtonEnabled indicates if next state button enabled
|
||||
* @param title title
|
||||
* @param availableBalance user crypto currency balance with fiat balance
|
||||
* @param availableBalanceShort user crypto currency balance without fiat balance
|
||||
* @param availableBalanceCrypto user crypto currency balance in crypto
|
||||
* @param availableBalanceFiat user crypto currency balance in fiat
|
||||
* @param tokenIconState crypto currency icon state
|
||||
* @param segmentedButtonConfig currency switcher config
|
||||
* @param selectedButton selected currency index
|
||||
|
|
@ -33,8 +34,10 @@ sealed class AmountState {
|
|||
override val isPrimaryButtonEnabled: Boolean,
|
||||
override val isRedesignEnabled: Boolean,
|
||||
val title: TextReference,
|
||||
@Deprecated("Remove with SEND_REDESIGNED toggle")
|
||||
val availableBalance: TextReference,
|
||||
val availableBalanceShort: TextReference,
|
||||
val availableBalanceCrypto: TextReference,
|
||||
val availableBalanceFiat: TextReference,
|
||||
val tokenName: TextReference,
|
||||
val tokenIconState: CurrencyIconState,
|
||||
val segmentedButtonConfig: PersistentList<AmountSegmentedButtonsConfig>,
|
||||
|
|
|
|||
|
|
@ -2,18 +2,16 @@ package com.tangem.common.ui.amountScreen.preview
|
|||
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.common.ui.amountScreen.models.AmountFieldModel
|
||||
import com.tangem.common.ui.amountScreen.models.AmountSegmentedButtonsConfig
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.core.ui.components.currency.icon.CurrencyIconState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.wrappedList
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.Amount
|
||||
import com.tangem.domain.tokens.model.AmountType
|
||||
import com.tangem.utils.StringsSigns
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -24,8 +22,9 @@ object AmountStatePreviewData {
|
|||
val amountState = AmountState.Data(
|
||||
isPrimaryButtonEnabled = false,
|
||||
title = stringReference("Family Wallet"),
|
||||
availableBalance = stringReference("2 130,88 USDT • 2 129,92 \$)"),
|
||||
availableBalanceShort = stringReference("2 130,88 USDT"),
|
||||
availableBalance = stringReference("2 130,81231238 USDT • 2 129,12 \$)"),
|
||||
availableBalanceCrypto = stringReference("2 130,81231238 USDT"),
|
||||
availableBalanceFiat = stringReference("1 232 129,12 \$"),
|
||||
tokenIconState = CurrencyIconState.Loading,
|
||||
segmentedButtonConfig = persistentListOf(
|
||||
AmountSegmentedButtonsConfig(
|
||||
|
|
@ -86,7 +85,9 @@ object AmountStatePreviewData {
|
|||
|
||||
val amountStateV2 = amountState.copy(
|
||||
isRedesignEnabled = true,
|
||||
availableBalance = resourceReference(R.string.common_balance, wrappedList("2 130,88 USDT")),
|
||||
availableBalance = stringReference("2 130,81231238 USDT • 2 129,12 \$)"),
|
||||
availableBalanceCrypto = stringReference("2 130,81231238 USDT"),
|
||||
availableBalanceFiat = stringReference(" ${StringsSigns.DOT} 1 232 129,12 $"),
|
||||
)
|
||||
|
||||
val amountWithValueFiatState = amountWithValueState.copy(
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fun AmountBlockV2(
|
|||
|
||||
AmountBlockV2(
|
||||
title = amountState.title,
|
||||
balance = amountState.availableBalanceShort,
|
||||
balance = amountState.availableBalanceCrypto,
|
||||
currencyTitle = currencyTitle,
|
||||
currencyIconState = amountState.tokenIconState,
|
||||
firstAmount = firstAmount,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.core.ui.components.SpacerWMax
|
||||
import com.tangem.core.ui.components.TextShimmer
|
||||
import com.tangem.core.ui.components.atoms.text.EllipsisText
|
||||
import com.tangem.core.ui.components.atoms.text.TextEllipsis
|
||||
|
|
@ -159,8 +158,10 @@ private fun AmountInfo(amountUM: AmountState, onMaxAmountClick: () -> Unit, modi
|
|||
bottom = 16.dp,
|
||||
),
|
||||
)
|
||||
AmountInfoMain(amountUM = amountUM)
|
||||
SpacerWMax()
|
||||
AmountInfoMain(
|
||||
amountUM = amountUM,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
Text(
|
||||
text = stringResourceSafe(R.string.send_max_amount),
|
||||
style = TangemTheme.typography.caption1,
|
||||
|
|
@ -209,12 +210,21 @@ private fun AmountInfoMain(amountUM: AmountState, modifier: Modifier = Modifier)
|
|||
color = TangemTheme.colors.text.primary1,
|
||||
maxLines = 1,
|
||||
)
|
||||
EllipsisText(
|
||||
text = amountUM.availableBalance.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = TextEllipsis.OffsetEnd(amountUM.amountTextField.cryptoAmount.currencySymbol.length),
|
||||
)
|
||||
Row {
|
||||
EllipsisText(
|
||||
text = amountUM.availableBalanceCrypto.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = TextEllipsis.OffsetEnd(amountUM.amountTextField.cryptoAmount.currencySymbol.length),
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
EllipsisText(
|
||||
text = amountUM.availableBalanceFiat.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = TextEllipsis.OffsetEnd(amountUM.amountTextField.fiatAmount.currencySymbol.length),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
|||
import androidx.compose.ui.unit.Constraints
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import java.text.NumberFormat
|
||||
import java.util.Locale
|
||||
|
||||
sealed class TextEllipsis {
|
||||
|
||||
|
|
@ -126,13 +128,27 @@ fun EllipsisText(
|
|||
)
|
||||
}
|
||||
is TextEllipsis.OffsetEnd -> {
|
||||
offsetEndEllipsisText(
|
||||
availableWidth = availableWidth,
|
||||
startCounter = startCounter,
|
||||
endCounter = endCounter,
|
||||
offsetEnd = ellipsis.offsetEnd,
|
||||
withSeparator = ellipsis.hasSeparator,
|
||||
)
|
||||
val locale = Locale.getDefault()
|
||||
val formatter = NumberFormat.getCurrencyInstance(locale)
|
||||
val formattedValue = formatter.format(1)
|
||||
|
||||
val isPrefixSymbol = formattedValue.startsWith(formatter.currency?.symbol.orEmpty())
|
||||
|
||||
if (isPrefixSymbol) {
|
||||
offsetEndEllipsisText(
|
||||
availableWidth = availableWidth,
|
||||
startCounter = startCounter,
|
||||
endCounter = endCounter,
|
||||
)
|
||||
} else {
|
||||
offsetEndEllipsisText(
|
||||
availableWidth = availableWidth,
|
||||
startCounter = startCounter,
|
||||
endCounter = endCounter,
|
||||
offsetEnd = ellipsis.offsetEnd,
|
||||
withSeparator = ellipsis.hasSeparator,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ internal class SendAmountModel @Inject constructor(
|
|||
|
||||
private fun initialState() {
|
||||
if (uiState.value is AmountState.Empty && userWallet != null) {
|
||||
val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
_uiState.update {
|
||||
AmountStateConverterV2(
|
||||
clickIntents = this,
|
||||
|
|
@ -190,7 +190,7 @@ internal class SendAmountModel @Inject constructor(
|
|||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
).convert(
|
||||
AmountParameters(
|
||||
title = if (isSingleWallet) {
|
||||
title = if (isOnlyOneWallet) {
|
||||
resourceReference(R.string.send_from_title)
|
||||
} else {
|
||||
resourceReference(
|
||||
|
|
|
|||
|
|
@ -307,7 +307,8 @@ class SendConfirmNotificationsTransformersComparisonTest {
|
|||
isRedesignEnabled = false,
|
||||
title = mockk(relaxed = true),
|
||||
availableBalance = mockk(relaxed = true),
|
||||
availableBalanceShort = mockk(relaxed = true),
|
||||
availableBalanceCrypto = mockk(relaxed = true),
|
||||
availableBalanceFiat = mockk(relaxed = true),
|
||||
tokenName = mockk(relaxed = true),
|
||||
tokenIconState = mockk(relaxed = true),
|
||||
segmentedButtonConfig = persistentListOf(),
|
||||
|
|
|
|||
|
|
@ -3,26 +3,26 @@ package com.tangem.features.send.v2.send.confirm.model.transformers
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.amountScreen.models.AmountFieldModel
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.features.send.v2.api.entity.CustomFeeFieldUM
|
||||
import com.tangem.features.send.v2.common.ui.state.ConfirmUM
|
||||
import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeUM
|
||||
import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeSelectorUM
|
||||
import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeType
|
||||
import com.tangem.features.send.v2.api.entity.CustomFeeFieldUM
|
||||
import com.tangem.features.send.v2.subcomponents.fee.ui.state.FeeUM
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.math.BigDecimal
|
||||
import java.math.BigInteger
|
||||
import java.util.Locale
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
|
||||
class SendConfirmationNotificationsTransformerTest {
|
||||
|
||||
|
|
@ -205,7 +205,8 @@ class SendConfirmationNotificationsTransformerTest {
|
|||
isRedesignEnabled = false,
|
||||
title = mockk(relaxed = true),
|
||||
availableBalance = mockk(relaxed = true),
|
||||
availableBalanceShort = mockk(relaxed = true),
|
||||
availableBalanceCrypto = mockk(relaxed = true),
|
||||
availableBalanceFiat = mockk(relaxed = true),
|
||||
tokenName = mockk(relaxed = true),
|
||||
tokenIconState = mockk(relaxed = true),
|
||||
segmentedButtonConfig = persistentListOf(),
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ class SendConfirmationNotificationsTransformerV2Test {
|
|||
isRedesignEnabled = false,
|
||||
title = mockk(relaxed = true),
|
||||
availableBalance = mockk(relaxed = true),
|
||||
availableBalanceShort = mockk(relaxed = true),
|
||||
availableBalanceCrypto = mockk(relaxed = true),
|
||||
availableBalanceFiat = mockk(relaxed = true),
|
||||
tokenName = mockk(relaxed = true),
|
||||
tokenIconState = mockk(relaxed = true),
|
||||
segmentedButtonConfig = persistentListOf(),
|
||||
|
|
|
|||
|
|
@ -84,8 +84,10 @@ sealed class SwapAmountFieldUM {
|
|||
override val amountField: AmountState,
|
||||
val priceImpact: TextReference?,
|
||||
val title: TextReference,
|
||||
val subtitle: TextReference,
|
||||
val subtitleEllipsis: TextEllipsis,
|
||||
val subtitleLeft: TextReference,
|
||||
val subtitleRight: TextReference,
|
||||
val subtitleEllipsisLeft: TextEllipsis,
|
||||
val subtitleEllipsisRight: TextEllipsis,
|
||||
val isClickEnabled: Boolean,
|
||||
) : SwapAmountFieldUM()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,11 +331,11 @@ internal class SwapAmountModel @Inject constructor(
|
|||
|
||||
private fun subscribeOnBalanceHiddenUpdates() {
|
||||
params.isBalanceHidingFlow.onEach { isHidden ->
|
||||
val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
uiState.transformerUpdate(
|
||||
SwapAmountBalanceHiddenTransformer(
|
||||
isBalanceHidden = isHidden,
|
||||
isSingleWallet = isSingleWallet,
|
||||
isSingleWallet = isOnlyOneWallet,
|
||||
userWallet = userWallet,
|
||||
appCurrency = appCurrency,
|
||||
swapDirection = swapDirection,
|
||||
|
|
@ -351,7 +351,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
|
||||
val primaryCryptoCurrencyStatus = (uiState.value as? SwapAmountUM.Content)?.primaryCryptoCurrencyStatus
|
||||
if (primaryCryptoCurrencyStatus != null) {
|
||||
val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
uiState.transformerUpdate(
|
||||
SwapAmountPrimaryReadyStateTransformer(
|
||||
userWallet = userWallet,
|
||||
|
|
@ -361,7 +361,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
clickIntents = this,
|
||||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
showBestRateAnimation = showBestRateAnimation,
|
||||
isSingleWallet = isSingleWallet,
|
||||
isSingleWallet = isOnlyOneWallet,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
),
|
||||
)
|
||||
} else {
|
||||
val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
uiState.transformerUpdate(
|
||||
SwapAmountPrimaryReadyStateTransformer(
|
||||
userWallet = userWallet,
|
||||
|
|
@ -397,7 +397,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
clickIntents = this,
|
||||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
showBestRateAnimation = showBestRateAnimation,
|
||||
isSingleWallet = isSingleWallet,
|
||||
isSingleWallet = isOnlyOneWallet,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -495,7 +495,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
val primaryStatus = (uiState.value as? SwapAmountUM.Content)?.primaryCryptoCurrencyStatus
|
||||
if (secondaryStatus != null && primaryStatus != null) {
|
||||
initCurrencies(primaryStatus, secondaryStatus)
|
||||
val isSingleWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1
|
||||
uiState.transformerUpdate(
|
||||
SwapAmountSecondaryReadyStateTransformer(
|
||||
userWallet = userWallet,
|
||||
|
|
@ -507,7 +507,7 @@ internal class SwapAmountModel @Inject constructor(
|
|||
clickIntents = this@SwapAmountModel,
|
||||
isBalanceHidden = params.isBalanceHidingFlow.value,
|
||||
showBestRateAnimation = showBestRateAnimation,
|
||||
isSingleWallet = isSingleWallet,
|
||||
isSingleWallet = isOnlyOneWallet,
|
||||
),
|
||||
)
|
||||
startLoadingQuotesTask(isSilentReload = false)
|
||||
|
|
|
|||
|
|
@ -35,11 +35,13 @@ internal class SwapAmountFieldConverter(
|
|||
return SwapAmountFieldUM.Content(
|
||||
amountType = selectedType,
|
||||
title = stringReference(cryptoCurrencyStatus.currency.name),
|
||||
subtitle = getSubtitle(selectedType = selectedType, cryptoCurrencyStatus = cryptoCurrencyStatus),
|
||||
subtitleEllipsis = getSubtitleEllipsis(
|
||||
subtitleLeft = getSubtitleLeft(selectedType = selectedType, cryptoCurrencyStatus = cryptoCurrencyStatus),
|
||||
subtitleEllipsisLeft = getSubtitleEllipsisLeft(
|
||||
selectedType = selectedType,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
),
|
||||
subtitleRight = getSubtitleRight(selectedType = selectedType, cryptoCurrencyStatus = cryptoCurrencyStatus),
|
||||
subtitleEllipsisRight = TextEllipsis.OffsetEnd(appCurrency.symbol.length),
|
||||
priceImpact = null,
|
||||
isClickEnabled = selectedType.isViewingField(),
|
||||
amountField = AmountStateConverterV2(
|
||||
|
|
@ -67,36 +69,44 @@ internal class SwapAmountFieldConverter(
|
|||
)
|
||||
}
|
||||
|
||||
private fun getSubtitle(selectedType: SwapAmountType, cryptoCurrencyStatus: CryptoCurrencyStatus) = when {
|
||||
private fun getSubtitleLeft(selectedType: SwapAmountType, cryptoCurrencyStatus: CryptoCurrencyStatus) = when {
|
||||
selectedType.isEnteringField() -> combinedReference(
|
||||
stringReference(
|
||||
cryptoCurrencyStatus.value.amount.format {
|
||||
crypto(cryptoCurrency = cryptoCurrencyStatus.currency)
|
||||
},
|
||||
),
|
||||
stringReference(value = " $DOT "),
|
||||
stringReference(
|
||||
cryptoCurrencyStatus.value.fiatAmount.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
},
|
||||
),
|
||||
).orMaskWithStars(isBalanceHidden)
|
||||
selectedType.isViewingField() -> resourceReference(
|
||||
R.string.send_with_swap_recipient_get_amount,
|
||||
|
||||
)
|
||||
selectedType.isViewingField() -> resourceReference(R.string.send_with_swap_recipient_get_amount)
|
||||
else -> TextReference.Companion.EMPTY
|
||||
}
|
||||
|
||||
private fun getSubtitleEllipsis(selectedType: SwapAmountType, cryptoCurrencyStatus: CryptoCurrencyStatus) = when {
|
||||
selectedType.isEnteringField() -> TextEllipsis.OffsetEnd(cryptoCurrencyStatus.currency.symbol.length)
|
||||
selectedType.isViewingField() -> TextEllipsis.End
|
||||
else -> TextEllipsis.End
|
||||
private fun getSubtitleRight(selectedType: SwapAmountType, cryptoCurrencyStatus: CryptoCurrencyStatus) = when {
|
||||
selectedType.isEnteringField() -> if (isBalanceHidden) {
|
||||
TextReference.EMPTY
|
||||
} else {
|
||||
combinedReference(
|
||||
stringReference(value = " $DOT "),
|
||||
stringReference(
|
||||
cryptoCurrencyStatus.value.fiatAmount.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
else -> TextReference.EMPTY
|
||||
}
|
||||
|
||||
private fun getSubtitleEllipsisLeft(selectedType: SwapAmountType, cryptoCurrencyStatus: CryptoCurrencyStatus) =
|
||||
when {
|
||||
selectedType.isEnteringField() -> TextEllipsis.OffsetEnd(cryptoCurrencyStatus.currency.symbol.length)
|
||||
selectedType.isViewingField() -> TextEllipsis.End
|
||||
else -> TextEllipsis.End
|
||||
}
|
||||
|
||||
private fun SwapAmountType.isEnteringField(): Boolean {
|
||||
return this == SwapAmountType.From && swapDirection == SwapDirection.Direct ||
|
||||
this == SwapAmountType.To && swapDirection == SwapDirection.Reverse
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ private fun ConstraintLayoutScope.SwapAmountBlock(
|
|||
amountState = (amountUM.secondaryAmount.amountField as? AmountState.Data)?.copy(
|
||||
title = resourceReference(R.string.send_with_swap_recipient_amount_title),
|
||||
availableBalance = TextReference.EMPTY,
|
||||
availableBalanceShort = TextReference.EMPTY,
|
||||
availableBalanceCrypto = TextReference.EMPTY,
|
||||
) ?: amountUM.secondaryAmount.amountField,
|
||||
isClickDisabled = true,
|
||||
isEditingDisabled = false,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import androidx.constraintlayout.compose.ConstraintLayout
|
|||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.amountScreen.ui.AmountFieldV2
|
||||
import com.tangem.core.ui.components.SpacerH2
|
||||
import com.tangem.core.ui.components.SpacerWMax
|
||||
import com.tangem.core.ui.components.TextShimmer
|
||||
import com.tangem.core.ui.components.atoms.text.EllipsisText
|
||||
import com.tangem.core.ui.components.currency.icon.CurrencyIcon
|
||||
|
|
@ -248,8 +247,8 @@ private fun SwapAmountInfo(
|
|||
amountFieldUM = amountFieldUM,
|
||||
selectedQuote = selectedQuote,
|
||||
isSelectedAmountType = isSelectedAmountType,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
SpacerWMax()
|
||||
AnimatedContent(
|
||||
targetState = isSelectedAmountType,
|
||||
) { isSelected ->
|
||||
|
|
@ -294,12 +293,21 @@ private fun SwapAmountInfoMain(
|
|||
AnimatedContent(isSelectedAmountType) { isSelected ->
|
||||
if (isSelected && amountFieldUM is SwapAmountFieldUM.Content) {
|
||||
SpacerH2()
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitle.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsis,
|
||||
)
|
||||
Row {
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitleLeft.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsisLeft,
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
EllipsisText(
|
||||
text = amountFieldUM.subtitleRight.resolveReference(),
|
||||
style = TangemTheme.typography.caption2,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
ellipsis = amountFieldUM.subtitleEllipsisRight,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
AnimatedContent(selectedQuote) { quote ->
|
||||
when (quote) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountFieldUM
|
|||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountType
|
||||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
|
||||
import com.tangem.features.swap.v2.impl.common.entity.SwapQuoteUM
|
||||
import com.tangem.utils.StringsSigns
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -100,10 +101,12 @@ internal data object SwapAmountContentPreview {
|
|||
availableBalance = stringReference("Balance: 100 BTC"),
|
||||
),
|
||||
title = stringReference("Tether"),
|
||||
subtitle = stringReference("Balance: 100 BTC"),
|
||||
subtitleLeft = stringReference("11 101,123123456 BTC"),
|
||||
subtitleRight = stringReference(" ${StringsSigns.DOT} 1 212,12 $"),
|
||||
priceImpact = null,
|
||||
isClickEnabled = false,
|
||||
subtitleEllipsis = TextEllipsis.OffsetEnd(3),
|
||||
subtitleEllipsisLeft = TextEllipsis.OffsetEnd(3),
|
||||
subtitleEllipsisRight = TextEllipsis.OffsetEnd(1),
|
||||
),
|
||||
secondaryAmount = SwapAmountFieldUM.Content(
|
||||
amountType = SwapAmountType.To,
|
||||
|
|
@ -113,9 +116,11 @@ internal data object SwapAmountContentPreview {
|
|||
),
|
||||
title = stringReference("Shiba Inu"),
|
||||
priceImpact = stringReference("(-10%)"),
|
||||
subtitle = TextReference.EMPTY,
|
||||
subtitleLeft = TextReference.EMPTY,
|
||||
subtitleRight = TextReference.EMPTY,
|
||||
isClickEnabled = false,
|
||||
subtitleEllipsis = TextEllipsis.OffsetEnd(3),
|
||||
subtitleEllipsisLeft = TextEllipsis.End,
|
||||
subtitleEllipsisRight = TextEllipsis.End,
|
||||
),
|
||||
appCurrency = AppCurrency.Default,
|
||||
swapDirection = SwapDirection.Direct,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue