fix: apply Custom order to main wallet view

also fix navigating into section/subsection

Fixes #13275
This commit is contained in:
Lukáš Tinkl 2024-01-24 12:02:03 +00:00 committed by Lukáš Tinkl
parent d7e25ea0a7
commit 3b99bcb29a
8 changed files with 71 additions and 32 deletions

View File

@ -20,7 +20,7 @@ FocusScope {
property alias titleRowComponentLoader: loader
property list<Item> headerComponents
property alias bottomHeaderComponents: secondHeaderRow.contentItem
default property Item content
default property alias content: contentWrapper.children
property alias titleLayout: titleLayout
property bool dirty: false
@ -49,8 +49,6 @@ FocusScope {
}
Component.onCompleted: {
content.parent = contentWrapper
if (headerComponents.length) {
for (let i in headerComponents) {
headerComponents[i].parent = titleRow

View File

@ -2,6 +2,7 @@ import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13
import Qt.labs.settings 1.1
import QtQml 2.15
import StatusQ.Controls 0.1
@ -22,6 +23,8 @@ import "../panels"
import AppLayouts.Profile.views.wallet 1.0
import AppLayouts.Wallet.stores 1.0
import AppLayouts.Wallet.controls 1.0
import AppLayouts.Wallet 1.0
SettingsContentBase {
id: root
@ -65,9 +68,22 @@ SettingsContentBase {
}
onSaveChangesClicked: {
manageTokensView.saveChanges()
let sectionLink = "%1/%2/".arg(Constants.appSection.wallet).arg(WalletLayout.LeftPanelSelection.AllAddresses)
if (Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets) {
sectionLink += WalletLayout.RightPanelSelection.Assets
priv.assetSettings.setValue("currentSortValue", SortOrderComboBox.TokenOrderCustom)
priv.assetSettings.sync()
} else if (Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles) {
sectionLink += WalletLayout.RightPanelSelection.Collectibles
priv.collectiblesSettings.setValue("currentSortValue", SortOrderComboBox.TokenOrderCustom)
priv.collectiblesSettings.sync()
}
Global.displayToastMessage(
qsTr("Your new custom token order has been applied to your %1", "Go to Wallet")
.arg(`<a style="text-decoration:none" href="#${Constants.appSection.wallet}">` + qsTr("Wallet", "Go to Wallet") + "</a>"),
.arg(`<a style="text-decoration:none" href="#${sectionLink}">` + qsTr("Wallet", "Go to Wallet") + "</a>"),
"",
"checkmark-circle",
false,
@ -79,6 +95,24 @@ SettingsContentBase {
manageTokensView.resetChanges()
}
readonly property var priv: QtObject {
id: priv
readonly property bool isManageTokensSubsection: Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageHidden ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAdvanced
readonly property var assetSettings: Settings {
category: "AssetsViewSortSettings"
//property int currentSortValue
}
readonly property var collectiblesSettings: Settings {
category: "CollectiblesViewSortSettings"
//property int currentSortValue
}
}
StackLayout {
id: stackContainer
@ -94,9 +128,7 @@ SettingsContentBase {
Binding on currentIndex {
value: root.manageTokensViewIndex
when: Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageTokenLists
when: priv.isManageTokensSubsection
restoreMode: Binding.RestoreNone
}
@ -294,13 +326,13 @@ SettingsContentBase {
return 0
case Constants.walletSettingsSubsection.manageCollectibles:
return 1
case Constants.walletSettingsSubsection.manageTokenLists:
return 2
case Constants.walletSettingsSubsection.manageHidden:
return 3
case Constants.walletSettingsSubsection.manageAdvanced:
return 4
}
}
when: Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles ||
Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageTokenLists
when: priv.isManageTokensSubsection
restoreMode: Binding.RestoreNone
}
}

View File

@ -49,12 +49,6 @@ ColumnLayout {
loader.item.saveSettings()
}
function resetChanges() {
if (tabBar.currentIndex > d.hiddenTabIndex)
return
loader.item.revert()
}
QtObject {
id: d

View File

@ -57,8 +57,8 @@ Item {
}
enum RightPanelSelection {
Collectibles,
Assets,
Collectibles,
Activity
}

View File

@ -157,12 +157,22 @@ ColumnLayout {
}
Settings {
id: settings
category: "CollectiblesViewSortSettings"
property alias currentSortField: cmbTokenOrder.currentIndex
property int currentSortValue: SortOrderComboBox.TokenOrderDateAdded
property alias currentSortOrder: cmbTokenOrder.currentSortOrder
property alias selectedFilterGroupIds: cmbFilter.selectedFilterGroupIds
}
Component.onCompleted: {
settings.sync()
cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue)
}
Component.onDestruction: {
settings.currentSortValue = cmbTokenOrder.currentValue
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: false

View File

@ -342,18 +342,12 @@ Item {
return
appMain.rootStore.mainModuleInst.setActiveSectionBySectionType(sectionType)
if (sectionType === Constants.appSection.profile) {
Global.settingsSubsection = subsection;
Global.settingsSubSubsection = settingsSubsection;
return
}
if (sectionType === Constants.appSection.wallet) {
appView.children[Constants.appViewStackIndex.wallet].item.openDesiredView(
WalletLayout.LeftPanelSelection.AllAddresses,
WalletLayout.RightPanelSelection.Activity,
data
)
Global.settingsSubSubsection = subSubsection;
} else if (sectionType === Constants.appSection.wallet) {
appView.children[Constants.appViewStackIndex.wallet].item.openDesiredView(subsection, subSubsection, data)
}
}

View File

@ -156,11 +156,21 @@ ColumnLayout {
}
Settings {
id: settings
category: "AssetsViewSortSettings"
property alias currentSortField: cmbTokenOrder.currentIndex
property int currentSortValue: SortOrderComboBox.TokenOrderCurrencyBalance
property alias currentSortOrder: cmbTokenOrder.currentSortOrder
}
Component.onCompleted: {
settings.sync()
cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue)
}
Component.onDestruction: {
settings.currentSortValue = cmbTokenOrder.currentValue
}
ColumnLayout {
Layout.fillWidth: true
Layout.preferredHeight: root.filterVisible ? implicitHeight : 0

View File

@ -357,7 +357,8 @@ QtObject {
readonly property int manageAccounts: 1
readonly property int manageAssets: 2
readonly property int manageCollectibles: 3
readonly property int manageTokenLists: 4
readonly property int manageHidden: 4
readonly property int manageAdvanced: 5
}
readonly property QtObject currentUserStatus: QtObject{