Updated on 2026-08-14
This commit is contained in:
parent
5a09e48a53
commit
e7f862423d
11 changed files with 52 additions and 16 deletions
|
|
@ -14,6 +14,7 @@ import com.tangem.core.decompose.model.getOrCreateModel
|
|||
import com.tangem.core.ui.extensions.conditional
|
||||
import com.tangem.features.send.v2.api.FeeSelectorBlockComponent
|
||||
import com.tangem.features.send.v2.api.FeeSelectorComponent
|
||||
import com.tangem.features.send.v2.api.SendFeatureToggles
|
||||
import com.tangem.features.send.v2.api.entity.FeeSelectorUM
|
||||
import com.tangem.features.send.v2.api.params.FeeSelectorParams
|
||||
import com.tangem.features.send.v2.feeselector.model.FeeSelectorModel
|
||||
|
|
@ -31,6 +32,7 @@ internal class DefaultFeeSelectorBlockComponent @AssistedInject constructor(
|
|||
@Assisted private val params: FeeSelectorParams.FeeSelectorBlockParams,
|
||||
@Assisted onResult: (feeSelectorUM: FeeSelectorUM) -> Unit,
|
||||
private val feeSelectorComponentFactory: FeeSelectorComponent.Factory,
|
||||
private val sendFeatureToggles: SendFeatureToggles,
|
||||
) : FeeSelectorBlockComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val model: FeeSelectorModel = getOrCreateModel(params = params)
|
||||
|
|
@ -80,6 +82,7 @@ internal class DefaultFeeSelectorBlockComponent @AssistedInject constructor(
|
|||
FeeSelectorBlockContent(
|
||||
state = state,
|
||||
onReadMoreClick = model::onReadMoreClicked,
|
||||
isGaslessFeatureEnabled = sendFeatureToggles.isGaslessTransactionsEnabled,
|
||||
modifier = modifier
|
||||
.conditional(isScreenSource && isNotSingleFee) {
|
||||
Modifier.clickable {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,11 @@ import com.tangem.blockchain.common.transaction.TransactionFee
|
|||
import com.tangem.common.ui.amountScreen.utils.getFiatString
|
||||
import com.tangem.core.ui.components.TextShimmer
|
||||
import com.tangem.core.ui.components.atoms.text.EllipsisText
|
||||
import com.tangem.core.ui.components.audits.AuditLabel
|
||||
import com.tangem.core.ui.components.audits.AuditLabelUM
|
||||
import com.tangem.core.ui.components.tooltip.TangemTooltip
|
||||
import com.tangem.core.ui.extensions.annotatedReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.format.bigdecimal.BigDecimalFormatConstants.EMPTY_BALANCE_SIGN
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
|
|
@ -51,6 +54,7 @@ private const val READ_MORE_TAG = "READ_MORE"
|
|||
@Composable
|
||||
internal fun FeeSelectorBlockContent(
|
||||
state: FeeSelectorUM,
|
||||
isGaslessFeatureEnabled: Boolean,
|
||||
onReadMoreClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
|
@ -69,16 +73,25 @@ internal fun FeeSelectorBlockContent(
|
|||
contentDescription = null,
|
||||
tint = TangemTheme.colors.icon.accent,
|
||||
)
|
||||
FeeSelectorDescription(state = state, onReadMoreClick = onReadMoreClick)
|
||||
FeeSelectorDescription(
|
||||
state = state,
|
||||
isGaslessFeatureEnabled = isGaslessFeatureEnabled,
|
||||
onReadMoreClick = onReadMoreClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FeeSelectorDescription(state: FeeSelectorUM, onReadMoreClick: () -> Unit, modifier: Modifier = Modifier) {
|
||||
private fun FeeSelectorDescription(
|
||||
state: FeeSelectorUM,
|
||||
isGaslessFeatureEnabled: Boolean,
|
||||
onReadMoreClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Row(modifier = modifier, horizontalArrangement = Arrangement.SpaceBetween) {
|
||||
FeeSelectorStaticPart(modifier = Modifier.weight(1f), onReadMoreClick = onReadMoreClick)
|
||||
when (state) {
|
||||
is FeeSelectorUM.Content -> FeeContent(state)
|
||||
is FeeSelectorUM.Content -> FeeContent(state, isGaslessFeatureEnabled)
|
||||
is FeeSelectorUM.Loading -> FeeLoading()
|
||||
is FeeSelectorUM.Error -> FeeError()
|
||||
}
|
||||
|
|
@ -161,9 +174,18 @@ private fun FeeLoading() {
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun FeeContent(state: FeeSelectorUM.Content, modifier: Modifier = Modifier) {
|
||||
private fun FeeContent(state: FeeSelectorUM.Content, isGaslessFeatureEnabled: Boolean, modifier: Modifier = Modifier) {
|
||||
val fiatRate = state.feeFiatRateUM
|
||||
Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
|
||||
if (isGaslessFeatureEnabled) {
|
||||
AuditLabel(
|
||||
state = AuditLabelUM(
|
||||
text = stringReference(state.selectedFeeItem.fee.amount.currencySymbol),
|
||||
type = AuditLabelUM.Type.General,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
EllipsisText(
|
||||
text = if (state.feeExtraInfo.isFeeConvertibleToFiat && fiatRate != null) {
|
||||
getFiatString(
|
||||
|
|
@ -206,13 +228,18 @@ private fun FeeContent(state: FeeSelectorUM.Content, modifier: Modifier = Modifi
|
|||
@Composable
|
||||
private fun FeeSelectorBlockContent_Preview(@PreviewParameter(FeeSelectorUMProvider::class) state: FeeSelectorUM) {
|
||||
TangemThemePreview {
|
||||
FeeSelectorBlockContent(modifier = Modifier.fillMaxWidth(), state = state, onReadMoreClick = {})
|
||||
FeeSelectorBlockContent(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
isGaslessFeatureEnabled = true,
|
||||
state = state,
|
||||
onReadMoreClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class FeeSelectorUMProvider : PreviewParameterProvider<FeeSelectorUM> {
|
||||
private val maxFeeItem = FeeItem.Market(
|
||||
fee = Fee.Common(amount = Amount(value = BigDecimal("100000000"), blockchain = Blockchain.Ethereum)),
|
||||
fee = Fee.Common(amount = Amount(value = BigDecimal("100000000"), blockchain = Blockchain.Hedera)),
|
||||
)
|
||||
private val lowFeeItem =
|
||||
FeeItem.Market(Fee.Common(amount = Amount(value = BigDecimal("0.0002876"), blockchain = Blockchain.Ethereum)))
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ private fun SendConvertTokenButton(onConvertToAnother: () -> Unit) {
|
|||
tint = TangemTheme.colors.icon.informative,
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.background(TangemTheme.colors.control.unchecked, CircleShape)
|
||||
.background(TangemTheme.colors.control.default, CircleShape)
|
||||
.padding(2.dp),
|
||||
)
|
||||
Text(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue