2023-10-24 11:21:20 +00:00
|
|
|
|
import QtQuick 2.15
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import QtQuick.Controls 2.15
|
2023-10-24 11:21:20 +00:00
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
|
import StatusQ 0.1
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import StatusQ.Core 0.1
|
2023-10-24 11:21:20 +00:00
|
|
|
|
import StatusQ.Controls 0.1
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import StatusQ.Components 0.1
|
2024-01-16 16:22:05 +00:00
|
|
|
|
import StatusQ.Models 0.1
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
2024-01-04 12:05:54 +00:00
|
|
|
|
import shared.stores 1.0 as SharedStores
|
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
|
|
|
|
|
|
2024-01-24 16:35:53 +00:00
|
|
|
|
property var getCurrencyAmount: function (balance, symbol) {}
|
|
|
|
|
property var getCurrentCurrencyAmount: function(balance){}
|
|
|
|
|
|
2023-12-06 10:54:36 +00:00
|
|
|
|
property alias currentIndex: tabBar.currentIndex
|
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
|
readonly property bool dirty: {
|
|
|
|
|
if (!loader.item)
|
|
|
|
|
return false
|
2024-01-16 16:22:05 +00:00
|
|
|
|
if (tabBar.currentIndex > d.hiddenTabIndex)
|
2023-11-17 14:08:43 +00:00
|
|
|
|
return false
|
2024-01-04 12:05:54 +00:00
|
|
|
|
// FIXME take advanced settings into account here too (#13178)
|
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() {
|
2024-01-16 16:22:05 +00:00
|
|
|
|
if (tabBar.currentIndex > d.hiddenTabIndex)
|
2023-11-17 14:08:43 +00:00
|
|
|
|
return
|
2024-01-04 12:05:54 +00:00
|
|
|
|
// FIXME save advanced settings (#13178)
|
2023-11-17 14:08:43 +00:00
|
|
|
|
loader.item.saveSettings()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
|
|
|
|
|
readonly property int assetsTabIndex: 0
|
|
|
|
|
readonly property int collectiblesTabIndex: 1
|
2024-01-16 16:22:05 +00:00
|
|
|
|
readonly property int hiddenTabIndex: 2
|
|
|
|
|
readonly property int advancedTabIndex: 3
|
|
|
|
|
|
|
|
|
|
// assets
|
|
|
|
|
readonly property var assetsController: ManageTokensController {
|
|
|
|
|
sourceModel: root.baseWalletAssetsModel
|
|
|
|
|
settingsKey: "WalletAssets"
|
|
|
|
|
onTokenHidden: (symbol, name) => Global.displayToastMessage(
|
|
|
|
|
qsTr("%1 (%2) was successfully hidden").arg(name).arg(symbol), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
onCommunityTokenGroupHidden: (communityName) => Global.displayToastMessage(
|
|
|
|
|
qsTr("%1 community assets successfully hidden").arg(communityName), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
onTokenShown: (symbol, name) => Global.displayToastMessage(qsTr("%1 is now visible").arg(name), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
onCommunityTokenGroupShown: (communityName) => Global.displayToastMessage(
|
|
|
|
|
qsTr("%1 community assets are now visible").arg(communityName), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// collectibles
|
|
|
|
|
readonly property var renamedCollectiblesModel: RolesRenamingModel {
|
|
|
|
|
sourceModel: root.baseWalletCollectiblesModel
|
|
|
|
|
mapping: [
|
|
|
|
|
RoleRename {
|
|
|
|
|
from: "uid"
|
|
|
|
|
to: "symbol"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readonly property var collectiblesController: ManageTokensController {
|
|
|
|
|
sourceModel: d.renamedCollectiblesModel
|
|
|
|
|
settingsKey: "WalletCollectibles"
|
|
|
|
|
onTokenHidden: (symbol, name) => Global.displayToastMessage(
|
|
|
|
|
qsTr("%1 was successfully hidden").arg(name), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
onCommunityTokenGroupHidden: (communityName) => Global.displayToastMessage(
|
|
|
|
|
qsTr("%1 community collectibles successfully hidden").arg(communityName), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
onTokenShown: (symbol, name) => Global.displayToastMessage(qsTr("%1 is now visible").arg(name), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
onCommunityTokenGroupShown: (communityName) => Global.displayToastMessage(
|
|
|
|
|
qsTr("%1 community collectibles are now visible").arg(communityName), "", "checkmark-circle",
|
|
|
|
|
false, Constants.ephemeralNotificationType.success, "")
|
|
|
|
|
}
|
2023-11-17 14:08:43 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2024-01-16 16:22:05 +00:00
|
|
|
|
StatusTabButton {
|
|
|
|
|
width: implicitWidth
|
|
|
|
|
text: qsTr("Hidden")
|
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
StatusTabButton {
|
|
|
|
|
width: implicitWidth
|
2024-01-04 12:05:54 +00:00
|
|
|
|
text: qsTr("Advanced")
|
2023-10-24 11:21:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2024-01-16 16:22:05 +00:00
|
|
|
|
case d.hiddenTabIndex:
|
|
|
|
|
return hiddenPanel
|
2024-01-04 12:05:54 +00:00
|
|
|
|
case d.advancedTabIndex:
|
|
|
|
|
return advancedTab
|
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: tokensPanel
|
|
|
|
|
ManageAssetsPanel {
|
2024-01-24 16:35:53 +00:00
|
|
|
|
getCurrencyAmount: function (balance, symbol) {
|
|
|
|
|
return root.getCurrencyAmount(balance, symbol)
|
|
|
|
|
}
|
|
|
|
|
getCurrentCurrencyAmount: function (balance) {
|
|
|
|
|
return root.getCurrentCurrencyAmount(balance)
|
|
|
|
|
}
|
2024-01-16 16:22:05 +00:00
|
|
|
|
controller: d.assetsController
|
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: collectiblesPanel
|
|
|
|
|
ManageCollectiblesPanel {
|
2024-01-16 16:22:05 +00:00
|
|
|
|
controller: d.collectiblesController
|
2023-11-17 14:08:43 +00:00
|
|
|
|
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
|
|
|
|
|
2024-01-16 16:22:05 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: hiddenPanel
|
|
|
|
|
ManageHiddenPanel {
|
2024-01-25 18:53:09 +00:00
|
|
|
|
getCurrencyAmount: function (balance, symbol) {
|
|
|
|
|
return root.getCurrencyAmount(balance, symbol)
|
|
|
|
|
}
|
|
|
|
|
getCurrentCurrencyAmount: function (balance) {
|
|
|
|
|
return root.getCurrentCurrencyAmount(balance)
|
|
|
|
|
}
|
2024-01-16 16:22:05 +00:00
|
|
|
|
assetsController: d.assetsController
|
|
|
|
|
collectiblesController: d.collectiblesController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
|
Component {
|
2024-01-04 12:05:54 +00:00
|
|
|
|
id: advancedTab
|
|
|
|
|
ColumnLayout {
|
2024-01-22 16:29:05 +00:00
|
|
|
|
spacing: 8
|
2024-01-04 12:05:54 +00:00
|
|
|
|
StatusListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Show community assets when sending tokens")
|
|
|
|
|
|
|
|
|
|
components: [
|
|
|
|
|
StatusSwitch {
|
|
|
|
|
id: showCommunityAssetsSwitch
|
|
|
|
|
checked: true // FIXME integrate with backend (#13178)
|
|
|
|
|
onCheckedChanged: {
|
|
|
|
|
// FIXME integrate with backend (#13178)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
onClicked: {
|
|
|
|
|
showCommunityAssetsSwitch.checked = !showCommunityAssetsSwitch.checked
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StatusDialogDivider {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
}
|
|
|
|
|
StatusListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Don’t display assets with balance lower than")
|
|
|
|
|
|
|
|
|
|
components: [
|
|
|
|
|
CurrencyAmountInput {
|
|
|
|
|
enabled: displayThresholdSwitch.checked
|
|
|
|
|
currencySymbol: SharedStores.RootStore.currencyStore.currentCurrency
|
|
|
|
|
value: 0.10 // FIXME integrate with backend (#13178)
|
|
|
|
|
},
|
|
|
|
|
StatusSwitch {
|
|
|
|
|
id: displayThresholdSwitch
|
|
|
|
|
checked: false // FIXME integrate with backend (#13178)
|
|
|
|
|
onCheckedChanged: {
|
|
|
|
|
// FIXME integrate with backend (#13178)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
onClicked: {
|
|
|
|
|
displayThresholdSwitch.checked = !displayThresholdSwitch.checked
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-22 16:29:05 +00:00
|
|
|
|
StatusDialogDivider {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
}
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 64
|
|
|
|
|
Layout.topMargin: 18
|
|
|
|
|
Layout.bottomMargin: 18
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
text: qsTr("Token lists")
|
|
|
|
|
color: Style.current.textColor
|
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
text: qsTr("Last updated %1 @%2").arg(LocaleUtils.formatDate(root.sourcesOfTokensModel.get(0).updatedAt * 1000)).arg(LocaleUtils.formatTime(root.sourcesOfTokensModel.get(0).updatedAt, Locale.ShortFormat))
|
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SupportedTokenListsPanel {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
sourcesOfTokensModel: root.sourcesOfTokensModel
|
|
|
|
|
tokensListModel: root.tokensListModel
|
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|