From 2c8083d3672835fadfc5c6c398db0047ccdd47c3 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 15 May 2026 13:11:07 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../WalletCurrencyActionsClickIntents.kt | 31 +++++++++++++------ .../state/utils/MultiWalletActionsExt.kt | 19 ++++++++++-- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletCurrencyActionsClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletCurrencyActionsClickIntents.kt index 249ce10de3..34eb71249c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletCurrencyActionsClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletCurrencyActionsClickIntents.kt @@ -65,6 +65,8 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.WalletAlertUM import com.tangem.feature.wallet.presentation.wallet.state.model.WalletEvent import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState +import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListUM +import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM import com.tangem.feature.wallet.presentation.wallet.state.transformers.CloseBottomSheetTransformer import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender import com.tangem.utils.coroutines.CoroutineDispatcherProvider @@ -453,16 +455,7 @@ internal class WalletCurrencyActionsClickIntentsImplementor @Inject constructor( } override fun onMultiWalletSwapClick(userWalletId: UserWalletId) { - val selectedWallet = stateHolder.getSelectedWallet() as? WalletState.MultiCurrency.Content ?: return - when (selectedWallet.tokensListState) { - is WalletTokensListState.ContentState.Content, - is WalletTokensListState.ContentState.PortfolioContent, - -> Unit - WalletTokensListState.ContentState.Loading, - WalletTokensListState.ContentState.Locked, - WalletTokensListState.Empty, - -> return - } + if (!isMultiWalletTokensLoaded()) return modelScope.launch { val swapRoute = getSwapRoute( @@ -576,6 +569,24 @@ internal class WalletCurrencyActionsClickIntentsImplementor @Inject constructor( return true } + private fun isMultiWalletTokensLoaded(): Boolean { + return if (stateHolder.value.isRedesignEnabled) { + val selectedWalletUM = stateHolder.getSelectedWalletUM() as? WalletUM.Content ?: return false + selectedWalletUM.tokensListUM is WalletTokensListUM.Content + } else { + val selectedWallet = stateHolder.getSelectedWallet() as? WalletState.MultiCurrency.Content ?: return false + when (selectedWallet.tokensListState) { + is WalletTokensListState.ContentState.Content, + is WalletTokensListState.ContentState.PortfolioContent, + -> true + WalletTokensListState.ContentState.Loading, + WalletTokensListState.ContentState.Locked, + WalletTokensListState.Empty, + -> false + } + } + } + private fun onMultiWalletActionClick( statusFlow: Flow>, route: AppRoute, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/MultiWalletActionsExt.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/MultiWalletActionsExt.kt index f5506e2b29..56fd1ba0f3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/MultiWalletActionsExt.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/MultiWalletActionsExt.kt @@ -1,6 +1,8 @@ package com.tangem.feature.wallet.presentation.wallet.state.utils import com.tangem.core.ui.ds.button.TangemButtonUM +import com.tangem.core.ui.ds.image.TangemIconUM +import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.presentation.wallet.state.model.WalletManageButton import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState import com.tangem.feature.wallet.presentation.wallet.state.model.WalletUM @@ -16,11 +18,24 @@ internal fun WalletState.MultiCurrency.Content.disableButtons(): PersistentList< } internal fun WalletUM.Content.enableButtons(): PersistentList { - return buttons.map { it.copy(isEnabled = true) }.toPersistentList() + return buttons.map { it.withEnabled(isEnabled = true) }.toPersistentList() } internal fun WalletUM.Content.disableButtons(): PersistentList { - return buttons.map { it.copy(isEnabled = false) }.toPersistentList() + return buttons.map { it.withEnabled(isEnabled = false) }.toPersistentList() +} + +private fun TangemButtonUM.withEnabled(isEnabled: Boolean): TangemButtonUM { + val refreshedIcon = (tangemIconUM as? TangemIconUM.Icon)?.copy( + tint = { + if (isEnabled) { + TangemTheme.colors2.graphic.neutral.primary + } else { + TangemTheme.colors2.graphic.neutral.quaternary + } + }, + ) ?: tangemIconUM + return copy(isEnabled = isEnabled, tangemIconUM = refreshedIcon) } private fun WalletState.MultiCurrency.Content.changeAvailability(enabled: Boolean): PersistentList {