2023-10-24 11:21:20 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
2023-11-17 14:08:43 +00:00
|
|
|
import utils 1.0
|
2023-10-24 11:21:20 +00:00
|
|
|
|
2023-10-25 10:40:10 +00:00
|
|
|
import AppLayouts.Profile.panels 1.0
|
2023-11-17 14:08:43 +00:00
|
|
|
import AppLayouts.Wallet.panels 1.0
|
2023-10-25 10:40:10 +00:00
|
|
|
|
2023-10-24 11:21:20 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
2023-10-25 10:40:10 +00:00
|
|
|
required property var sourcesOfTokensModel // Expected roles: key, name, updatedAt, source, version, tokensCount, image
|
|
|
|
required property var tokensListModel // Expected roles: name, symbol, image, chainName, explorerUrl
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
required property var baseWalletAssetsModel
|
|
|
|
required property var baseWalletCollectiblesModel
|
|
|
|
|
|
|
|
readonly property bool dirty: {
|
|
|
|
if (!loader.item)
|
|
|
|
return false
|
|
|
|
if (tabBar.currentIndex > d.collectiblesTabIndex)
|
|
|
|
return false
|
2023-11-22 19:58:02 +00:00
|
|
|
if (tabBar.currentIndex === d.collectiblesTabIndex && baseWalletCollectiblesModel.isFetching)
|
2023-11-17 14:08:43 +00:00
|
|
|
return false
|
|
|
|
return loader.item && loader.item.dirty
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveChanges() {
|
|
|
|
if (tabBar.currentIndex > d.collectiblesTabIndex)
|
|
|
|
return
|
|
|
|
loader.item.saveSettings()
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetChanges() {
|
|
|
|
if (tabBar.currentIndex > d.collectiblesTabIndex)
|
|
|
|
return
|
|
|
|
loader.item.revert()
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int assetsTabIndex: 0
|
|
|
|
readonly property int collectiblesTabIndex: 1
|
|
|
|
readonly property int tokenSourcesTabIndex: 2
|
|
|
|
|
|
|
|
function checkLoadMoreCollectibles() {
|
|
|
|
if (tabBar.currentIndex !== collectiblesTabIndex)
|
|
|
|
return
|
|
|
|
// If there is no more items to load or we're already fetching, return
|
2023-11-22 19:58:02 +00:00
|
|
|
if (!root.baseWalletCollectiblesModel.hasMore || root.baseWalletCollectiblesModel.isFetching)
|
2023-11-17 14:08:43 +00:00
|
|
|
return
|
2023-11-22 19:58:02 +00:00
|
|
|
root.baseWalletCollectiblesModel.loadMore()
|
2023-11-17 14:08:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2023-11-22 19:58:02 +00:00
|
|
|
target: root.baseWalletCollectiblesModel
|
2023-11-17 14:08:43 +00:00
|
|
|
function onHasMoreChanged() {
|
|
|
|
d.checkLoadMoreCollectibles()
|
|
|
|
}
|
|
|
|
function onIsFetchingChanged() {
|
|
|
|
d.checkLoadMoreCollectibles()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-24 11:21:20 +00:00
|
|
|
StatusTabBar {
|
|
|
|
id: tabBar
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: 5
|
|
|
|
|
|
|
|
StatusTabButton {
|
2023-11-17 14:08:43 +00:00
|
|
|
leftPadding: 0
|
2023-10-24 11:21:20 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Assets")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
width: implicitWidth
|
2023-11-17 14:08:43 +00:00
|
|
|
text: qsTr("Collectibles")
|
2023-10-24 11:21:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Token lists")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
// NB: we want to discard any pending unsaved changes when switching tabs or navigating away
|
|
|
|
Loader {
|
|
|
|
id: loader
|
2023-10-24 11:21:20 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-11-17 14:08:43 +00:00
|
|
|
active: visible
|
|
|
|
|
|
|
|
sourceComponent: {
|
|
|
|
switch (tabBar.currentIndex) {
|
|
|
|
case d.assetsTabIndex:
|
|
|
|
return tokensPanel
|
|
|
|
case d.collectiblesTabIndex:
|
|
|
|
return collectiblesPanel
|
|
|
|
case d.tokenSourcesTabIndex:
|
|
|
|
return supportedTokensListPanel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
Component {
|
|
|
|
id: tokensPanel
|
|
|
|
ManageAssetsPanel {
|
|
|
|
baseModel: root.baseWalletAssetsModel
|
2023-10-24 11:21:20 +00:00
|
|
|
}
|
2023-11-17 14:08:43 +00:00
|
|
|
// TODO #12611 add Advanced section
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
Component {
|
|
|
|
id: collectiblesPanel
|
|
|
|
ManageCollectiblesPanel {
|
|
|
|
baseModel: root.baseWalletCollectiblesModel
|
|
|
|
Component.onCompleted: d.checkLoadMoreCollectibles()
|
2023-10-24 11:21:20 +00:00
|
|
|
}
|
2023-11-17 14:08:43 +00:00
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
Component {
|
|
|
|
id: supportedTokensListPanel
|
2023-10-25 10:40:10 +00:00
|
|
|
SupportedTokenListsPanel {
|
|
|
|
sourcesOfTokensModel: root.sourcesOfTokensModel
|
|
|
|
tokensListModel: root.tokensListModel
|
2023-10-24 11:21:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|