Add Pedalo Rules for viewing in the app
[harbour-pedalo.git] / qml / pages / MainPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import "../components"
4
5 Page {
6     id: page
7
8     // The effective value will be restricted by ApplicationWindow.allowedOrientations
9     allowedOrientations: Orientation.All
10
11     // To enable PullDownMenu, place our content in a SilicaFlickable
12     SilicaFlickable {
13         anchors.fill: parent
14
15         VerticalScrollDecorator {}
16
17         // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
18         PullDownMenu {
19             MenuItem {
20                 text: qsTr("About")
21                 onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
22             }
23
24             MenuItem {
25                 text: qsTr("The Pedalo Rules")
26                 onClicked: pageStack.push(Qt.resolvedUrl("TheRules.qml"))
27             }
28         }
29
30         // Tell SilicaFlickable the height of its content.
31         contentHeight: column.implicitHeight
32
33         Column {
34             id: column
35
36             width: isPortrait ? parent.width : parent.width / 2.0
37             height: isPortrait ? page.height / 2.0 : page.height
38             spacing: 0
39
40             BarButton {
41                 source: (currentStatus.cycling ? "image://pedalo/button-journey-finish?" : "image://pedalo/button-journey-start?") + (pressed ? Theme.primaryColor : Theme.highlightColor)
42                 text: currentStatus.cycling ? qsTr("Finish your journey") : qsTr("Start a journey")
43                 onClicked: {
44                     if (currentStatus.cycling) {
45                         var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
46
47                         dialog.accepted.connect(function() {
48                             currentStatus.cycling = false
49                         })
50                     }
51                     else {
52                         currentStatus.startJourney()
53                     }
54                 }
55             }
56
57             BarButton {
58                 source: "image://pedalo/button-journey-add?" + (pressed ? Theme.primaryColor : Theme.highlightColor)
59                 text: qsTr("Add a journey")
60                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"))
61             }
62         }
63
64         Column {
65             id: column2
66
67             width: isPortrait ? parent.width : parent.width / 2.0
68             height: isPortrait ? page.height / 2.0 : page.height
69             spacing: 0
70             y: isPortrait ? page.height / 2: 0
71             x: isPortrait ? 0 : page.width / 2.0
72
73             BarButton {
74                 source: "image://pedalo/button-stats?" + (pressed ? Theme.primaryColor : Theme.highlightColor)
75                 text: qsTr("View latest stats")
76                 onClicked: pageStack.push(Qt.resolvedUrl("Stats.qml"))
77             }
78
79             BarButton {
80                 source: "image://pedalo/button-list?" + (pressed ? Theme.primaryColor : Theme.highlightColor)
81                 text: qsTr("Previous journeys")
82                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyList.qml"))
83             }
84         }
85     }
86 }