This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
fanny-app/qml/Pages/MainPage.qml

202 lines
4.7 KiB
QML
Raw Normal View History

2018-06-21 08:47:09 +02:00
import QtQuick 2.9
import QtQuick.Controls 2.4
import QtGraphicalEffects 1.0
2018-06-21 08:47:09 +02:00
import "../Components"
import "../Forms"
2018-07-19 20:08:46 +02:00
2018-06-21 08:47:09 +02:00
Page {
id: root
2018-06-25 08:07:05 +02:00
objectName: "MainPage"
2018-06-25 10:04:11 +02:00
2018-06-30 11:05:39 +02:00
Shortcut {
sequences: ["Esc", "Back"]
enabled: formStack.depth > 1
2018-06-30 11:05:39 +02:00
onActivated: {
formStack.pop()
2018-06-30 11:05:39 +02:00
}
}
StackView {
id: formStack
property var currPage
property string eventDay: ""
anchors {
top: toolBar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
onCurrPageChanged: {
mainStack.replace(currPage)
}
onCurrentItemChanged: {
formStack.currentItem.opened()
}
initialItem: homeForm
Component {
id: homeForm
HomeForm {}
}
Component {
id: foodPlanForm
FoodPlanForm {}
}
Component {
id: eventForm
EventForm {
day: formStack.eventDay
}
}
Component {
id: settingsForm
SettingsForm {}
}
Component {
id: filterForm
FilterForm {}
}
popEnter: Transition {
XAnimator {
from: (formStack.mirrored ? -1 : 1) * -formStack.width
to: 0
duration: 500
easing.type: Easing.OutCubic
}
}
popExit: Transition {
XAnimator {
from: 0
to: (formStack.mirrored ? -1 : 1) * formStack.width
duration: 500
easing.type: Easing.OutCubic
}
}
2018-06-21 08:47:09 +02:00
pushEnter: Transition {
XAnimator {
from: (formStack.mirrored ? -1 : 1) * formStack.width
to: 0
duration: 500
easing.type: Easing.OutCubic
}
}
pushExit: Transition {
XAnimator {
from: 0
to: (formStack.mirrored ? -1 : 1) * -formStack.width
duration: 500
easing.type: Easing.OutCubic
}
}
}
AppToolBar {
id: toolBar
anchors {
top: parent.top
left: parent.left
right: parent.right
topMargin: -60
}
height: 50
2018-07-19 20:08:46 +02:00
Button {
id:toolButton
enabled: true
2018-06-25 10:04:11 +02:00
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
2018-07-19 20:08:46 +02:00
leftMargin: parent.width *0.02
2018-06-25 10:04:11 +02:00
}
2018-07-19 20:08:46 +02:00
height: parent.height - parent.height * 0.5
width: height
2018-06-21 16:41:02 +02:00
2018-06-21 08:47:09 +02:00
onClicked: {
if (formStack.depth > 1) {
formStack.pop()
2018-06-21 08:47:09 +02:00
} else {
drawer.open()
}
}
2018-07-19 20:08:46 +02:00
onPressed: toolButton.scale = 0.9
onReleased: toolButton.scale = 1.0
background: Image {
source: formStack.depth > 1 ? "qrc:/graphics/icons/backDark.png" : "qrc:/graphics/icons/drawer.png"
2018-07-19 20:08:46 +02:00
height: parent.height
width: parent.width
Behavior on scale {
PropertyAnimation {
duration: 100
}
}
}
2018-06-21 08:47:09 +02:00
}
Label {
text: getText()
2018-07-19 17:19:09 +02:00
anchors {
verticalCenter: parent.verticalCenter
left: toolButton.right
2018-07-19 20:08:46 +02:00
leftMargin: parent.width * 0.02
2018-07-19 17:19:09 +02:00
}
2018-07-19 20:08:46 +02:00
font.bold: true
color: "black"
function getText(){
var titleString = "";
for(var i=1; i<formStack.depth; i++){
if(i > 1){
titleString += " > "
}
titleString += formStack.get(i).title
}
return(titleString)
}
2018-06-21 08:47:09 +02:00
}
2018-07-19 17:19:09 +02:00
Behavior on anchors.topMargin {
NumberAnimation {
duration: 500
easing.type: Easing.OutCubic
2018-07-19 17:19:09 +02:00
}
}
states: [
State {
name: "closed"
when: formStack.depth === 1
PropertyChanges {
target: toolBar
anchors.topMargin: -60
2018-07-19 20:08:46 +02:00
}
},
State {
name: "open"
when: formStack.depth > 1
PropertyChanges {
target: toolBar
anchors.topMargin: 0
2018-06-21 08:47:09 +02:00
}
}
]
2018-06-25 00:15:18 +02:00
}
2018-06-21 08:47:09 +02:00
}