Updated on 2026-08-14

This commit is contained in:
Tangem 2022-11-07 20:25:35 +05:00
parent d3a1c61088
commit b128907197
5 changed files with 47 additions and 11 deletions

View file

@ -7,6 +7,7 @@ import com.tangem.tap.features.send.redux.SendScreenAction
import com.tangem.tap.features.send.redux.states.FeeState
import com.tangem.tap.features.send.redux.states.FeeType
import com.tangem.tap.features.send.redux.states.SendState
import com.tangem.tap.features.wallet.redux.ProgressState
/**
[REDACTED_AUTHOR]
@ -36,7 +37,7 @@ class FeeReducer : SendInternalReducer {
private fun handleAction(action: FeeAction, sendState: SendState, state: FeeState): SendState {
val result = when (action) {
is FeeAction.RequestFee -> {
state
state.copy(progressState = ProgressState.Loading)
}
is FeeAction.ChangeLayoutVisibility -> {
fun getVisibility(current: Boolean, proposed: Boolean?): Boolean = proposed ?: current
@ -68,12 +69,15 @@ class FeeReducer : SendInternalReducer {
currentFee = currentFee,
feeIsApproximate = isFeeApproximate(sendState),
)
}
}.copy(
progressState = ProgressState.Done,
)
}
FeeAction.FeeCalculation.ClearResult -> {
state.copy(
feeList = null,
currentFee = null,
progressState = ProgressState.Done,
)
}
}

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.send.redux.states
import com.tangem.blockchain.common.Amount
import com.tangem.tap.features.wallet.redux.ProgressState
import java.math.BigDecimal
/**
@ -20,6 +21,7 @@ data class FeeState(
val controlsLayoutIsVisible: Boolean = false,
val feeChipGroupIsVisible: Boolean = true,
val includeFeeSwitcherIsEnabled: Boolean = true,
val progressState: ProgressState = ProgressState.Done
) : SendScreenState {
override val stateId: StateId = StateId.FEE

View file

@ -11,6 +11,7 @@ import com.tangem.tap.common.extensions.beginDelayedTransition
import com.tangem.tap.common.extensions.enableError
import com.tangem.tap.common.extensions.getColor
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.extensions.hide
import com.tangem.tap.common.extensions.show
import com.tangem.tap.common.extensions.update
import com.tangem.tap.common.redux.getMessageString
@ -35,6 +36,7 @@ import com.tangem.tap.features.send.ui.SendFragment
import com.tangem.tap.features.send.ui.dialogs.RequestFeeErrorDialog
import com.tangem.tap.features.send.ui.dialogs.SendTransactionFailsDialog
import com.tangem.tap.features.send.ui.dialogs.TezosWarningDialog
import com.tangem.tap.features.wallet.redux.ProgressState
import com.tangem.tap.features.wallet.redux.WalletState.Companion.ROUGH_SIGN
import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.features.wallet.ui.adapters.WarningMessagesAdapter
@ -62,7 +64,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
StateId.TRANSACTION_EXTRAS -> handleTransactionExtrasState(fg, state.transactionExtrasState)
StateId.AMOUNT -> handleAmountState(fg, state.amountState)
StateId.FEE -> handleFeeState(fg, state.feeState)
StateId.RECEIPT -> handleReceiptState(fg, state.receiptState)
StateId.RECEIPT -> handleReceiptState(fg, state.receiptState, state.feeState.progressState)
}
}
}
@ -263,7 +265,11 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
if (chipGroup.checkedChipId != chipId && chipId != View.NO_ID) chipGroup.check(chipId)
}
private fun handleReceiptState(fg: SendFragment, state: ReceiptState) = with(fg.binding.clReceiptContainer) {
private fun handleReceiptState(
fg: SendFragment,
state: ReceiptState,
feeProgressState: ProgressState,
) = with(fg.binding.clReceiptContainer) {
val mainLayout = clReceiptContainer as ViewGroup
val totalLayout = llTotalContainer.llTotal as ViewGroup
val totalTokenLayout = llTotalContainer.flTotalTokenCrypto as ViewGroup
@ -274,11 +280,22 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
return if (value == UNKNOWN_AMOUNT_SIGN) value else "$ROUGH_SIGN $value"
}
when (feeProgressState) {
ProgressState.Loading -> {
tvReceiptFeeValue.hide()
pbReceiptFee.show()
}
ProgressState.Done -> {
pbReceiptFee.hide()
tvReceiptFeeValue.show()
}
}
when (state.visibleTypeOfReceipt) {
ReceiptLayoutType.FIAT -> {
val receipt = state.fiat ?: return
llTotalContainer.tvTotalValue
totalLayout.show(true)
totalTokenLayout.show(false)
tvReceiptAmountValue.update("${receipt.amountFiat} ${receipt.symbols.fiat}")
@ -290,7 +307,6 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
receipt.willSentCrypto, receipt.symbols.crypto,
)
llTotalContainer.tvWillBeSentValue.update(willSent)
}
ReceiptLayoutType.CRYPTO -> {
val receipt = state.crypto ?: return