2024-07-03 11:47:05 +00:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Two-tabs panel holding searchable lists of assets (single level) and
|
|
|
|
|
collectibles (two levels).
|
|
|
|
|
|
|
|
|
|
Structure:
|
|
|
|
|
|
|
|
|
|
TabBar (assets, collectibles)
|
|
|
|
|
StackLayout (current index bound to tab bar's current index)
|
|
|
|
|
Assets List (assets part)
|
|
|
|
|
StackView (collectibles part)
|
|
|
|
|
Collectibles List (top level - groups by collection/community)
|
|
|
|
|
Collectibles List (nested level, on demand)
|
|
|
|
|
*/
|
|
|
|
|
Control {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
enum Tabs {
|
|
|
|
|
Assets = 0,
|
|
|
|
|
Collectibles = 1
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
/** Expected model structure: see SearchableAssetsPanel::model **/
|
|
|
|
|
property alias assetsModel: searchableAssetsPanel.model
|
2024-07-03 11:47:05 +00:00
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
/** Expected model structure: see SearchableCollectiblesPanel::model **/
|
|
|
|
|
property alias collectiblesModel: searchableCollectiblesPanel.model
|
2024-07-03 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
// Index of the current tab, indexes correspond to the Tabs enum values.
|
|
|
|
|
property alias currentTab: tabBar.currentIndex
|
|
|
|
|
|
|
|
|
|
signal assetSelected(string key)
|
|
|
|
|
signal collectionSelected(string key)
|
|
|
|
|
signal collectibleSelected(string key)
|
|
|
|
|
|
|
|
|
|
property string highlightedKey: ""
|
|
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
|
StatusTabBar {
|
|
|
|
|
id: tabBar
|
|
|
|
|
|
2024-09-03 14:29:22 +00:00
|
|
|
|
objectName: "tokensTabBar"
|
|
|
|
|
|
2024-09-18 11:03:36 +00:00
|
|
|
|
Layout.fillWidth: true
|
2024-07-03 11:47:05 +00:00
|
|
|
|
visible: !!root.assetsModel && !!root.collectiblesModel
|
|
|
|
|
|
2024-09-18 14:10:04 +00:00
|
|
|
|
currentIndex: !!root.collectiblesModel && !root.assetsModel
|
|
|
|
|
? TokenSelectorPanel.Tabs.Collectibles
|
|
|
|
|
: TokenSelectorPanel.Tabs.Assets
|
2024-07-03 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
StatusTabButton {
|
2024-09-03 14:29:22 +00:00
|
|
|
|
objectName: "assetsTab"
|
|
|
|
|
|
2024-07-03 11:47:05 +00:00
|
|
|
|
text: qsTr("Assets")
|
|
|
|
|
width: implicitWidth
|
|
|
|
|
|
|
|
|
|
visible: !!root.assetsModel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusTabButton {
|
2024-09-03 14:29:22 +00:00
|
|
|
|
objectName: "collectiblesTab"
|
|
|
|
|
|
2024-07-03 11:47:05 +00:00
|
|
|
|
text: qsTr("Collectibles")
|
|
|
|
|
width: implicitWidth
|
|
|
|
|
|
|
|
|
|
visible: !!root.collectiblesModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackLayout {
|
|
|
|
|
Layout.maximumHeight: 400
|
|
|
|
|
|
|
|
|
|
visible: !!root.assetsModel || !!root.collectiblesModel
|
|
|
|
|
currentIndex: tabBar.currentIndex
|
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
SearchableAssetsPanel {
|
|
|
|
|
id: searchableAssetsPanel
|
2024-07-03 11:47:05 +00:00
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
2024-07-03 11:47:05 +00:00
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
onSelected: root.assetSelected(key)
|
2024-07-03 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
SearchableCollectiblesPanel {
|
|
|
|
|
id: searchableCollectiblesPanel
|
2024-07-03 11:47:05 +00:00
|
|
|
|
|
|
|
|
|
Layout.preferredHeight: visible ? currentItem.implicitHeight : 0
|
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
|
onCollectibleSelected: root.collectibleSelected(key)
|
|
|
|
|
onCollectionSelected: root.collectionSelected(key)
|
2024-07-03 11:47:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|