Spectral/qml/component/SideNavButton.qml

32 lines
728 B
QML
Raw Normal View History

2018-07-12 01:44:41 +00:00
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
2018-03-21 11:13:47 +00:00
2018-09-02 13:26:42 +00:00
ItemDelegate {
property var page
2018-09-02 13:26:42 +00:00
readonly property bool selected: stackView.currentItem === page
2018-03-21 11:13:47 +00:00
Rectangle {
2018-09-02 13:26:42 +00:00
width: selected ? 4 : 0
2018-03-21 11:13:47 +00:00
height: parent.height
2018-09-02 13:26:42 +00:00
color: Material.accent
2018-03-21 11:13:47 +00:00
Behavior on width {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
}
2018-09-02 13:26:42 +00:00
onClicked: {
if(page && stackView.currentItem !== page) {
if(stackView.depth === 1) {
stackView.replace(page)
} else {
stackView.clear()
stackView.push(page)
2018-03-21 11:13:47 +00:00
}
}
}
}