Global.settingsSubsection property (UI state in singleton) removed

This commit is contained in:
Michał Cieślak 2024-10-18 23:43:29 +02:00 committed by Michał
parent 5a97b034e2
commit 5acb9fc8fb
5 changed files with 30 additions and 12 deletions

View File

@ -34,6 +34,8 @@ import AppLayouts.Communities.stores 1.0 as CommunitiesStore
StatusSectionLayout {
id: root
property alias settingsSubsection: profileContainer.currentIndex
objectName: "profileStatusSectionLayout"
property SharedStores.RootStore sharedRootStore
@ -56,7 +58,7 @@ StatusSectionLayout {
onNotificationButtonClicked: Global.openActivityCenterPopup()
onBackButtonClicked: {
switch (Global.settingsSubsection) {
switch (root.settingsSubsection) {
case Constants.settingsSubsection.contacts:
Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.messaging)
break;
@ -75,8 +77,7 @@ StatusSectionLayout {
}
Component.onCompleted: {
profileContainer.currentIndex = -1
profileContainer.currentIndex = Qt.binding(() => Global.settingsSubsection)
profileContainer.currentIndexChanged()
root.store.devicesStore.loadDevices() // Load devices to get non-paired number for badge
}
@ -109,6 +110,12 @@ StatusSectionLayout {
profileContainer.currentItem.notifyDirty();
}
}
onSettingsSubsectionChanged: root.settingsSubsection = settingsSubsection
Binding on settingsSubsection {
value: root.settingsSubsection
}
}
centerPanel: StackLayout {
@ -119,8 +126,6 @@ StatusSectionLayout {
anchors.fill: parent
anchors.leftMargin: Constants.settingsSection.leftMargin
currentIndex: Global.settingsSubsection
onCurrentIndexChanged: {
if (!!children[currentIndex] && !children[currentIndex].active)
children[currentIndex].active = true

View File

@ -22,6 +22,8 @@ Column {
property bool walletMenuItemEnabled: false
property int settingsSubsection
signal menuItemClicked(var menu_item)
Repeater {
@ -33,7 +35,7 @@ Column {
itemId: model.subsection
title: model.text
asset.name: model.icon
selected: Global.settingsSubsection === model.subsection
selected: root.settingsSubsection === model.subsection
highlighted: !!betaTagLoader.item && betaTagLoader.item.hovered
onClicked: root.menuItemClicked(model)
badge.value: {
@ -85,7 +87,7 @@ Column {
itemId: model.subsection
title: model.text
asset.name: model.icon
selected: Global.settingsSubsection === model.subsection
selected: root.settingsSubsection === model.subsection
onClicked: root.menuItemClicked(model)
visible: {
(model.subsection !== Constants.settingsSubsection.wallet) ||
@ -116,7 +118,7 @@ Column {
itemId: model.subsection
title: model.text
asset.name: model.icon
selected: Global.settingsSubsection === model.subsection
selected: root.settingsSubsection === model.subsection
onClicked: root.menuItemClicked(model)
}
}
@ -134,7 +136,7 @@ Column {
itemId: model.subsection
title: model.text
asset.name: model.icon
selected: Global.settingsSubsection === model.subsection
selected: root.settingsSubsection === model.subsection
onClicked: root.menuItemClicked(model)
}
}

View File

@ -18,6 +18,8 @@ Item {
signal menuItemClicked(var event)
property alias settingsSubsection: profileMenu.settingsSubsection
StatusNavigationPanelHeadline {
id: title
text: qsTr("Settings")
@ -68,7 +70,7 @@ Item {
if (menu_item.subsection === Constants.settingsSubsection.signout)
return confirmDialog.open()
Global.settingsSubsection = menu_item.subsection
profileMenu.settingsSubsection = menu_item.subsection
}
}
}

View File

@ -501,7 +501,7 @@ Item {
appMain.rootStore.mainModuleInst.setActiveSectionBySectionType(sectionType)
if (sectionType === Constants.appSection.profile) {
Global.settingsSubsection = subsection;
profileLoader.settingsSubsection = subsection
Global.settingsSubSubsection = subSubsection;
} else if (sectionType === Constants.appSection.wallet) {
appView.children[Constants.appViewStackIndex.wallet].item.openDesiredView(subsection, subSubsection, data)
@ -1432,6 +1432,10 @@ Item {
}
Loader {
id: profileLoader
property int settingsSubsection: Constants.settingsSubsection.profile
active: appView.currentIndex === Constants.appViewStackIndex.profile
asynchronous: true
sourceComponent: ProfileLayout {
@ -1448,6 +1452,12 @@ Item {
collectiblesStore: appMain.walletCollectiblesStore
currencyStore: appMain.currencyStore
isCentralizedMetricsEnabled: appMain.isCentralizedMetricsEnabled
Binding on settingsSubsection {
value: profileLoader.settingsSubsection
}
onSettingsSubsectionChanged: profileLoader.settingsSubsection = settingsSubsection
}
}

View File

@ -6,7 +6,6 @@ QtObject {
id: root
property bool activityPopupOpened: false
property int settingsSubsection: Constants.settingsSubsection.profile
property int settingsSubSubsection: -1
property bool appIsReady: false