Updated on 2026-08-14
This commit is contained in:
parent
b623a457d9
commit
3af4539567
12 changed files with 56 additions and 35 deletions
|
|
@ -30,9 +30,11 @@ internal class SendEntryPointModel @Inject constructor(
|
|||
ChooseManagedTokensComponent.ModelCallback {
|
||||
|
||||
private var lastSavedAmount = ""
|
||||
private var isEnterInFiat = false
|
||||
|
||||
override fun onConvertToAnotherToken(lastAmount: String) {
|
||||
override fun onConvertToAnotherToken(lastAmount: String, isEnterInFiatSelected: Boolean) {
|
||||
lastSavedAmount = lastAmount
|
||||
isEnterInFiat = isEnterInFiatSelected
|
||||
modelScope.launch {
|
||||
val showSendViaSwapNotification = shouldShowNotificationUseCase(
|
||||
NotificationId.SendViaSwapTokenSelectorNotification.key,
|
||||
|
|
@ -45,12 +47,11 @@ internal class SendEntryPointModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCloseSwap(lastAmount: String) {
|
||||
override fun onCloseSwap(lastAmount: String, isEnterInFiatSelected: Boolean) {
|
||||
lastSavedAmount = lastAmount
|
||||
isEnterInFiat = isEnterInFiatSelected
|
||||
modelScope.launch {
|
||||
if (lastAmount.isNotBlank()) {
|
||||
sendAmountUpdateTrigger.triggerUpdateAmount(lastAmount)
|
||||
}
|
||||
sendAmountUpdateTrigger.triggerUpdateAmount(lastAmount, isEnterInFiat)
|
||||
router.replaceAll(SendEntryRoute.Send)
|
||||
}
|
||||
}
|
||||
|
|
@ -58,9 +59,7 @@ internal class SendEntryPointModel @Inject constructor(
|
|||
@Suppress("MagicNumber")
|
||||
override fun onResult() {
|
||||
modelScope.launch {
|
||||
if (lastSavedAmount.isNotBlank()) {
|
||||
swapAmountUpdateTrigger.triggerUpdateAmount(lastSavedAmount)
|
||||
}
|
||||
swapAmountUpdateTrigger.triggerUpdateAmount(lastSavedAmount, isEnterInFiat)
|
||||
// Workaround in order to execute correct exit animation on SendEntryRoute.ChooseToken
|
||||
router.pop()
|
||||
delay(10L)
|
||||
|
|
@ -70,7 +69,7 @@ internal class SendEntryPointModel @Inject constructor(
|
|||
|
||||
override fun onBack() {
|
||||
modelScope.launch {
|
||||
sendAmountUpdateTrigger.triggerUpdateAmount(lastSavedAmount)
|
||||
sendAmountUpdateTrigger.triggerUpdateAmount(lastSavedAmount, isEnterInFiat)
|
||||
router.pop()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,14 +227,14 @@ internal class SendModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onConvertToAnotherToken(lastAmount: String) {
|
||||
override fun onConvertToAnotherToken(lastAmount: String, isEnterInFiatSelected: Boolean) {
|
||||
analyticsEventHandler.send(
|
||||
SendAnalyticEvents.ConvertTokenButtonClicked(
|
||||
token = cryptoCurrency.symbol,
|
||||
blockchain = cryptoCurrency.network.name,
|
||||
),
|
||||
)
|
||||
params.callback?.onConvertToAnotherToken(lastAmount = lastAmount)
|
||||
params.callback?.onConvertToAnotherToken(lastAmount = lastAmount, isEnterInFiatSelected = isEnterInFiatSelected)
|
||||
}
|
||||
|
||||
override fun resetSendNavigation() {
|
||||
|
|
@ -455,7 +455,7 @@ internal class SendModel @Inject constructor(
|
|||
)
|
||||
// If it is in active state use flow to update value in amount component
|
||||
modelScope.launch {
|
||||
amount?.let { sendAmountUpdateTrigger.triggerUpdateAmount(it) }
|
||||
amount?.let { sendAmountUpdateTrigger.triggerUpdateAmount(it, null) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ internal class SendAmountComponent(
|
|||
|
||||
interface ModelCallback : NavigationModelCallback {
|
||||
fun onAmountResult(amountUM: AmountState, isResetPredefined: Boolean)
|
||||
fun onConvertToAnotherToken(lastAmount: String)
|
||||
fun onConvertToAnotherToken(lastAmount: String, isEnterInFiatSelected: Boolean)
|
||||
fun resetSendNavigation()
|
||||
fun onError(error: GetUserWalletError)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ interface SendAmountReduceListener {
|
|||
* Different from another triggers because it takes raw string instead of BigDecimal
|
||||
*/
|
||||
interface SendAmountUpdateTrigger {
|
||||
suspend fun triggerUpdateAmount(amountValue: String)
|
||||
suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean?)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +38,7 @@ interface SendAmountUpdateTrigger {
|
|||
* Different from another triggers because it takes raw string instead of BigDecimal
|
||||
*/
|
||||
interface SendAmountUpdateListener {
|
||||
val updateAmountTriggerFlow: Flow<String>
|
||||
val updateAmountTriggerFlow: Flow<Pair<String, Boolean?>>
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
|
@ -51,7 +51,7 @@ internal class DefaultSendAmountReduceTrigger @Inject constructor() :
|
|||
override val reduceToTriggerFlow = MutableSharedFlow<BigDecimal>()
|
||||
override val reduceByTriggerFlow = MutableSharedFlow<ReduceByData>()
|
||||
override val ignoreReduceTriggerFlow = MutableSharedFlow<Unit>()
|
||||
override val updateAmountTriggerFlow = MutableSharedFlow<String>()
|
||||
override val updateAmountTriggerFlow = MutableSharedFlow<Pair<String, Boolean?>>()
|
||||
|
||||
override suspend fun triggerReduceBy(reduceBy: ReduceByData) {
|
||||
reduceByTriggerFlow.emit(reduceBy)
|
||||
|
|
@ -65,7 +65,7 @@ internal class DefaultSendAmountReduceTrigger @Inject constructor() :
|
|||
ignoreReduceTriggerFlow.emit(Unit)
|
||||
}
|
||||
|
||||
override suspend fun triggerUpdateAmount(amountValue: String) {
|
||||
updateAmountTriggerFlow.emit(amountValue)
|
||||
override suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean?) {
|
||||
updateAmountTriggerFlow.emit(amountValue to isEnterInFiatSelected)
|
||||
}
|
||||
}
|
||||
|
|
@ -290,7 +290,15 @@ internal class SendAmountModel @Inject constructor(
|
|||
isPrimaryButtonEnabled = false,
|
||||
) ?: it
|
||||
}
|
||||
amountParams.callback.onConvertToAnotherToken(amountFieldData?.amountTextField?.value.orEmpty())
|
||||
|
||||
val isEnterInFiatSelected = amountFieldData?.amountTextField?.isFiatValue == true
|
||||
val lastAmount = if (isEnterInFiatSelected) {
|
||||
amountFieldData.amountTextField.fiatValue
|
||||
} else {
|
||||
amountFieldData?.amountTextField?.value
|
||||
}
|
||||
|
||||
amountParams.callback.onConvertToAnotherToken(lastAmount.orEmpty(), isEnterInFiatSelected)
|
||||
}
|
||||
|
||||
private fun subscribeOnAmountReduceToTriggerUpdates() {
|
||||
|
|
@ -346,7 +354,8 @@ internal class SendAmountModel @Inject constructor(
|
|||
|
||||
private fun subscribeOnAmountUpdateTriggerUpdates() {
|
||||
sendAmountUpdateListener.updateAmountTriggerFlow
|
||||
.onEach { amount ->
|
||||
.onEach { (amount, isEnterInFiat) ->
|
||||
isEnterInFiat?.let { onCurrencyChangeClick(isEnterInFiat) }
|
||||
onAmountValueChange(amount)
|
||||
saveResult()
|
||||
}.launchIn(modelScope)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue