Wallet: swap/bridge buttons visibility adjusted

Closes: #15952
Closes: #15931
This commit is contained in:
Michał Cieślak 2024-08-02 11:24:40 +02:00 committed by Iuri Matias
parent e998262379
commit 98cacb2d4a
6 changed files with 36 additions and 11 deletions

View File

@ -175,6 +175,7 @@ SplitView {
sendEnabled: sendEnabledCheckBox.checked sendEnabled: sendEnabledCheckBox.checked
swapEnabled: swapEnabledCheckBox.checked swapEnabled: swapEnabledCheckBox.checked
swapVisible: swapVisibleCheckBox.checked swapVisible: swapVisibleCheckBox.checked
communitySwapVisible: communitySwapVisibleCheckBox.checked
balanceError: balanceErrorCheckBox.checked balanceError: balanceErrorCheckBox.checked
? "Balance error!" : "" ? "Balance error!" : ""
@ -243,6 +244,11 @@ SplitView {
text: "swap visible" text: "swap visible"
} }
CheckBox {
id: communitySwapVisibleCheckBox
text: "community swap visible"
}
CheckBox { CheckBox {
id: balanceErrorCheckBox id: balanceErrorCheckBox

View File

@ -41,6 +41,9 @@ Rectangle {
readonly property bool isCollectibleViewed: !!walletStore.currentViewedHoldingID && readonly property bool isCollectibleViewed: !!walletStore.currentViewedHoldingID &&
(walletStore.currentViewedHoldingType === Constants.TokenType.ERC721 || (walletStore.currentViewedHoldingType === Constants.TokenType.ERC721 ||
walletStore.currentViewedHoldingType === Constants.TokenType.ERC1155) 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 bool isCollectibleSoulbound: isCollectibleViewed && !!walletStore.currentViewedCollectible && walletStore.currentViewedCollectible.soulbound
readonly property var collectibleOwnership: isCollectibleViewed && walletStore.currentViewedCollectible ? readonly property var collectibleOwnership: isCollectibleViewed && walletStore.currentViewedCollectible ?
@ -67,11 +70,16 @@ Rectangle {
&& !root.isCommunityOwnershipTransfer && !root.isCommunityOwnershipTransfer
&& walletStore.overview.canSend && walletStore.overview.canSend
&& !root.walletStore.showAllAccounts && !root.walletStore.showAllAccounts
&& !d.hideCollectibleTransferActions && !d.isCollectibleViewed
&& !d.isCommunityAsset
readonly property bool buyActionAvailable: !root.isCommunityOwnershipTransfer && !root.walletStore.showAllAccounts 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) { function getFirstUserOwnedAddress(ownershipModel, accountsModel) {
if (!ownershipModel) return "" if (!ownershipModel) return ""
@ -144,9 +152,9 @@ Rectangle {
StatusFlatButton { StatusFlatButton {
id: swap id: swap
interactive: !d.isCollectibleViewed && networkConnectionStore.sendBuyBridgeEnabled interactive: networkConnectionStore.sendBuyBridgeEnabled
visible: d.swapActionAvailable visible: d.swapActionAvailable
tooltip.text: d.isCollectibleViewed ? qsTr("Collectibles cannot be swapped") : networkConnectionStore.sendBuyBridgeToolTipText tooltip.text: networkConnectionStore.sendBuyBridgeToolTipText
icon.name: "swap" icon.name: "swap"
text: qsTr("Swap") text: qsTr("Swap")
onClicked: root.launchSwapModal() onClicked: root.launchSwapModal()

View File

@ -177,19 +177,22 @@ QtObject {
function resetCurrentViewedHolding(type) { function resetCurrentViewedHolding(type) {
currentViewedHoldingTokensKey = "" currentViewedHoldingTokensKey = ""
currentViewedHoldingID = "" currentViewedHoldingID = ""
currentViewedHoldingCommunityId = ""
currentViewedHoldingType = type currentViewedHoldingType = type
} }
function setCurrentViewedHoldingType(type) { function setCurrentViewedHoldingType(type) {
currentViewedHoldingTokensKey = "" currentViewedHoldingTokensKey = ""
currentViewedHoldingID = "" currentViewedHoldingID = ""
currentViewedHoldingCommunityId = ""
currentViewedHoldingType = type currentViewedHoldingType = type
} }
function setCurrentViewedHolding(id, tokensKey, type) { function setCurrentViewedHolding(id, tokensKey, type, communityId) {
currentViewedHoldingTokensKey = tokensKey currentViewedHoldingTokensKey = tokensKey
currentViewedHoldingID = id currentViewedHoldingID = id
currentViewedHoldingType = type currentViewedHoldingType = type
currentViewedHoldingCommunityId = communityId
} }
property string currentViewedHoldingTokensKey: "" property string currentViewedHoldingTokensKey: ""
@ -197,6 +200,7 @@ QtObject {
everywhere. Adding a new one currentViewedHoldingTokensKey aboce to not impact send/bridge flows */ everywhere. Adding a new one currentViewedHoldingTokensKey aboce to not impact send/bridge flows */
property string currentViewedHoldingID: "" property string currentViewedHoldingID: ""
property int currentViewedHoldingType property int currentViewedHoldingType
property string currentViewedHoldingCommunityId: ""
readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible
function canProfileProveOwnershipOfProvidedAddresses(addresses) { function canProfileProveOwnershipOfProvidedAddresses(addresses) {

View File

@ -38,7 +38,7 @@ ColumnLayout {
property bool isUpdating: false // Indicates if the collectibles list is being updated 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 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 sendRequested(string symbol, int tokenType, string fromAddress)
signal receiveRequested(string symbol) signal receiveRequested(string symbol)
signal switchToCommunityRequested(string communityId) signal switchToCommunityRequested(string communityId)
@ -476,7 +476,7 @@ ColumnLayout {
communityImage: model.communityImage ?? "" communityImage: model.communityImage ?? ""
balance: model.balance ?? 1 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: { onRightClicked: {
const userOwnedAddress = d.getFirstUserOwnedAddress(model.ownership) const userOwnedAddress = d.getFirstUserOwnedAddress(model.ownership)
Global.openMenu(tokenContextMenu, this, Global.openMenu(tokenContextMenu, this,

View File

@ -225,6 +225,7 @@ RightTabBaseView {
sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled && sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled &&
!RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend !RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend
communitySendEnabled: RootStore.tokensStore.showCommunityAssetsInSend
swapEnabled: !RootStore.overview.isWatchOnlyAccount swapEnabled: !RootStore.overview.isWatchOnlyAccount
swapVisible: Global.featureFlags.swapEnabled swapVisible: Global.featureFlags.swapEnabled
@ -266,7 +267,8 @@ RightTabBaseView {
token.symbol, RootStore.currencyStore.currentCurrency) token.symbol, RootStore.currencyStore.currentCurrency)
assetDetailView.token = token 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 stack.currentIndex = 2
} }
} }
@ -283,7 +285,7 @@ RightTabBaseView {
filterVisible: filterButton.checked filterVisible: filterButton.checked
onCollectibleClicked: { onCollectibleClicked: {
RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId) RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId)
RootStore.setCurrentViewedHolding(uid, uid, tokenType) RootStore.setCurrentViewedHolding(uid, uid, tokenType, communityId)
d.detailedCollectibleActivityController.resetFilter() d.detailedCollectibleActivityController.resetFilter()
d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":"))) d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")))
d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false) d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false)

View File

@ -58,8 +58,10 @@ Control {
// switches configuring right click menu // switches configuring right click menu
property bool sendEnabled: true property bool sendEnabled: true
property bool communitySendEnabled: false
property bool swapEnabled: true property bool swapEnabled: true
property bool swapVisible: true property bool swapVisible: true
property bool communitySwapVisible: false
property string balanceError property string balanceError
@ -267,13 +269,16 @@ Control {
readonly property string key: model.key readonly property string key: model.key
readonly property string communityKey: model.communityId readonly property string communityKey: model.communityId
readonly property bool isCommunity: !!model.isCommunity
onClosed: destroy() onClosed: destroy()
sendEnabled: root.sendEnabled sendEnabled: root.sendEnabled
&& (!isCommunity || root.communitySendEnabled)
swapEnabled: root.swapEnabled swapEnabled: root.swapEnabled
swapVisible: root.swapVisible swapVisible: root.swapVisible && (!isCommunity || root.communitySwapVisible)
hideVisible: model.canBeHidden hideVisible: model.canBeHidden
communityHideVisible: !!model.isCommunity communityHideVisible: isCommunity
onSendRequested: root.sendRequested(key) onSendRequested: root.sendRequested(key)
onReceiveRequested: root.receiveRequested(key) onReceiveRequested: root.receiveRequested(key)