Updated on 2026-08-14
This commit is contained in:
parent
56bd0638f2
commit
6abbcbb921
5 changed files with 57 additions and 10 deletions
|
|
@ -113,6 +113,7 @@ internal sealed class SendStates {
|
|||
val isFeeApproximate: Boolean,
|
||||
val isCustomSelected: Boolean,
|
||||
val notifications: ImmutableList<SendNotification>,
|
||||
val isTronToken: Boolean,
|
||||
) : SendStates()
|
||||
|
||||
/** Send state */
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.tangem.features.send.impl.presentation.state.fee
|
||||
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
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.converter.Converter
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -23,6 +25,8 @@ internal class SendFeeStateConverter(
|
|||
isFeeApproximate = false,
|
||||
isCustomSelected = false,
|
||||
isFeeConvertibleToFiat = cryptoCurrencyStatusProvider().currency.network.hasFiatFeeRate,
|
||||
isTronToken = cryptoCurrencyStatusProvider().currency is CryptoCurrency.Token &&
|
||||
isTron(cryptoCurrencyStatusProvider().currency.network.id.value),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -83,6 +83,7 @@ internal object FeeStatePreviewData {
|
|||
notifications = persistentListOf(),
|
||||
isCustomSelected = false,
|
||||
isFeeConvertibleToFiat = true,
|
||||
isTronToken = false,
|
||||
)
|
||||
|
||||
val feeChoosableState = feeState.copy(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
|
|||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
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.ui.SendDoneButtons
|
||||
import com.tangem.common.ui.amountScreen.utils.getFiatString
|
||||
|
|
@ -187,14 +188,23 @@ private fun SendingText(
|
|||
fiatCurrencyCode = feeState.appCurrency.code,
|
||||
)
|
||||
val textResource = remember(uiState) {
|
||||
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()),
|
||||
)
|
||||
val fee = feeState.fee
|
||||
if (feeState.isTronToken && fee is Fee.Tron) {
|
||||
getTokenFeeSendingText(
|
||||
feeState = feeState,
|
||||
fee = fee,
|
||||
sendingValue = sendingValue,
|
||||
)
|
||||
} 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 = textResource.resolveAnnotatedReference(),
|
||||
|
|
@ -260,4 +270,35 @@ private fun isButtonEnabled(currentState: SendUiCurrentScreen, uiState: SendUiSt
|
|||
SendUiStateType.EditFee -> uiState.editFeeState?.isPrimaryButtonEnabled
|
||||
else -> true
|
||||
} ?: 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(", ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue