Updated on 2026-08-14
This commit is contained in:
parent
3d608c7823
commit
5d9a6c9047
3 changed files with 21 additions and 14 deletions
|
|
@ -20,21 +20,24 @@ import com.tangem.common.ui.amountScreen.models.AmountState
|
||||||
import com.tangem.common.ui.amountScreen.preview.AmountStatePreviewData
|
import com.tangem.common.ui.amountScreen.preview.AmountStatePreviewData
|
||||||
import com.tangem.core.ui.components.ResizableText
|
import com.tangem.core.ui.components.ResizableText
|
||||||
import com.tangem.core.ui.components.currency.icon.CurrencyIcon
|
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.crypto
|
||||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||||
import com.tangem.core.ui.format.bigdecimal.format
|
import com.tangem.core.ui.format.bigdecimal.format
|
||||||
import com.tangem.core.ui.res.TangemTheme
|
import com.tangem.core.ui.res.TangemTheme
|
||||||
import com.tangem.core.ui.res.TangemThemePreview
|
import com.tangem.core.ui.res.TangemThemePreview
|
||||||
import com.tangem.core.ui.test.BaseAmountBlockTestTags
|
import com.tangem.core.ui.test.BaseAmountBlockTestTags
|
||||||
import java.math.BigDecimal
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AmountBlock(amountState: AmountState, isClickDisabled: Boolean, isEditingDisabled: Boolean, onClick: () -> Unit) {
|
fun AmountBlock(amountState: AmountState, isClickDisabled: Boolean, isEditingDisabled: Boolean, onClick: () -> Unit) {
|
||||||
if (amountState !is AmountState.Data) return
|
if (amountState !is AmountState.Data) return
|
||||||
val amount = amountState.amountTextField
|
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 {
|
val fiatAmount = amount.fiatAmount.value.format {
|
||||||
fiat(
|
fiat(
|
||||||
fiatCurrencySymbol = amount.fiatAmount.currencySymbol,
|
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
|
// region Preview
|
||||||
@Preview
|
@Preview
|
||||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||||
|
|
|
||||||
|
|
@ -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.impl.R
|
||||||
import com.tangem.features.send.v2.send.analytics.SendAnalyticHelper
|
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.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.send.ui.state.SendUM
|
||||||
import com.tangem.features.send.v2.subcomponents.amount.SendAmountReduceTrigger
|
import com.tangem.features.send.v2.subcomponents.amount.SendAmountReduceTrigger
|
||||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||||
import com.tangem.utils.extensions.orZero
|
import com.tangem.utils.extensions.orZero
|
||||||
import com.tangem.utils.extensions.stripZeroPlainString
|
import com.tangem.utils.extensions.stripZeroPlainString
|
||||||
import com.tangem.utils.transformer.update
|
import com.tangem.utils.transformer.update
|
||||||
|
import kotlinx.coroutines.NonCancellable
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -422,12 +427,14 @@ internal class SendConfirmModel @Inject constructor(
|
||||||
val userWalletId = receivingUserWallet.userWalletId ?: return
|
val userWalletId = receivingUserWallet.userWalletId ?: return
|
||||||
val network = receivingUserWallet.network ?: return
|
val network = receivingUserWallet.network ?: return
|
||||||
|
|
||||||
modelScope.launch {
|
modelScope.launch(dispatchers.default) {
|
||||||
addCryptoCurrenciesUseCase(
|
withContext(NonCancellable) {
|
||||||
userWalletId = userWalletId,
|
addCryptoCurrenciesUseCase(
|
||||||
cryptoCurrency = cryptoCurrency,
|
userWalletId = userWalletId,
|
||||||
network = network,
|
cryptoCurrency = cryptoCurrency,
|
||||||
)
|
network = network,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ internal class SendDestinationModel @Inject constructor(
|
||||||
async {
|
async {
|
||||||
val addresses = if (!wallet.isMultiCurrency) {
|
val addresses = if (!wallet.isMultiCurrency) {
|
||||||
getCryptoCurrencyUseCase(wallet.walletId).getOrNull()?.let {
|
getCryptoCurrencyUseCase(wallet.walletId).getOrNull()?.let {
|
||||||
if (it.network.id == cryptoCurrencyNetwork.id) {
|
if (it.network.rawId == cryptoCurrencyNetwork.rawId) {
|
||||||
getNetworkAddressesUseCase.invokeSync(
|
getNetworkAddressesUseCase.invokeSync(
|
||||||
userWalletId = wallet.walletId,
|
userWalletId = wallet.walletId,
|
||||||
networkRawId = it.network.id.rawId,
|
networkRawId = it.network.id.rawId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue