From 5d9a6c9047b8731240d5a05925456a0860c4b1fa Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 8 Oct 2025 20:02:49 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../common/ui/amountScreen/ui/AmountBlock.kt | 12 +++++------ .../v2/send/confirm/model/SendConfirmModel.kt | 21 ++++++++++++------- .../destination/model/SendDestinationModel.kt | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlock.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlock.kt index 8e21c12dd9..62fe6dc051 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlock.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/ui/AmountBlock.kt @@ -20,21 +20,24 @@ import com.tangem.common.ui.amountScreen.models.AmountState import com.tangem.common.ui.amountScreen.preview.AmountStatePreviewData import com.tangem.core.ui.components.ResizableText import com.tangem.core.ui.components.currency.icon.CurrencyIcon -import com.tangem.core.ui.format.bigdecimal.anyDecimals import com.tangem.core.ui.format.bigdecimal.crypto import com.tangem.core.ui.format.bigdecimal.fiat import com.tangem.core.ui.format.bigdecimal.format import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.test.BaseAmountBlockTestTags -import java.math.BigDecimal @Composable fun AmountBlock(amountState: AmountState, isClickDisabled: Boolean, isEditingDisabled: Boolean, onClick: () -> Unit) { if (amountState !is AmountState.Data) return val amount = amountState.amountTextField - val cryptoAmount = formatWithSymbol(amount.value, amount.cryptoAmount.currencySymbol) + val cryptoAmount = amount.cryptoAmount.value.format { + crypto( + symbol = amount.cryptoAmount.currencySymbol, + decimals = amount.cryptoAmount.decimals, + ) + } val fiatAmount = amount.fiatAmount.value.format { fiat( fiatCurrencySymbol = amount.fiatAmount.currencySymbol, @@ -81,9 +84,6 @@ fun AmountBlock(amountState: AmountState, isClickDisabled: Boolean, isEditingDis } } -fun formatWithSymbol(amount: String, symbol: String) = - BigDecimal.ZERO.format { crypto(symbol, 0).anyDecimals() }.replace("0", amount) - // region Preview @Preview @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt index f5f0287872..414a66531b 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt @@ -56,15 +56,20 @@ import com.tangem.features.send.v2.common.ui.state.ConfirmUM import com.tangem.features.send.v2.impl.R import com.tangem.features.send.v2.send.analytics.SendAnalyticHelper import com.tangem.features.send.v2.send.confirm.SendConfirmComponent -import com.tangem.features.send.v2.send.confirm.model.transformers.* +import com.tangem.features.send.v2.send.confirm.model.transformers.SendConfirmInitialStateTransformer +import com.tangem.features.send.v2.send.confirm.model.transformers.SendConfirmSendingStateTransformer +import com.tangem.features.send.v2.send.confirm.model.transformers.SendConfirmSentStateTransformer +import com.tangem.features.send.v2.send.confirm.model.transformers.SendConfirmationNotificationsTransformerV2 import com.tangem.features.send.v2.send.ui.state.SendUM import com.tangem.features.send.v2.subcomponents.amount.SendAmountReduceTrigger import com.tangem.utils.coroutines.CoroutineDispatcherProvider import com.tangem.utils.extensions.orZero import com.tangem.utils.extensions.stripZeroPlainString import com.tangem.utils.transformer.update +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import timber.log.Timber import java.math.BigDecimal import javax.inject.Inject @@ -422,12 +427,14 @@ internal class SendConfirmModel @Inject constructor( val userWalletId = receivingUserWallet.userWalletId ?: return val network = receivingUserWallet.network ?: return - modelScope.launch { - addCryptoCurrenciesUseCase( - userWalletId = userWalletId, - cryptoCurrency = cryptoCurrency, - network = network, - ) + modelScope.launch(dispatchers.default) { + withContext(NonCancellable) { + addCryptoCurrenciesUseCase( + userWalletId = userWalletId, + cryptoCurrency = cryptoCurrency, + network = network, + ) + } } } diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt index fe0fbd389b..713ea50d93 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt @@ -220,7 +220,7 @@ internal class SendDestinationModel @Inject constructor( async { val addresses = if (!wallet.isMultiCurrency) { getCryptoCurrencyUseCase(wallet.walletId).getOrNull()?.let { - if (it.network.id == cryptoCurrencyNetwork.id) { + if (it.network.rawId == cryptoCurrencyNetwork.rawId) { getNetworkAddressesUseCase.invokeSync( userWalletId = wallet.walletId, networkRawId = it.network.id.rawId,