Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-08 20:02:49 +05:00
parent 3d608c7823
commit 5d9a6c9047
3 changed files with 21 additions and 14 deletions

View file

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

View file

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

View file

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