Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-16 20:13:40 +03:00
parent 56bd0638f2
commit 6abbcbb921
5 changed files with 57 additions and 10 deletions

@ -1 +1 @@
Subproject commit 57484a0139299d1229872c626b2c9cb34442038c Subproject commit 328c13826f7e52ba783db1ba39de5b17b1b79bc5

View file

@ -113,6 +113,7 @@ internal sealed class SendStates {
val isFeeApproximate: Boolean, val isFeeApproximate: Boolean,
val isCustomSelected: Boolean, val isCustomSelected: Boolean,
val notifications: ImmutableList<SendNotification>, val notifications: ImmutableList<SendNotification>,
val isTronToken: Boolean,
) : SendStates() ) : SendStates()
/** Send state */ /** Send state */

View file

@ -1,8 +1,10 @@
package com.tangem.features.send.impl.presentation.state.fee package com.tangem.features.send.impl.presentation.state.fee
import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.features.send.impl.presentation.state.SendStates import com.tangem.features.send.impl.presentation.state.SendStates
import com.tangem.lib.crypto.BlockchainUtils.isTron
import com.tangem.utils.Provider import com.tangem.utils.Provider
import com.tangem.utils.converter.Converter import com.tangem.utils.converter.Converter
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
@ -23,6 +25,8 @@ internal class SendFeeStateConverter(
isFeeApproximate = false, isFeeApproximate = false,
isCustomSelected = false, isCustomSelected = false,
isFeeConvertibleToFiat = cryptoCurrencyStatusProvider().currency.network.hasFiatFeeRate, isFeeConvertibleToFiat = cryptoCurrencyStatusProvider().currency.network.hasFiatFeeRate,
isTronToken = cryptoCurrencyStatusProvider().currency is CryptoCurrency.Token &&
isTron(cryptoCurrencyStatusProvider().currency.network.id.value),
) )
} }
} }

View file

@ -83,6 +83,7 @@ internal object FeeStatePreviewData {
notifications = persistentListOf(), notifications = persistentListOf(),
isCustomSelected = false, isCustomSelected = false,
isFeeConvertibleToFiat = true, isFeeConvertibleToFiat = true,
isTronToken = false,
) )
val feeChoosableState = feeState.copy( val feeChoosableState = feeState.copy(

View file

@ -20,6 +20,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import com.tangem.blockchain.common.transaction.Fee
import com.tangem.common.ui.amountScreen.models.AmountState import com.tangem.common.ui.amountScreen.models.AmountState
import com.tangem.common.ui.amountScreen.ui.SendDoneButtons import com.tangem.common.ui.amountScreen.ui.SendDoneButtons
import com.tangem.common.ui.amountScreen.utils.getFiatString import com.tangem.common.ui.amountScreen.utils.getFiatString
@ -187,14 +188,23 @@ private fun SendingText(
fiatCurrencyCode = feeState.appCurrency.code, fiatCurrencyCode = feeState.appCurrency.code,
) )
val textResource = remember(uiState) { val textResource = remember(uiState) {
resourceReference( val fee = feeState.fee
id = if (feeState.isFeeConvertibleToFiat) { if (feeState.isTronToken && fee is Fee.Tron) {
R.string.send_summary_transaction_description getTokenFeeSendingText(
} else { feeState = feeState,
R.string.send_summary_transaction_description_no_fiat_fee fee = fee,
}, sendingValue = sendingValue,
formatArgs = wrappedList(sendingValue, feeState.getFiatValue()), )
) } else {
resourceReference(
id = if (feeState.isFeeConvertibleToFiat) {
R.string.send_summary_transaction_description
} else {
R.string.send_summary_transaction_description_no_fiat_fee
},
formatArgs = wrappedList(sendingValue, feeState.getFiatValue()),
)
}
} }
Text( Text(
text = textResource.resolveAnnotatedReference(), text = textResource.resolveAnnotatedReference(),
@ -260,4 +270,35 @@ private fun isButtonEnabled(currentState: SendUiCurrentScreen, uiState: SendUiSt
SendUiStateType.EditFee -> uiState.editFeeState?.isPrimaryButtonEnabled SendUiStateType.EditFee -> uiState.editFeeState?.isPrimaryButtonEnabled
else -> true else -> true
} ?: false } ?: false
} }
private fun getTokenFeeSendingText(feeState: SendStates.FeeState, fee: Fee.Tron, sendingValue: String): TextReference {
val suffix = when {
fee.feeEnergy == 0L -> {
resourceReference(
R.string.send_summary_transaction_description_suffix_including,
wrappedList(feeState.getFiatValue()),
)
}
fee.feeEnergy <= fee.remainingEnergy -> {
resourceReference(
R.string.send_summary_transaction_description_suffix_fee_covered,
wrappedList(fee.feeEnergy),
)
}
else -> {
resourceReference(
R.string.send_summary_transaction_description_suffix_fee_reduced,
wrappedList(fee.remainingEnergy),
)
}
}
val prefix = resourceReference(
R.string.send_summary_transaction_description_prefix,
wrappedList(sendingValue),
)
return combinedReference(prefix, COMMA_SEPARATOR, suffix)
}
private val COMMA_SEPARATOR = stringReference(", ")