diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml
index ffb87108d1..7ed29ac733 100644
--- a/core/res/src/main/res/values-ru/strings.xml
+++ b/core/res/src/main/res/values-ru/strings.xml
@@ -91,7 +91,7 @@
Посмотреть историю транзакций
Обозреватель
Комиссия
- Сетевые комиссии – это плата пользователя за обработку и подтверждение транзакций. Размер комиссии зависит от нагрузка на сеть, объема транзакции и приоритета исполнения. %s
+ Сетевые комиссии – это плата пользователя за обработку и подтверждение транзакций. Размер комиссии зависит от нагрузки на сеть, объема транзакции и приоритета исполнения. %s
Подробнее
Свое
Быстро
@@ -495,6 +495,8 @@
Сумма отправки не может быть менее %1$s
Обратите внимание, что при определенных параметрах комиссии возможны задержки по вашей транзакции
Возможны задержки по транзакции
+ Уменьшить до [%s]
+ Уменьшить на [%s]
Необязательное
Последние
Получатель
diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml
index 23e26fd59a..6189bc5cbf 100644
--- a/core/res/src/main/res/values/strings.xml
+++ b/core/res/src/main/res/values/strings.xml
@@ -507,6 +507,8 @@
Due to %1$s limitations only %2$s UTXOs can fit in a single transaction. This means you can only send %3$s or less. You need to reduce the amount.
Existential deposit
The account will be wiped from the blockchain if a balance goes below the existential deposit. Please ensure that the remaining balance after sending will not be less than %s.
+ Reduce by [%s]
+ Reduce to [%s]
Optional
Please align your QR code with the square to scan it. Ensure you scan %s network address.
Recent
diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/custom/EthereumCustomFeeConverter.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/custom/EthereumCustomFeeConverter.kt
index 4be7b3acfb..bf12d6f398 100644
--- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/custom/EthereumCustomFeeConverter.kt
+++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/custom/EthereumCustomFeeConverter.kt
@@ -5,6 +5,7 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import com.tangem.blockchain.common.transaction.Fee
+import com.tangem.common.extensions.isZero
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
@@ -31,9 +32,10 @@ internal class EthereumCustomFeeConverter(
) : Converter> {
override fun convert(value: Fee.Ethereum): ImmutableList {
+ val feeValue = value.amount.value
return persistentListOf(
SendTextField.CustomFee(
- value = value.amount.value?.parseBigDecimal(value.amount.decimals).orEmpty(),
+ value = feeValue?.parseBigDecimal(value.amount.decimals).orEmpty(),
decimals = value.amount.decimals,
symbol = value.amount.currencySymbol,
onValueChange = { clickIntents.onCustomFeeValueChange(FEE_AMOUNT, it) },
@@ -43,7 +45,7 @@ internal class EthereumCustomFeeConverter(
),
title = resourceReference(R.string.send_max_fee),
footer = resourceReference(R.string.send_max_fee_footer),
- label = getFeeFormatted(value.amount.value),
+ label = getFeeFormatted(feeValue),
keyboardActions = KeyboardActions(),
),
SendTextField.CustomFee(
@@ -67,7 +69,7 @@ internal class EthereumCustomFeeConverter(
footer = resourceReference(R.string.send_gas_limit_footer),
onValueChange = { clickIntents.onCustomFeeValueChange(GAS_LIMIT, it) },
keyboardOptions = KeyboardOptions(
- imeAction = ImeAction.Done,
+ imeAction = if (checkExceedBalance(feeValue)) ImeAction.None else ImeAction.Done,
keyboardType = KeyboardType.Number,
),
keyboardActions = KeyboardActions(onDone = { clickIntents.onNextClick() }),
@@ -133,7 +135,16 @@ internal class EthereumCustomFeeConverter(
label = getFeeFormatted(newFeeAmount),
),
)
- set(index, this[index].copy(value = value))
+ set(
+ index,
+ this[index].copy(
+ value = value,
+ keyboardOptions = KeyboardOptions(
+ imeAction = if (!checkExceedBalance(newFeeAmount)) ImeAction.None else ImeAction.Done,
+ keyboardType = KeyboardType.Number,
+ ),
+ ),
+ )
}
}
}.toImmutableList()
@@ -152,6 +163,13 @@ internal class EthereumCustomFeeConverter(
)
}
+ private fun checkExceedBalance(feeAmount: BigDecimal?): Boolean {
+ val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
+ val currencyCryptoAmount = cryptoCurrencyStatus.value.amount ?: BigDecimal.ZERO
+
+ return feeAmount == null || feeAmount.isZero() || feeAmount > currencyCryptoAmount
+ }
+
companion object {
private const val ETHEREUM_GAS_UNIT = "GWEI"
private const val ETHEREUM_GAS_DECIMALS = 18
diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldChangeConverter.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldChangeConverter.kt
index b9bfa076bd..630a026952 100644
--- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldChangeConverter.kt
+++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldChangeConverter.kt
@@ -1,5 +1,8 @@
package com.tangem.features.send.impl.presentation.state.fields
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.text.input.KeyboardType
import com.tangem.common.extensions.isZero
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.core.ui.utils.parseToBigDecimal
@@ -43,6 +46,10 @@ internal class SendAmountFieldChangeConverter(
isError = isExceedBalance,
cryptoAmount = amountTextField.cryptoAmount.copy(value = decimalCryptoValue),
fiatAmount = amountTextField.fiatAmount.copy(value = decimalFiatValue),
+ keyboardOptions = KeyboardOptions(
+ imeAction = if (!isExceedBalance) ImeAction.Done else ImeAction.None,
+ keyboardType = KeyboardType.Number,
+ ),
),
),
feeState = feeState.copy(
diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldConverter.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldConverter.kt
index 83701146e2..ff622738f7 100644
--- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldConverter.kt
+++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldConverter.kt
@@ -5,6 +5,7 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import com.tangem.blockchain.extensions.toBigDecimalOrDefault
+import com.tangem.common.extensions.isZero
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.domain.appcurrency.model.AppCurrency
@@ -36,12 +37,13 @@ internal class SendAmountFieldConverter(
val fiatDecimal = cryptoCurrencyStatus.value.fiatRate?.multiply(cryptoDecimal) ?: BigDecimal.ZERO
fiatDecimal.parseBigDecimal(FIAT_DECIMALS)
}
+ val isDoneActionEnabled = !cryptoDecimal.isZero()
return SendTextField.AmountField(
value = value,
fiatValue = fiatValue,
onValueChange = clickIntents::onAmountValueChange,
keyboardOptions = KeyboardOptions(
- imeAction = ImeAction.Done,
+ imeAction = if (isDoneActionEnabled) ImeAction.Done else ImeAction.None,
keyboardType = KeyboardType.Number,
),
keyboardActions = KeyboardActions(onDone = { clickIntents.onNextClick() }),
diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldMaxAmountConverter.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldMaxAmountConverter.kt
index 1a9a4d6def..f6875731d7 100644
--- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldMaxAmountConverter.kt
+++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fields/SendAmountFieldMaxAmountConverter.kt
@@ -1,5 +1,8 @@
package com.tangem.features.send.impl.presentation.state.fields
+import androidx.compose.foundation.text.KeyboardOptions
+import androidx.compose.ui.text.input.ImeAction
+import androidx.compose.ui.text.input.KeyboardType
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.features.send.impl.presentation.state.SendUiState
@@ -26,6 +29,7 @@ internal class SendAmountFieldMaxAmountConverter(
if (decimalCryptoValue.isNullOrZero()) return state
+ val isDoneActionEnabled = !decimalCryptoValue.isNullOrZero()
val cryptoValue = decimalCryptoValue?.parseBigDecimal(cryptoDecimals).orEmpty()
val fiatValue = decimalFiatValue?.parseBigDecimal(fiatDecimals).orEmpty()
return state.copy(
@@ -37,6 +41,10 @@ internal class SendAmountFieldMaxAmountConverter(
isError = false,
cryptoAmount = amountTextField.cryptoAmount.copy(value = decimalCryptoValue),
fiatAmount = amountTextField.fiatAmount.copy(value = decimalFiatValue),
+ keyboardOptions = KeyboardOptions(
+ imeAction = if (isDoneActionEnabled) ImeAction.Done else ImeAction.None,
+ keyboardType = KeyboardType.Number,
+ ),
),
),
feeState = feeState.copy(