From d83a31a9b02944178ff5debfe50536a3dc7493c7 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 1 Sep 2025 18:11:11 +0500 Subject: [PATCH 1/2] Updated on 2026-08-14 --- .../converters/AmountStateConverter.kt | 19 ++++--- .../field/AmountBoundaryUpdateTransformer.kt | 16 +++--- .../ui/amountScreen/models/AmountState.kt | 7 ++- .../preview/AmountStatePreviewData.kt | 13 ++--- .../ui/amountScreen/ui/AmountBlockV2.kt | 2 +- .../amountScreen/ui/AmountFieldContainer.kt | 28 +++++++---- .../ui/components/atoms/text/EllipsisText.kt | 30 ++++++++--- .../amount/model/SendAmountModel.kt | 4 +- ...NotificationsTransformersComparisonTest.kt | 3 +- ...onfirmationNotificationsTransformerTest.kt | 15 +++--- ...firmationNotificationsTransformerV2Test.kt | 3 +- .../v2/impl/amount/entity/SwapAmountUM.kt | 6 ++- .../v2/impl/amount/model/SwapAmountModel.kt | 16 +++--- .../converter/SwapAmountFieldConverter.kt | 50 +++++++++++-------- .../impl/amount/ui/SwapAmountBlockContent.kt | 2 +- .../v2/impl/amount/ui/SwapAmountContent.kt | 24 ++++++--- .../ui/preview/SwapAmountContentPreview.kt | 13 +++-- 17 files changed, 159 insertions(+), 92 deletions(-) diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountStateConverter.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountStateConverter.kt index 8212806067..c3b284e828 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountStateConverter.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountStateConverter.kt @@ -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), diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/field/AmountBoundaryUpdateTransformer.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/field/AmountBoundaryUpdateTransformer.kt index 9639c7f781..90204d2c9f 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/field/AmountBoundaryUpdateTransformer.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/field/AmountBoundaryUpdateTransformer.kt @@ -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), + ) + }, ) } } \ No newline at end of file diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/models/AmountState.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/models/AmountState.kt index cac4628783..a063b984f5 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/models/AmountState.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/models/AmountState.kt @@ -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, diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/preview/AmountStatePreviewData.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/preview/AmountStatePreviewData.kt index 281270d273..fca332d04e 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/preview/AmountStatePreviewData.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/preview/AmountStatePreviewData.kt @@ -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( 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 979a1a4419..ebb5f3feba 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 @@ -64,7 +64,7 @@ fun AmountBlockV2( AmountBlockV2( title = amountState.title, - balance = amountState.availableBalanceShort, + balance = amountState.availableBalanceCrypto, currencyTitle = currencyTitle, currencyIconState = amountState.tokenIconState, firstAmount = firstAmount, diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountFieldContainer.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountFieldContainer.kt index ea0473e930..d831aad665 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountFieldContainer.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountFieldContainer.kt @@ -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), + ) + } } } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt index 6a851a2abf..019f33a4b6 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/text/EllipsisText.kt @@ -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, + ) + } } } } diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt index b69ef65add..edf9d9aa4f 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt @@ -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( diff --git a/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmNotificationsTransformersComparisonTest.kt b/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmNotificationsTransformersComparisonTest.kt index 4c7c95d94f..929e59f708 100644 --- a/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmNotificationsTransformersComparisonTest.kt +++ b/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmNotificationsTransformersComparisonTest.kt @@ -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(), diff --git a/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerTest.kt b/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerTest.kt index 020d3afcab..a0c7096cb7 100644 --- a/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerTest.kt +++ b/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerTest.kt @@ -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(), diff --git a/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerV2Test.kt b/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerV2Test.kt index 6903fc2550..15b4768aaa 100644 --- a/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerV2Test.kt +++ b/features/send-v2/impl/src/test/java/com/tangem/features/send/v2/send/confirm/model/transformers/SendConfirmationNotificationsTransformerV2Test.kt @@ -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(), 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 147e318a85..b2d95fed03 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 @@ -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() } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt index b2e38a4172..ca3b3093f2 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt @@ -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) 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 1962a4d356..832a1c2a7d 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 @@ -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 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 f7129e04bc..bc921fd483 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 @@ -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, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt index 41957bf386..119255fe91 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/ui/SwapAmountContent.kt @@ -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) { 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 02419e0cd6..3e6da5d36b 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 @@ -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, From 41862d07ee097275ef3fcce636a4018aaecb5cea Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 1 Sep 2025 13:11:29 +0000 Subject: [PATCH 2/2] Updated on 2026-08-14 --- gradle/tangem_dependencies.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/tangem_dependencies.toml b/gradle/tangem_dependencies.toml index 05f6e8b112..33e667f9d0 100644 --- a/gradle/tangem_dependencies.toml +++ b/gradle/tangem_dependencies.toml @@ -5,13 +5,13 @@ # https://github.com/tangem/tangem-sdk-android/ # https://github.com/tangem/vico -tangemBlockchainSdk = "releases-5.28-1211" +tangemBlockchainSdk = "develop-1212" #tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds -tangemCardSdk = "releases-5.28-559" +tangemCardSdk = "develop-560" #tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^ tangemVico = "2.0.0-alpha.25-tangem12" #tangemVico = "0.0.1" # Keep it! - used for local builds ^ -tangemHotSdk = "develop-461" +tangemHotSdk = "develop-525" #tangemHotSdk = "0.0.1" # Keep it! - used for local builds ^