Settings, Advanced: mirror stack transition when clicking on a button on the left

This commit is contained in:
rating89us 2021-12-07 23:49:35 +01:00
parent bddb9b0050
commit 70e3c2d3ad
3 changed files with 16 additions and 5 deletions

View file

@ -32,6 +32,8 @@ import "." as MoneroComponents
Rectangle { Rectangle {
default property list<MoneroComponents.NavbarItem> items default property list<MoneroComponents.NavbarItem> items
property alias currentIndex: repeater.currentIndex
property alias previousIndex: repeater.previousIndex
color: "transparent" color: "transparent"
height: grid.height height: grid.height
@ -100,7 +102,10 @@ Rectangle {
} }
Repeater { Repeater {
id: repeater
model: items.length model: items.length
property int currentIndex: 0
property int previousIndex: 0
RowLayout { RowLayout {
spacing: 0 spacing: 0
@ -149,7 +154,11 @@ Rectangle {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: items[index].selected() onClicked: {
repeater.previousIndex = repeater.currentIndex;
repeater.currentIndex = index;
items[index].selected()
}
} }
} }

View file

@ -43,6 +43,7 @@ ColumnLayout {
property alias state: stateView.state property alias state: stateView.state
MoneroComponents.Navbar { MoneroComponents.Navbar {
id: navbarId
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.topMargin: height Layout.topMargin: height
Layout.bottomMargin: height Layout.bottomMargin: height
@ -128,7 +129,7 @@ ColumnLayout {
PropertyAnimation { PropertyAnimation {
target: enterItem target: enterItem
property: "x" property: "x"
from: 0 - target.width from: (navbarId.currentIndex < navbarId.previousIndex ? 1 : -1) * - target.width
to: 0 to: 0
duration: 300 duration: 300
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
@ -137,7 +138,7 @@ ColumnLayout {
target: exitItem target: exitItem
property: "x" property: "x"
from: 0 from: 0
to: target.width to: (navbarId.currentIndex < navbarId.previousIndex ? 1 : -1) * target.width
duration: 300 duration: 300
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }

View file

@ -49,6 +49,7 @@ ColumnLayout {
property alias settingsStateViewState: settingsStateView.state property alias settingsStateViewState: settingsStateView.state
MoneroComponents.Navbar { MoneroComponents.Navbar {
id: navbarId
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.topMargin: height Layout.topMargin: height
Layout.bottomMargin: height Layout.bottomMargin: height
@ -145,7 +146,7 @@ ColumnLayout {
PropertyAnimation { PropertyAnimation {
target: enterItem target: enterItem
property: "x" property: "x"
from: 0 - target.width from: (navbarId.currentIndex < navbarId.previousIndex ? 1 : -1) * - target.width
to: 0 to: 0
duration: 300 duration: 300
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
@ -154,7 +155,7 @@ ColumnLayout {
target: exitItem target: exitItem
property: "x" property: "x"
from: 0 from: 0
to: target.width to: (navbarId.currentIndex < navbarId.previousIndex ? 1 : -1) * target.width
duration: 300 duration: 300
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
} }