add navbar

This commit is contained in:
王劲鹏 2021-06-09 11:44:27 +08:00 committed by osborn
parent dba0569256
commit 37ef313c10

View File

@ -1,16 +1,34 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.5 import QtQuick.Controls 2.5
import QtQuick.Layouts 1.15
ApplicationWindow { ApplicationWindow {
visible: true visible: true
width: 600 width: 600
height: 800 height: 844
title: qsTr("Doric Demo") title: qsTr("Doric Demo")
ColumnLayout{
spacing: 0
anchors.fill: parent
Rectangle {
id: navbar
color: "red"
visible: false
Layout.fillWidth: true
Layout.preferredHeight: 44
}
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
StackView { StackView {
id: stack id: stack
objectName: "stackView" objectName: "stackView"
anchors.fill: parent anchors.fill: parent
initialItem: ScrollView { initialItem: ScrollView {
id: entry id: entry
@ -22,6 +40,8 @@ ApplicationWindow {
ListView { ListView {
width: parent.width width: parent.width
model: 23 model: 23
boundsBehavior: Flickable.StopAtBounds
delegate: Rectangle { delegate: Rectangle {
Column { Column {
anchors.centerIn: parent anchors.centerIn: parent
@ -90,8 +110,24 @@ ApplicationWindow {
} }
} }
} }
}
}
function navigatorPush(page) { function navigatorPush(page) {
stack.push(page) stack.push(page)
if (stack.depth > 1) {
navbar.visible = true
} else {
navbar.visible = false
}
}
function navigatorPop() {
stack.pop()
if (stack.depth > 1) {
navbar.visible = true
} else {
navbar.visible = false
}
} }
} }