Spectral/qml/component/SideNavButton.qml

44 lines
1.0 KiB
QML
Raw Normal View History

2018-07-09 02:45:26 +00:00
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import QtQuick.Controls.Material 2.4
2018-03-21 11:13:47 +00:00
Item {
property var page
2018-03-21 11:13:47 +00:00
property alias contentItem: buttonDelegate.contentItem
signal clicked
id: sideNavButton
Layout.fillWidth: true
Layout.preferredHeight: width
Rectangle {
width: stackView.currentItem === page ? parent.width : 0
height: parent.height
anchors.bottom: buttonDelegate.bottom
color: Qt.lighter(Material.accent)
Behavior on width {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
}
ButtonDelegate {
id: buttonDelegate
anchors.fill: parent
onClicked: {
2018-07-09 02:45:26 +00:00
if(!page && stackView.currentItem !== page) {
2018-03-21 11:13:47 +00:00
if(stackView.depth === 1) {
stackView.replace(page)
} else {
stackView.clear()
stackView.push(page)
}
}
sideNavButton.clicked()
}
}
}