From 64ba8f017061f20e9b8a76097207b6259334fdec Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 6 Feb 2026 10:57:04 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../api/subcomponents/SwapAmountUpdateTrigger.kt | 2 ++ .../impl/amount/DefaultSwapAmountUpdateTrigger.kt | 9 +++++++++ .../swap/v2/impl/amount/model/SwapAmountModel.kt | 14 ++++++++++++++ .../confirm/SendWithSwapConfirmComponent.kt | 1 + .../confirm/model/SendWithSwapConfirmModel.kt | 8 ++++++++ 5 files changed, 34 insertions(+) diff --git a/features/swap-v2/api/src/main/java/com/tangem/features/swap/v2/api/subcomponents/SwapAmountUpdateTrigger.kt b/features/swap-v2/api/src/main/java/com/tangem/features/swap/v2/api/subcomponents/SwapAmountUpdateTrigger.kt index 7c9a0f4b91..de3c1fa9f2 100644 --- a/features/swap-v2/api/src/main/java/com/tangem/features/swap/v2/api/subcomponents/SwapAmountUpdateTrigger.kt +++ b/features/swap-v2/api/src/main/java/com/tangem/features/swap/v2/api/subcomponents/SwapAmountUpdateTrigger.kt @@ -8,4 +8,6 @@ interface SwapAmountUpdateTrigger { suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean) suspend fun triggerQuoteReload() + + suspend fun triggerAutoUpdateEnabled(isEnabled: Boolean) } \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/DefaultSwapAmountUpdateTrigger.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/DefaultSwapAmountUpdateTrigger.kt index 29162606e3..168c040b92 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/DefaultSwapAmountUpdateTrigger.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/DefaultSwapAmountUpdateTrigger.kt @@ -17,6 +17,8 @@ interface SwapAmountUpdateListener { val updateAmountTriggerFlow: Flow> val reloadQuotesTriggerFlow: Flow + + val autoUpdateTriggerFlow: Flow } /** @@ -59,6 +61,9 @@ internal class DefaultSwapAmountUpdateTrigger @Inject constructor() : override val reloadQuotesTriggerFlow: Flow field = MutableSharedFlow() + override val autoUpdateTriggerFlow: Flow + field = MutableSharedFlow() + override suspend fun triggerUpdateAmount(amountValue: String, isEnterInFiatSelected: Boolean) { updateAmountTriggerFlow.emit(amountValue to isEnterInFiatSelected) } @@ -67,6 +72,10 @@ internal class DefaultSwapAmountUpdateTrigger @Inject constructor() : reloadQuotesTriggerFlow.emit(Unit) } + override suspend fun triggerAutoUpdateEnabled(isEnabled: Boolean) { + autoUpdateTriggerFlow.emit(isEnabled) + } + override suspend fun triggerReduceBy(reduceBy: ReduceByData) { reduceByTriggerFlow.emit(reduceBy) } diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt index 8546a9c6e2..b406f013fb 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/SwapAmountModel.kt @@ -132,6 +132,7 @@ internal class SwapAmountModel @Inject constructor( subscribeOnAmountIgnoreReduceTriggerUpdates() subscribeOnReloadQuotesTriggerUpdates() subscribeOnBalanceHiddenUpdates() + subscribeOnAutoupdateEnabling() } fun onStart() { @@ -482,6 +483,19 @@ internal class SwapAmountModel @Inject constructor( .launchIn(modelScope) } + private fun subscribeOnAutoupdateEnabling() { + swapAmountUpdateListener.autoUpdateTriggerFlow + .distinctUntilChanged() + .onEach { isEnabled -> + if (isEnabled) { + startLoadingQuotesTask(isSilentReload = true) + } else { + quoteTaskScheduler.cancelTask() + } + } + .launchIn(modelScope) + } + private fun observeChooseSelectToken() { swapChooseTokenNetworkListener.swapChooseTokenNetworkResultFlow .onEach { data -> diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt index 579a4ddafc..9bae584628 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt @@ -98,6 +98,7 @@ internal class SendWithSwapConfirmComponent @AssistedInject constructor( analyticsCategoryName = params.analyticsCategoryName, analyticsSendSource = params.analyticsSendSource, userWalletId = params.userWallet.walletId, + bottomSheetShown = model::onFeeBottomSheetShown, ), onResult = model::onFeeResult, ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt index 2923283a79..90526afb56 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt @@ -45,6 +45,7 @@ import com.tangem.features.send.v2.api.subcomponents.destination.entity.Destinat import com.tangem.features.send.v2.api.subcomponents.feeSelector.FeeSelectorReloadTrigger import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateTrigger +import com.tangem.features.swap.v2.api.subcomponents.SwapAmountUpdateTrigger import com.tangem.features.swap.v2.impl.R import com.tangem.features.swap.v2.impl.amount.SwapAmountReduceTrigger import com.tangem.features.swap.v2.impl.amount.entity.SwapAmountUM @@ -90,6 +91,7 @@ internal class SendWithSwapConfirmModel @Inject constructor( private val sendNotificationsUpdateListener: SendNotificationsUpdateListener, private val swapNotificationsUpdateListener: SwapNotificationsUpdateListener, private val swapAmountReduceTrigger: SwapAmountReduceTrigger, + private val swapAmountUpdateTrigger: SwapAmountUpdateTrigger, private val feeSelectorReloadTrigger: FeeSelectorReloadTrigger, private val swapAlertFactory: SwapAlertFactory, private val appRouter: AppRouter, @@ -211,6 +213,12 @@ internal class SendWithSwapConfirmModel @Inject constructor( } } + fun onFeeBottomSheetShown(isShown: Boolean) { + modelScope.launch { + swapAmountUpdateTrigger.triggerAutoUpdateEnabled(isEnabled = !isShown) + } + } + fun showEditAmount() { analyticsEventHandler.send( CommonSendAnalyticEvents.ScreenReopened(