Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@desktop/wallet): Add option to not show Popular section in TokenSelectorViewAdaptor.qml #17179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ QObject {
property var enabledChainIds: []
property string accountAddress
property bool showCommunityAssets
// Incase of SendModal we show SNT, ETH and DAI with 0 balance
property bool showZeroBalanceForDefaultTokens: false

// output model
readonly property SortFilterProxyModel outputAssetsModel: SortFilterProxyModel {
Expand Down Expand Up @@ -111,7 +113,7 @@ QObject {
id: tokensWithBalance
filters: [
ValueFilter {
roleName: "currencyBalance"
roleName: "balancesModelCount"
value: 0
inverted: true
}
Expand Down Expand Up @@ -154,6 +156,7 @@ QObject {
: ""

readonly property var balances: this
readonly property int balancesModelCount: delegateRoot.ModelCount.count

sourceModel: joinModel

Expand Down Expand Up @@ -185,6 +188,7 @@ QObject {
roleName: "balance"
value: "0"
inverted: true
enabled: !root.showZeroBalanceForDefaultTokens
},
RegExpFilter {
roleName: "account"
Expand Down Expand Up @@ -219,7 +223,7 @@ QObject {
}
}

exposedRoles: ["tokensKey", "balances", "currentBalance", "currencyBalance", "currencyBalanceAsString", "balanceAsString"]
exposedRoles: ["tokensKey", "balances", "currentBalance", "currencyBalance", "currencyBalanceAsString", "balanceAsString", "balancesModelCount"]
expectedRoles: [ "tokensKey", "communityId", "balances", "decimals", "marketDetails"]
}
}
Expand Down
6 changes: 5 additions & 1 deletion ui/app/AppLayouts/Wallet/controls/TokenSelector.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Control {

readonly property bool isTokenSelected: tokenSelectorButton.selected

property bool showSectionName: true

signal assetSelected(string key)
signal collectionSelected(string key)
signal collectibleSelected(string key)
Expand Down Expand Up @@ -49,7 +51,7 @@ Control {
QObject {
id: d

readonly property int maxPopupHeight: 330
readonly property int maxPopupHeight: 455
}

contentItem: TokenSelectorButton {
Expand Down Expand Up @@ -100,6 +102,8 @@ Control {
dropdown.close()
}

showSectionName: root.showSectionName

onAssetSelected: {
const entry = ModelUtils.getByKey(assetsModel, "tokensKey", key)
highlightedKey = key
Expand Down
15 changes: 14 additions & 1 deletion ui/app/AppLayouts/Wallet/panels/SearchableAssetsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import QtQuick.Layouts 1.15
import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Popups.Dialog 0.1

import AppLayouts.Wallet.views 1.0
Expand Down Expand Up @@ -33,6 +34,7 @@ Control {
property alias model: sfpm.sourceModel
property string highlightedKey
property string nonInteractiveKey
property bool showSectionName: true

signal selected(string key)

Expand Down Expand Up @@ -63,13 +65,23 @@ Control {
contentItem: ColumnLayout {
spacing: 0

StatusBaseText {
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 4
text: qsTr("Your assets will appear here")
color: Theme.palette.baseColor1
visible: !listView.count && !searchBox.text
}

TokenSearchBox {
id: searchBox

objectName: "searchBox"

Layout.fillWidth: true
placeholderText: qsTr("Search assets")
placeholderText: qsTr("Search for token or enter token address")

visible: listView.count || !!searchBox.text

Keys.forwardTo: [listView]
}
Expand Down Expand Up @@ -100,6 +112,7 @@ Control {
section.delegate: TokenSelectorSectionDelegate {
width: ListView.view.width
text: section
height: root.showSectionName ? implicitHeight : 0
}

delegate: TokenSelectorAssetDelegate {
Expand Down
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Wallet/panels/SendModalHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ RowLayout {
TokenSelectorButton.Size.Normal

enabled: root.interactive
showSectionName: false

assetsModel: root.assetsModel
collectiblesModel: root.displayOnlyAssets ? null: root.collectiblesModel
Expand Down
10 changes: 10 additions & 0 deletions ui/app/AppLayouts/Wallet/panels/TokenSelectorPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import StatusQ.Popups.Dialog 0.1
import StatusQ.Controls 0.1

/**
Expand Down Expand Up @@ -34,6 +35,8 @@ Control {
// Index of the current tab, indexes ​​correspond to the Tabs enum values.
property alias currentTab: tabBar.currentIndex

property bool showSectionName: true

signal assetSelected(string key)
signal collectionSelected(string key)
signal collectibleSelected(string key)
Expand All @@ -46,6 +49,7 @@ Control {
}

contentItem: ColumnLayout {
spacing: 0
StatusTabBar {
id: tabBar

Expand Down Expand Up @@ -77,6 +81,11 @@ Control {
}
}

StatusDialogDivider {
Layout.topMargin: -9
Layout.fillWidth: true
}

SearchableAssetsPanel {
id: searchableAssetsPanel

Expand All @@ -86,6 +95,7 @@ Control {
Layout.fillHeight: true

highlightedKey: root.highlightedKey
showSectionName: root.showSectionName

onSelected: root.assetSelected(key)
}
Expand Down
1 change: 1 addition & 0 deletions ui/app/mainui/SendModalHandler.qml
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ QtObject {

currentCurrency: root.currentCurrency
showCommunityAssets: root.showCommunityAssetsInSend
showZeroBalanceForDefaultTokens: true

accountAddress: simpleSendModal.selectedAccountAddress
enabledChainIds: [simpleSendModal.selectedChainId]
Expand Down