Updated on 2026-08-14
This commit is contained in:
commit
7de53d6b0c
20 changed files with 257 additions and 43 deletions
|
|
@ -40,6 +40,7 @@ internal class SendEntryPointModel @Inject constructor(
|
|||
AppRoute.ChooseManagedTokens(
|
||||
userWalletId = params.userWalletId,
|
||||
initialCurrency = params.cryptoCurrency,
|
||||
selectedCurrency = null,
|
||||
source = AppRoute.ChooseManagedTokens.Source.SendViaSwap,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -230,6 +230,23 @@ internal class SendModel @Inject constructor(
|
|||
params.callback?.onConvertToAnotherToken(lastAmount = lastAmount)
|
||||
}
|
||||
|
||||
override fun resetSendNavigation() {
|
||||
uiState.update {
|
||||
it.copy(
|
||||
destinationUM = SendDestinationInitialStateTransformer(
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
isRedesignEnabled = sendFeatureToggles.isSendRedesignEnabled,
|
||||
).transform(DestinationUM.Empty()),
|
||||
feeUM = FeeUM.Empty(),
|
||||
feeSelectorUM = FeeSelectorUM.Loading,
|
||||
confirmUM = ConfirmUM.Empty,
|
||||
confirmData = null,
|
||||
navigationUM = NavigationUM.Empty,
|
||||
)
|
||||
}
|
||||
router.popTo(Amount(isEditMode = false))
|
||||
}
|
||||
|
||||
override fun onError(error: GetUserWalletError) {
|
||||
Timber.w(error.toString())
|
||||
showAlertError()
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ internal class SendAmountComponent(
|
|||
interface ModelCallback : NavigationModelCallback {
|
||||
fun onAmountResult(amountUM: AmountState, isResetPredefined: Boolean)
|
||||
fun onConvertToAnotherToken(lastAmount: String)
|
||||
fun resetSendNavigation()
|
||||
fun onError(error: GetUserWalletError)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.tangem.features.send.v2.subcomponents.amount.model
|
||||
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.message.DialogMessage
|
||||
import com.tangem.core.ui.message.EventMessageAction
|
||||
import javax.inject.Inject
|
||||
|
||||
@ModelScoped
|
||||
internal class SendAmountAlertFactory @Inject constructor(
|
||||
private val uiMessageSender: UiMessageSender,
|
||||
) {
|
||||
|
||||
fun showResetSendingAlert(onConfirm: () -> Unit) {
|
||||
// todo fix localization [REDACTED_TASK_KEY]
|
||||
uiMessageSender.send(
|
||||
DialogMessage(
|
||||
title = stringReference("Confirm Convert"),
|
||||
message = stringReference("Proceed with conversion? Previous data will be reset."),
|
||||
firstActionBuilder = {
|
||||
EventMessageAction(
|
||||
title = stringReference("Confirm"),
|
||||
onClick = onConfirm,
|
||||
)
|
||||
},
|
||||
secondActionBuilder = {
|
||||
EventMessageAction(
|
||||
title = stringReference("Not Now"),
|
||||
onClick = onDismissRequest,
|
||||
)
|
||||
},
|
||||
dismissOnFirstAction = true,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,7 @@ internal class SendAmountModel @Inject constructor(
|
|||
private val feeSelectorReloadTrigger: FeeSelectorReloadTrigger,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
private val rampStateManager: RampStateManager,
|
||||
private val sendAmountAlertFactory: SendAmountAlertFactory,
|
||||
) : Model(), SendAmountClickIntents {
|
||||
|
||||
private val params: SendAmountComponentParams = paramsContainer.require()
|
||||
|
|
@ -242,9 +243,21 @@ internal class SendAmountModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onConvertToAnotherToken() {
|
||||
val amountParams = params as? SendAmountComponentParams.AmountParams ?: return
|
||||
if (amountParams.currentRoute.value.isEditMode) {
|
||||
sendAmountAlertFactory.showResetSendingAlert {
|
||||
params.callback.resetSendNavigation()
|
||||
confirmConvertToToken()
|
||||
}
|
||||
} else {
|
||||
confirmConvertToToken()
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirmConvertToToken() {
|
||||
val amountParams = params as? SendAmountComponentParams.AmountParams ?: return
|
||||
val amountFieldData = uiState.value as? AmountState.Data
|
||||
val amountParams = params as? SendAmountComponentParams.AmountParams
|
||||
amountParams?.callback?.onConvertToAnotherToken(amountFieldData?.amountTextField?.value.orEmpty())
|
||||
amountParams.callback.onConvertToAnotherToken(amountFieldData?.amountTextField?.value.orEmpty())
|
||||
}
|
||||
|
||||
private fun subscribeOnAmountReduceToTriggerUpdates() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue