From 98cacb2d4aaa2fe2c57d761b29325df68968a139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Fri, 2 Aug 2024 11:24:40 +0200 Subject: [PATCH] Wallet: swap/bridge buttons visibility adjusted Closes: #15952 Closes: #15931 --- storybook/pages/AssetsViewPage.qml | 6 ++++++ ui/app/AppLayouts/Wallet/panels/WalletFooter.qml | 16 ++++++++++++---- ui/app/AppLayouts/Wallet/stores/RootStore.qml | 6 +++++- .../AppLayouts/Wallet/views/CollectiblesView.qml | 4 ++-- ui/app/AppLayouts/Wallet/views/RightTabView.qml | 6 ++++-- ui/imports/shared/views/AssetsView.qml | 9 +++++++-- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/storybook/pages/AssetsViewPage.qml b/storybook/pages/AssetsViewPage.qml index 43454df110..a3c2207d3b 100644 --- a/storybook/pages/AssetsViewPage.qml +++ b/storybook/pages/AssetsViewPage.qml @@ -175,6 +175,7 @@ SplitView { sendEnabled: sendEnabledCheckBox.checked swapEnabled: swapEnabledCheckBox.checked swapVisible: swapVisibleCheckBox.checked + communitySwapVisible: communitySwapVisibleCheckBox.checked balanceError: balanceErrorCheckBox.checked ? "Balance error!" : "" @@ -243,6 +244,11 @@ SplitView { text: "swap visible" } + CheckBox { + id: communitySwapVisibleCheckBox + + text: "community swap visible" + } CheckBox { id: balanceErrorCheckBox diff --git a/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml b/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml index 417b467768..1db801cc73 100644 --- a/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml +++ b/ui/app/AppLayouts/Wallet/panels/WalletFooter.qml @@ -41,6 +41,9 @@ Rectangle { readonly property bool isCollectibleViewed: !!walletStore.currentViewedHoldingID && (walletStore.currentViewedHoldingType === Constants.TokenType.ERC721 || walletStore.currentViewedHoldingType === Constants.TokenType.ERC1155) + + readonly property bool isCommunityAsset: !d.isCollectibleViewed && walletStore.currentViewedHoldingCommunityId !== "" + readonly property bool isCollectibleSoulbound: isCollectibleViewed && !!walletStore.currentViewedCollectible && walletStore.currentViewedCollectible.soulbound readonly property var collectibleOwnership: isCollectibleViewed && walletStore.currentViewedCollectible ? @@ -67,11 +70,16 @@ Rectangle { && !root.isCommunityOwnershipTransfer && walletStore.overview.canSend && !root.walletStore.showAllAccounts - && !d.hideCollectibleTransferActions + && !d.isCollectibleViewed + && !d.isCommunityAsset readonly property bool buyActionAvailable: !root.isCommunityOwnershipTransfer && !root.walletStore.showAllAccounts - readonly property bool swapActionAvailable: Global.featureFlags.swapEnabled && !walletStore.overview.isWatchOnlyAccount && walletStore.overview.canSend && !d.hideCollectibleTransferActions + readonly property bool swapActionAvailable: Global.featureFlags.swapEnabled + && !walletStore.overview.isWatchOnlyAccount + && walletStore.overview.canSend + && !d.isCollectibleViewed + && !d.isCommunityAsset function getFirstUserOwnedAddress(ownershipModel, accountsModel) { if (!ownershipModel) return "" @@ -144,9 +152,9 @@ Rectangle { StatusFlatButton { id: swap - interactive: !d.isCollectibleViewed && networkConnectionStore.sendBuyBridgeEnabled + interactive: networkConnectionStore.sendBuyBridgeEnabled visible: d.swapActionAvailable - tooltip.text: d.isCollectibleViewed ? qsTr("Collectibles cannot be swapped") : networkConnectionStore.sendBuyBridgeToolTipText + tooltip.text: networkConnectionStore.sendBuyBridgeToolTipText icon.name: "swap" text: qsTr("Swap") onClicked: root.launchSwapModal() diff --git a/ui/app/AppLayouts/Wallet/stores/RootStore.qml b/ui/app/AppLayouts/Wallet/stores/RootStore.qml index 9e6545ba13..40d6091092 100644 --- a/ui/app/AppLayouts/Wallet/stores/RootStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/RootStore.qml @@ -177,19 +177,22 @@ QtObject { function resetCurrentViewedHolding(type) { currentViewedHoldingTokensKey = "" currentViewedHoldingID = "" + currentViewedHoldingCommunityId = "" currentViewedHoldingType = type } function setCurrentViewedHoldingType(type) { currentViewedHoldingTokensKey = "" currentViewedHoldingID = "" + currentViewedHoldingCommunityId = "" currentViewedHoldingType = type } - function setCurrentViewedHolding(id, tokensKey, type) { + function setCurrentViewedHolding(id, tokensKey, type, communityId) { currentViewedHoldingTokensKey = tokensKey currentViewedHoldingID = id currentViewedHoldingType = type + currentViewedHoldingCommunityId = communityId } property string currentViewedHoldingTokensKey: "" @@ -197,6 +200,7 @@ QtObject { everywhere. Adding a new one currentViewedHoldingTokensKey aboce to not impact send/bridge flows */ property string currentViewedHoldingID: "" property int currentViewedHoldingType + property string currentViewedHoldingCommunityId: "" readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible function canProfileProveOwnershipOfProvidedAddresses(addresses) { diff --git a/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml b/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml index 56ff9f2992..d3689eba33 100644 --- a/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml +++ b/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml @@ -38,7 +38,7 @@ ColumnLayout { property bool isUpdating: false // Indicates if the collectibles list is being updated property bool isError: false // Indicates an error occurred while updating/fetching the collectibles list - signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid, int tokenType) + signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid, int tokenType, string communityId) signal sendRequested(string symbol, int tokenType, string fromAddress) signal receiveRequested(string symbol) signal switchToCommunityRequested(string communityId) @@ -476,7 +476,7 @@ ColumnLayout { communityImage: model.communityImage ?? "" balance: model.balance ?? 1 - onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.symbol, model.tokenType) + onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.symbol, model.tokenType, model.communityId ?? "") onRightClicked: { const userOwnedAddress = d.getFirstUserOwnedAddress(model.ownership) Global.openMenu(tokenContextMenu, this, diff --git a/ui/app/AppLayouts/Wallet/views/RightTabView.qml b/ui/app/AppLayouts/Wallet/views/RightTabView.qml index c2a3e93915..ed6801d51c 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabView.qml @@ -225,6 +225,7 @@ RightTabBaseView { sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled && !RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend + communitySendEnabled: RootStore.tokensStore.showCommunityAssetsInSend swapEnabled: !RootStore.overview.isWatchOnlyAccount swapVisible: Global.featureFlags.swapEnabled @@ -266,7 +267,8 @@ RightTabBaseView { token.symbol, RootStore.currencyStore.currentCurrency) assetDetailView.token = token - RootStore.setCurrentViewedHolding(token.symbol, token.key, Constants.TokenType.ERC20) + RootStore.setCurrentViewedHolding( + token.symbol, token.key, Constants.TokenType.ERC20, token.communityId ?? "") stack.currentIndex = 2 } } @@ -283,7 +285,7 @@ RightTabBaseView { filterVisible: filterButton.checked onCollectibleClicked: { RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId) - RootStore.setCurrentViewedHolding(uid, uid, tokenType) + RootStore.setCurrentViewedHolding(uid, uid, tokenType, communityId) d.detailedCollectibleActivityController.resetFilter() d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":"))) d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false) diff --git a/ui/imports/shared/views/AssetsView.qml b/ui/imports/shared/views/AssetsView.qml index 23d425785b..f5f0f43f65 100644 --- a/ui/imports/shared/views/AssetsView.qml +++ b/ui/imports/shared/views/AssetsView.qml @@ -58,8 +58,10 @@ Control { // switches configuring right click menu property bool sendEnabled: true + property bool communitySendEnabled: false property bool swapEnabled: true property bool swapVisible: true + property bool communitySwapVisible: false property string balanceError @@ -267,13 +269,16 @@ Control { readonly property string key: model.key readonly property string communityKey: model.communityId + readonly property bool isCommunity: !!model.isCommunity + onClosed: destroy() sendEnabled: root.sendEnabled + && (!isCommunity || root.communitySendEnabled) swapEnabled: root.swapEnabled - swapVisible: root.swapVisible + swapVisible: root.swapVisible && (!isCommunity || root.communitySwapVisible) hideVisible: model.canBeHidden - communityHideVisible: !!model.isCommunity + communityHideVisible: isCommunity onSendRequested: root.sendRequested(key) onReceiveRequested: root.receiveRequested(key)