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,89 +1,111 @@
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")
StackView { ColumnLayout{
id: stack spacing: 0
objectName: "stackView"
anchors.fill: parent anchors.fill: parent
initialItem: ScrollView {
id: entry
anchors.fill: parent Rectangle {
id: navbar
color: "red"
visible: false
Layout.fillWidth: true
Layout.preferredHeight: 44
}
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff Rectangle {
ScrollBar.vertical.policy: ScrollBar.AlwaysOff Layout.fillWidth: true
Layout.fillHeight: true
ListView { StackView {
width: parent.width id: stack
model: 23 objectName: "stackView"
delegate: Rectangle { anchors.fill: parent
Column {
anchors.centerIn: parent initialItem: ScrollView {
Text { id: entry
text: {
switch (index) { anchors.fill: parent
case 0:
return "ComponetDemo.js" ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
case 1: ScrollBar.vertical.policy: ScrollBar.AlwaysOff
return "Counter.js"
case 2: ListView {
return "DraggableDemo.js" width: parent.width
case 3: model: 23
return "EffectsDemo.js" boundsBehavior: Flickable.StopAtBounds
case 4:
return "FlexDemo.js" delegate: Rectangle {
case 5: Column {
return "Gobang.js" anchors.centerIn: parent
case 6: Text {
return "ImageDemo.js" text: {
case 7: switch (index) {
return "InputDemo.js" case 0:
case 8: return "ComponetDemo.js"
return "LayoutDemo.js" case 1:
case 9: return "Counter.js"
return "LayoutTestDemo.js" case 2:
case 10: return "DraggableDemo.js"
return "ModalDemo.js" case 3:
case 11: return "EffectsDemo.js"
return "ModularDemo.js" case 4:
case 12: return "FlexDemo.js"
return "NavigatorDemo.js" case 5:
case 13: return "Gobang.js"
return "NetworkDemo.js" case 6:
case 14: return "ImageDemo.js"
return "NotificationDemo.js" case 7:
case 15: return "InputDemo.js"
return "PopoverDemo.js" case 8:
case 16: return "LayoutDemo.js"
return "ScrollerDemo.js" case 9:
case 17: return "LayoutTestDemo.js"
return "SimpleDemo.js" case 10:
case 18: return "ModalDemo.js"
return "SliderDemo.js" case 11:
case 19: return "ModularDemo.js"
return "Snake.js" case 12:
case 20: return "NavigatorDemo.js"
return "StorageDemo.js" case 13:
case 21: return "NetworkDemo.js"
return "SwitchDemo.js" case 14:
case 22: return "NotificationDemo.js"
return "TextDemo.js" case 15:
return "PopoverDemo.js"
case 16:
return "ScrollerDemo.js"
case 17:
return "SimpleDemo.js"
case 18:
return "SliderDemo.js"
case 19:
return "Snake.js"
case 20:
return "StorageDemo.js"
case 21:
return "SwitchDemo.js"
case 22:
return "TextDemo.js"
}
}
}
}
width: parent.width
height: 60
MouseArea {
anchors.fill: parent
onClicked: {
demoBridge.navigate(index)
} }
} }
}
}
width: parent.width
height: 60
MouseArea {
anchors.fill: parent
onClicked: {
demoBridge.navigate(index)
} }
} }
} }
@ -93,5 +115,19 @@ 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
}
} }
} }