From 720042cf18ac456013503df60e267b5ab8cce8e3 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 2 May 2023 13:33:22 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../wallet/ui/WalletDetailsFragment.kt | 35 +++++++------------ .../wallet/ui/utils/WalletDataOperations.kt | 7 +++- .../wallet/ui/wallet/SingleWalletView.kt | 14 ++------ 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt index 7da258be29..d4556d790b 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt @@ -1,11 +1,7 @@ package com.tangem.tap.features.wallet.ui import android.os.Bundle -import android.view.Menu -import android.view.MenuInflater -import android.view.MenuItem -import android.view.View -import android.view.ViewGroup +import android.view.* import android.widget.TextView import androidx.activity.OnBackPressedCallback import androidx.annotation.ColorRes @@ -31,14 +27,7 @@ import com.tangem.tap.common.SnackbarHandler import com.tangem.tap.common.TestActions import com.tangem.tap.common.analytics.events.DetailsScreen import com.tangem.tap.common.analytics.events.Token -import com.tangem.tap.common.extensions.appendIfNotNull -import com.tangem.tap.common.extensions.beginDelayedTransition -import com.tangem.tap.common.extensions.fitChipsByGroupWidth -import com.tangem.tap.common.extensions.getColor -import com.tangem.tap.common.extensions.getString -import com.tangem.tap.common.extensions.hide -import com.tangem.tap.common.extensions.show -import com.tangem.tap.common.extensions.toQrCode +import com.tangem.tap.common.extensions.* import com.tangem.tap.common.recyclerView.SpaceItemDecoration import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.common.utils.SafeStoreSubscriber @@ -56,15 +45,7 @@ import com.tangem.tap.features.wallet.ui.adapters.PendingTransactionsAdapter import com.tangem.tap.features.wallet.ui.adapters.WalletDetailWarningMessagesAdapter import com.tangem.tap.features.wallet.ui.images.load import com.tangem.tap.features.wallet.ui.test.TestWallet -import com.tangem.tap.features.wallet.ui.utils.assembleWarnings -import com.tangem.tap.features.wallet.ui.utils.getAvailableActions -import com.tangem.tap.features.wallet.ui.utils.getFormattedAmount -import com.tangem.tap.features.wallet.ui.utils.getFormattedFiatAmount -import com.tangem.tap.features.wallet.ui.utils.isAvailableToBuy -import com.tangem.tap.features.wallet.ui.utils.isAvailableToSell -import com.tangem.tap.features.wallet.ui.utils.isAvailableToSwap -import com.tangem.tap.features.wallet.ui.utils.mainButton -import com.tangem.tap.features.wallet.ui.utils.shouldShowMultipleAddress +import com.tangem.tap.features.wallet.ui.utils.* import com.tangem.tap.store import com.tangem.tap.userWalletsListManagerSafe import com.tangem.tap.walletCurrenciesManager @@ -76,6 +57,9 @@ import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject +/** + * Wallet details fragment - use only for MultiWallet + */ @Suppress("LargeClass", "MagicNumber") @AndroidEntryPoint class WalletDetailsFragment : @@ -308,7 +292,11 @@ class WalletDetailsFragment : WalletAction.DialogAction.ChooseTradeActionDialog( buyAllowed = selectedWallet.isAvailableToBuy(exchangeManager), sellAllowed = selectedWallet.isAvailableToSell(exchangeManager), - swapAllowed = selectedWallet.isAvailableToSwap(swapFeatureToggleManager, swapInteractor), + swapAllowed = selectedWallet.isAvailableToSwap( + swapFeatureToggleManager = swapFeatureToggleManager, + swapInteractor = swapInteractor, + isSingleWallet = false, + ), ), ) } @@ -317,6 +305,7 @@ class WalletDetailsFragment : swapInteractor = swapInteractor, exchangeManager = exchangeManager, swapFeatureToggleManager = swapFeatureToggleManager, + isSingleWallet = false, ) binding.rowButtons.updateButtonsVisibility( actions = actions, diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt index 42be04542e..042426cb80 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/utils/WalletDataOperations.kt @@ -56,7 +56,11 @@ internal fun WalletDataModel.isAvailableToSell(exchangeManager: CurrencyExchange internal fun WalletDataModel.isAvailableToSwap( swapFeatureToggleManager: SwapFeatureToggleManager, swapInteractor: SwapInteractor, + isSingleWallet: Boolean, ): Boolean { + if (isSingleWallet) { + return false + } if (currency.blockchain.id == Blockchain.Optimism.id && !swapFeatureToggleManager.isOptimismSwapEnabled) { return false } @@ -68,11 +72,12 @@ internal fun WalletDataModel.getAvailableActions( swapInteractor: SwapInteractor, exchangeManager: CurrencyExchangeManager, swapFeatureToggleManager: SwapFeatureToggleManager, + isSingleWallet: Boolean, ): Set { return setOfNotNull( if (isAvailableToBuy(exchangeManager)) CurrencyAction.Buy else null, if (isAvailableToSell(exchangeManager)) CurrencyAction.Sell else null, - if (isAvailableToSwap(swapFeatureToggleManager, swapInteractor)) CurrencyAction.Swap else null, + if (isAvailableToSwap(swapFeatureToggleManager, swapInteractor, isSingleWallet)) CurrencyAction.Swap else null, ) } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/SingleWalletView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/SingleWalletView.kt index 5edef28db5..5668693e18 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/SingleWalletView.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/SingleWalletView.kt @@ -5,12 +5,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import com.tangem.core.analytics.Analytics import com.tangem.tap.common.analytics.events.Token -import com.tangem.tap.common.extensions.beginDelayedTransition -import com.tangem.tap.common.extensions.fitChipsByGroupWidth -import com.tangem.tap.common.extensions.getQuantityString -import com.tangem.tap.common.extensions.getString -import com.tangem.tap.common.extensions.hide -import com.tangem.tap.common.extensions.show +import com.tangem.tap.common.extensions.* import com.tangem.tap.domain.model.WalletDataModel import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsState import com.tangem.tap.features.wallet.models.Currency @@ -23,11 +18,7 @@ import com.tangem.tap.features.wallet.ui.BalanceWidget import com.tangem.tap.features.wallet.ui.MultipleAddressUiHelper import com.tangem.tap.features.wallet.ui.WalletFragment import com.tangem.tap.features.wallet.ui.adapters.PendingTransactionsAdapter -import com.tangem.tap.features.wallet.ui.utils.getAvailableActions -import com.tangem.tap.features.wallet.ui.utils.isAvailableToBuy -import com.tangem.tap.features.wallet.ui.utils.isAvailableToSell -import com.tangem.tap.features.wallet.ui.utils.mainButton -import com.tangem.tap.features.wallet.ui.utils.shouldShowMultipleAddress +import com.tangem.tap.features.wallet.ui.utils.* import com.tangem.tap.features.wallet.ui.view.WalletDetailsButtonsRow import com.tangem.tap.store import com.tangem.wallet.R @@ -179,6 +170,7 @@ class SingleWalletView : WalletView() { swapInteractor = swapInteractor, exchangeManager = exchangeManager, swapFeatureToggleManager = swapFeatureToggleManager, + isSingleWallet = true, ) binding?.rowButtons?.updateButtonsVisibility( actions = actions,