feat(HoldingsDropdown): Added no data information message

- Added default no data information message for assets and collectibles.
- Added specific no data information message for airdrop functionality.
- Hidden searcher when there is no data available.

Part of #9938
This commit is contained in:
Noelia 2023-03-23 19:26:38 +01:00 committed by Noelia
parent a6e29ebc03
commit 575ee6a226
4 changed files with 37 additions and 5 deletions

View File

@ -23,6 +23,7 @@ Item {
property var checkedKeys: []
property int type: ExtendedDropdownContent.Type.Assets
property string noDataText: qsTr("No data found")
readonly property bool canGoBack: root.state !== d.depth1_ListState
@ -81,6 +82,13 @@ Item {
property url currentItemSource: ""
readonly property bool searchMode: searcher.text.length > 0
readonly property bool availableData: {
if(root.type === ExtendedDropdownContent.Type.Assets && root.assetsModel && root.assetsModel.count > 0)
return true
if(root.type === ExtendedDropdownContent.Type.Collectibles && root.collectiblesModel && root.collectiblesModel.count > 0)
return true
return false
}
onCurrentModelChanged: {
// Workaround for a bug in SortFilterProxyModel causing that model
@ -337,6 +345,7 @@ Item {
Layout.fillWidth: true
Layout.topMargin: root.state === d.depth1_ListState ? 0 : 8
visible: d.availableData
topPadding: 0
bottomPadding: 0
minimumHeight: 36
@ -388,6 +397,8 @@ Item {
id: assetsListView
ListDropdownContent {
availableData: d.availableData
noDataText: root.noDataText
headerModel: ListModel {
ListElement { key: "MINT"; icon: "add"; iconSize: 16; description: qsTr("Mint asset"); rotation: 0; spacing: 8 }
ListElement { key: "IMPORT"; icon: "invite-users"; iconSize: 16; description: qsTr("Import existing asset"); rotation: 180; spacing: 8 }
@ -414,6 +425,8 @@ Item {
id: collectiblesListView
ListDropdownContent {
availableData: d.availableData
noDataText: root.noDataText
areHeaderButtonsVisible: root.state === d.depth1_ListState
headerModel: ListModel {
ListElement { key: "MINT"; icon: "add"; iconSize: 16; description: qsTr("Mint collectible"); rotation: 0; spacing: 8 }

View File

@ -17,6 +17,13 @@ StatusDropdown {
property var collectiblesModel
property bool isENSTab: true
property bool isCollectiblesOnly: false
property string noDataText: {
if(d.currentHoldingType === HoldingTypes.Type.Asset)
return qsTr("No assets found")
if(d.currentHoldingType === HoldingTypes.Type.Collectible)
return qsTr("No collectibles found")
return qsTr("No data found")
}
property var usedTokens: []
property var usedEnsNames: []
@ -244,6 +251,7 @@ StatusDropdown {
assetsModel: root.assetsModel
collectiblesModel: root.collectiblesModel
noDataText: root.noDataText
checkedKeys: root.usedTokens.map(entry => entry.key)
type: d.extendedDropdownType

View File

@ -8,6 +8,7 @@ import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import utils 1.0
StatusListView {
id: root
@ -17,6 +18,8 @@ StatusListView {
property var headerModel
property bool areHeaderButtonsVisible: true
property bool searchMode: false
property bool availableData: false
property string noDataText: qsTr("No data found")
property int maxHeight: 381 // default by design
@ -72,7 +75,7 @@ StatusListView {
Layout.preferredHeight: visible ? d.sectionHeight : 0
Layout.fillWidth: true
visible: root.searchMode
visible: !root.availableData || root.searchMode
sourceComponent: sectionComponent
}
}
@ -122,18 +125,25 @@ StatusListView {
Item {
id: sectionDelegateRoot
property string section: root.count ?
qsTr("Search result") :
qsTr("No results")
property string section: {
if(!root.availableData)
return root.noDataText
if(root.count)
return qsTr("Search result")
return qsTr("No results")
}
StatusBaseText {
anchors.leftMargin: 8
anchors.leftMargin: Style.current.halfPadding
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: parent.width
text: sectionDelegateRoot.section
color: Theme.palette.baseColor1
font.pixelSize: 12
elide: Text.ElideRight
wrapMode: Text.WordWrap
lineHeight: 1.2
}
}
}

View File

@ -78,6 +78,7 @@ StatusScrollView {
collectiblesModel: root.collectiblesModel
isENSTab: false
isCollectiblesOnly: true
noDataText: qsTr("First you need to mint or import a collectible before you can perform an airdrop")
function addItem(type, item, amount) {
const key = item.key