Updated on 2026-08-14
This commit is contained in:
parent
0e42927a62
commit
398c3a4fde
6 changed files with 87 additions and 24 deletions
|
|
@ -303,12 +303,13 @@ internal class DefaultSendComponent @AssistedInject constructor(
|
|||
val isEmptyStack = childStack.value.backStack.isEmpty()
|
||||
val isSuccess = model.uiState.value.confirmUM is ConfirmUM.Success
|
||||
val isStubComponent = childStack.value.active.instance is StubComponent
|
||||
val isSendingInProgress = (model.uiState.value.confirmUM as? ConfirmUM.Content)?.isSending == true
|
||||
|
||||
val isPopSend = isEmptyRoute || isEmptyStack || isSuccess || isStubComponent
|
||||
if (isPopSend) {
|
||||
router.pop()
|
||||
} else {
|
||||
stackNavigation.pop()
|
||||
when {
|
||||
isSendingInProgress -> Unit // Do not anything while transaction sending in progress
|
||||
isPopSend -> router.pop()
|
||||
else -> stackNavigation.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -215,11 +215,13 @@ internal class DefaultNFTSendComponent @AssistedInject constructor(
|
|||
val isEmptyRoute = childStack.value.active.configuration == CommonSendRoute.Empty
|
||||
val isEmptyStack = childStack.value.backStack.isEmpty()
|
||||
val isSuccess = model.uiState.value.confirmUM is ConfirmUM.Success
|
||||
val isSendingInProgress = (model.uiState.value.confirmUM as? ConfirmUM.Content)?.isSending == true
|
||||
|
||||
if (isEmptyRoute || isEmptyStack || isSuccess) {
|
||||
router.pop()
|
||||
} else {
|
||||
stackNavigation.pop()
|
||||
val isPopSend = isEmptyRoute || isEmptyStack || isSuccess
|
||||
when {
|
||||
isSendingInProgress -> Unit // Do not anything while transaction sending in progress
|
||||
isPopSend -> router.pop()
|
||||
else -> stackNavigation.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import com.tangem.features.swap.v2.impl.amount.SwapAmountComponent
|
|||
import com.tangem.features.swap.v2.impl.amount.SwapAmountComponentParams
|
||||
import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM
|
||||
import com.tangem.features.swap.v2.impl.common.SwapUtils.SEND_WITH_SWAP_PROVIDER_TYPES
|
||||
import com.tangem.features.swap.v2.impl.common.entity.ConfirmUM
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.confirm.SendWithSwapConfirmComponent
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.model.SendWithSwapModel
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.success.SendWithSwapSuccessComponent
|
||||
|
|
@ -202,11 +203,15 @@ internal class DefaultSendWithSwapComponent @AssistedInject constructor(
|
|||
|
||||
private fun onChildBack() {
|
||||
val isEmptyStack = childStack.value.backStack.isEmpty()
|
||||
val isSuccess = model.uiState.value.confirmUM is ConfirmUM.Success
|
||||
val isSendingInProgress = (model.uiState.value.confirmUM as? ConfirmUM.Content)?.isTransactionInProcess == true
|
||||
|
||||
if (isEmptyStack) {
|
||||
router.pop()
|
||||
} else {
|
||||
stackNavigation.pop()
|
||||
val isPopSend = isEmptyStack || isSuccess
|
||||
|
||||
when {
|
||||
isSendingInProgress -> Unit // Do not anything while transaction sending in progress
|
||||
isPopSend -> router.pop()
|
||||
else -> stackNavigation.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ import com.tangem.features.swap.v2.impl.sendviaswap.SendWithSwapRoute
|
|||
import com.tangem.features.swap.v2.impl.sendviaswap.analytics.SendWithSwapAnalyticEvents
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.confirm.SendWithSwapConfirmComponent
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.confirm.model.transformers.SendWithSwapConfirmInitialStateTransformer
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.confirm.model.transformers.SendWithSwapConfirmSendingStateTransformer
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.confirm.model.transformers.SendWithSwapConfirmSentStateTransformer
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.confirm.model.transformers.SendWithSwapConfirmationNotificationsTransformer
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.entity.SendWithSwapUM
|
||||
import com.tangem.lib.crypto.BlockchainFeeUtils.patchTransactionFeeForSwap
|
||||
|
|
@ -241,10 +243,12 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
private fun onSendClick() {
|
||||
val provider = confirmData.quote?.provider ?: return
|
||||
modelScope.launch {
|
||||
uiState.transformerUpdate(SendWithSwapConfirmSendingStateTransformer(true))
|
||||
swapTransactionSender.sendTransaction(
|
||||
confirmData = confirmData,
|
||||
isAmountSubtractAvailable = isAmountSubtractAvailable,
|
||||
onExpressError = { expressError ->
|
||||
uiState.transformerUpdate(SendWithSwapConfirmSendingStateTransformer(false))
|
||||
swapAlertFactory.getGenericErrorState(
|
||||
expressError = expressError,
|
||||
onFailedTxEmailClick = {
|
||||
|
|
@ -261,6 +265,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
)
|
||||
},
|
||||
onSendError = { error ->
|
||||
uiState.transformerUpdate(SendWithSwapConfirmSendingStateTransformer(false))
|
||||
swapAlertFactory.getSendTransactionErrorState(
|
||||
error = error,
|
||||
onFailedTxEmailClick = {
|
||||
|
|
@ -282,17 +287,14 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
networkId = primaryCurrencyStatus.currency.network.id,
|
||||
).getOrNull().orEmpty()
|
||||
sendSuccessAnalytics()
|
||||
uiState.update {
|
||||
it.copy(
|
||||
confirmUM = ConfirmUM.Success(
|
||||
isPrimaryButtonEnabled = true,
|
||||
transactionDate = timestamp,
|
||||
txUrl = txUrl,
|
||||
provider = provider,
|
||||
swapDataModel = data,
|
||||
),
|
||||
)
|
||||
}
|
||||
uiState.transformerUpdate(
|
||||
SendWithSwapConfirmSentStateTransformer(
|
||||
timestamp = timestamp,
|
||||
txUrl = txUrl,
|
||||
provider = provider,
|
||||
swapDataModel = data,
|
||||
),
|
||||
)
|
||||
router.replaceAll(SendWithSwapRoute.Success)
|
||||
},
|
||||
expressOperationType = ExpressOperationType.SEND_WITH_SWAP,
|
||||
|
|
@ -428,7 +430,15 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
backIconRes = R.drawable.ic_back_24,
|
||||
backIconClick = router::pop,
|
||||
primaryButton = NavigationButton(
|
||||
textReference = resourceReference(R.string.common_send),
|
||||
textReference = when (confirmUM) {
|
||||
is ConfirmUM.Success -> resourceReference(R.string.common_close)
|
||||
is ConfirmUM.Content -> if (confirmUM.isTransactionInProcess) {
|
||||
resourceReference(R.string.send_sending)
|
||||
} else {
|
||||
resourceReference(R.string.common_send)
|
||||
}
|
||||
else -> resourceReference(R.string.common_send)
|
||||
},
|
||||
iconRes = R.drawable.ic_tangem_24,
|
||||
isIconVisible = isReadyToSend,
|
||||
isHapticClick = isReadyToSend,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.tangem.features.swap.v2.impl.sendviaswap.confirm.model.transformers
|
||||
|
||||
import com.tangem.features.swap.v2.impl.common.entity.ConfirmUM
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.entity.SendWithSwapUM
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
internal class SendWithSwapConfirmSendingStateTransformer(
|
||||
private val isTransactionInProcess: Boolean,
|
||||
) : Transformer<SendWithSwapUM> {
|
||||
override fun transform(prevState: SendWithSwapUM): SendWithSwapUM {
|
||||
val confirmUM = prevState.confirmUM as? ConfirmUM.Content ?: return prevState
|
||||
return prevState.copy(
|
||||
confirmUM = confirmUM.copy(
|
||||
isPrimaryButtonEnabled = !isTransactionInProcess,
|
||||
isTransactionInProcess = isTransactionInProcess,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.tangem.features.swap.v2.impl.sendviaswap.confirm.model.transformers
|
||||
|
||||
import com.tangem.domain.express.models.ExpressProvider
|
||||
import com.tangem.domain.swap.models.SwapDataModel
|
||||
import com.tangem.features.swap.v2.impl.common.entity.ConfirmUM
|
||||
import com.tangem.features.swap.v2.impl.sendviaswap.entity.SendWithSwapUM
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
internal class SendWithSwapConfirmSentStateTransformer(
|
||||
private val txUrl: String,
|
||||
private val timestamp: Long,
|
||||
private val provider: ExpressProvider,
|
||||
private val swapDataModel: SwapDataModel,
|
||||
) : Transformer<SendWithSwapUM> {
|
||||
override fun transform(prevState: SendWithSwapUM): SendWithSwapUM {
|
||||
return prevState.copy(
|
||||
confirmUM = ConfirmUM.Success(
|
||||
isPrimaryButtonEnabled = true,
|
||||
transactionDate = timestamp,
|
||||
txUrl = txUrl,
|
||||
provider = provider,
|
||||
swapDataModel = swapDataModel,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue