Change SwipeView to StackView and clean code.

This commit is contained in:
Black Hat
2018-03-01 19:15:04 +08:00
parent c3367543bf
commit 2ac0d0cd8b
7 changed files with 54 additions and 83 deletions

View File

@@ -4,7 +4,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.3
Item {
property int index
property Item page
property alias contentItem: itemDelegate.contentItem
signal clicked
@@ -14,13 +14,13 @@ Item {
Layout.preferredHeight: width
Rectangle {
width: swipeView.currentIndex === index ? parent.width : 0
width: stackView.currentItem === page ? parent.width : 0
height: parent.height
anchors.bottom: itemDelegate.bottom
color: Qt.lighter(Material.accent)
Behavior on width {
PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 }
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
}
@@ -29,7 +29,14 @@ Item {
anchors.fill: parent
onClicked: {
swipeView.currentIndex = index
if(page != null) {
if(stackView.depth === 1) {
stackView.replace(page)
} else {
stackView.clear()
stackView.push(page)
}
}
buttonDelegate.clicked()
}
}