Fill main screen with buttons
[harbour-pedalo.git] / qml / pages / MainPage.qml
index 31b1447..4e7293c 100644 (file)
@@ -1,9 +1,9 @@
 import QtQuick 2.0
 import Sailfish.Silica 1.0
+import "../components"
 
 Page {
     id: page
-    property bool cycling: false
 
     // The effective value will be restricted by ApplicationWindow.allowedOrientations
     allowedOrientations: Orientation.All
@@ -12,79 +12,70 @@ Page {
     SilicaFlickable {
         anchors.fill: parent
 
+        VerticalScrollDecorator {}
+
         // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
         PullDownMenu {
             MenuItem {
-                text: qsTr("Show Page 2")
-                onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
+                text: qsTr("About")
+                onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
             }
         }
 
         // Tell SilicaFlickable the height of its content.
-        contentHeight: column.height
+        contentHeight: column.implicitHeight
 
-        // Place our content in a Column.  The PageHeader is always placed at the top
-        // of the page, followed by our content.
         Column {
             id: column
 
-            width: page.width
-            spacing: Theme.paddingLarge
-            PageHeader {
-                title: qsTr("Pedalo")
-            }
-
-            SectionHeader {
-                text: qsTr("Cycle!")
-            }
+            width: isPortrait ? parent.width : parent.width / 2.0
+            height: isPortrait ? page.height / 2.0 : page.height
+            spacing: 0
 
-            Button {
-                anchors.horizontalCenter: parent.horizontalCenter
-                text: cycling ? qsTr("Finish") : qsTr("Start a journey")
+            BarButton {
+                source: "image://theme/icon-launcher-component-gallery"
+                text: currentStatus.cycling ? qsTr("Finish your journey") : qsTr("Start a journey")
                 onClicked: {
-                    if (cycling) {
-                        var dialog = pageStack.push(Qt.resolvedUrl("AddJourney.qml"))
+                    if (currentStatus.cycling) {
+                        var dialog = pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"), {title: "Finish journey", start: journeymodel.epochToDateTime(currentStatus.startTime), duration: currentStatus.getDuration()})
 
                         dialog.accepted.connect(function() {
-                            cycling = false
+                            currentStatus.cycling = false
                         })
                     }
                     else {
-                        cycling = true
+                        currentStatus.startJourney()
                     }
                 }
             }
 
-            SectionHeader {
-                text: qsTr("Add a journey")
+            BarButton {
+                source: "image://theme/icon-launcher-component-gallery"
+                text: "Add a journey"
+                onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml"))
             }
+        }
 
-            Button {
-                anchors.horizontalCenter: parent.horizontalCenter
-                text: qsTr("Enter journey")
-                onClicked: pageStack.push(Qt.resolvedUrl("AddJourney.qml"))
-            }
+        Column {
+            id: column2
 
-            SectionHeader {
-                text: qsTr("Latest stats")
-            }
+            width: isPortrait ? parent.width : parent.width / 2.0
+            height: isPortrait ? page.height / 2.0 : page.height
+            spacing: 0
+            y: isPortrait ? page.height / 2: 0
+            x: isPortrait ? 0 : page.width / 2.0
 
-            Button {
-                anchors.horizontalCenter: parent.horizontalCenter
-                text: qsTr("View stats")
+            BarButton {
+                source: "image://theme/icon-launcher-component-gallery"
+                text: "View latest stats"
                 onClicked: pageStack.push(Qt.resolvedUrl("Stats.qml"))
             }
 
-            SectionHeader {
-                text: qsTr("Previous journeys")
-            }
-
-            Button {
-                anchors.horizontalCenter: parent.horizontalCenter
-                text: qsTr("View journeys")
+            BarButton {
+                source: "image://theme/icon-launcher-component-gallery"
+                text: "Previous journeys"
                 onClicked: pageStack.push(Qt.resolvedUrl("JourneyList.qml"))
             }
-
         }
     }
 }