aboutsummaryrefslogtreecommitdiff
path: root/src/stepCounter
diff options
context:
space:
mode:
authordodoradio <dodoradio@outlook.com>2023-07-20 23:48:37 +0100
committerdodoradio <dodoradio@outlook.com>2023-07-21 00:09:58 +0100
commit69ee975bf761578f59ba41b21575f7c0764b3681 (patch)
treee8b3284dfcca5951888030599f028a9db64e9b24 /src/stepCounter
parentc2632dc90160ad4457fbe65eb1dae5157254cbc7 (diff)
Add steps detail page
Currently this is a direct clone of the heartrate detail page, and isn't specialised for steps in any way
Diffstat (limited to '')
-rw-r--r--src/stepCounter/StepCounterPreview.qml92
-rw-r--r--src/stepCounter/StepsDetailPage.qml93
2 files changed, 144 insertions, 41 deletions
diff --git a/src/stepCounter/StepCounterPreview.qml b/src/stepCounter/StepCounterPreview.qml
index f6a0228..3c2d3f0 100644
--- a/src/stepCounter/StepCounterPreview.qml
+++ b/src/stepCounter/StepCounterPreview.qml
@@ -23,57 +23,67 @@ import org.asteroid.sensorlogd 1.0
import "../graphs"
-Column {
+MouseArea {
+ implicitHeight: contentColumn.implicitHeight
property var weekday: ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
+ Column {
+ id: contentColumn
+ width: parent.width
- Label {
- width: parent.width*0.8
- anchors.horizontalCenter: parent.horizontalCenter
- text: stepsDataLoader.getTodayTotal() ? "You've walked " + stepsDataLoader.todayTotal + " steps today, keep it up!" : "You haven't yet logged any steps today"
- wrapMode: Text.WordWrap
- horizontalAlignment: Text.AlignHCenter
- }
+ Label {
+ width: parent.width*0.8
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: stepsDataLoader.getTodayTotal() ? "You've walked " + stepsDataLoader.todayTotal + " steps today, keep it up!" : "You haven't yet logged any steps today"
+ wrapMode: Text.WordWrap
+ horizontalAlignment: Text.AlignHCenter
+ }
- Item { width: parent.width; height: parent.width*0.1}
- Label {
- anchors {
- left: parent.left
- margins: app.width*0.1
+ Item { width: parent.width; height: parent.width*0.1}
+ Label {
+ anchors {
+ left: parent.left
+ margins: app.width*0.1
+ }
+ text: "Steps"
}
- text: "Steps"
- }
- Item { width: parent.width; height: parent.width*0.05}
+ Item { width: parent.width; height: parent.width*0.05}
- BarGraph {
- id: stepsGraph
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width*0.85
- height: app.width*3/5
- StepsDataLoader {
- id: stepsDataLoader
- Component.onCompleted: {
- triggerDaemonRecording()
- stepsGraph.loadData()
+ BarGraph {
+ id: stepsGraph
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width*0.85
+ height: app.width*3/5
+ StepsDataLoader {
+ id: stepsDataLoader
+ Component.onCompleted: {
+ triggerDaemonRecording()
+ stepsGraph.loadData()
+ }
}
- }
- function loadData() {
- var currDate = new Date()
- currDate.setDate(currDate.getDate() - 7)
- for (var i = 0; i < 7; i++) {
- currDate.setDate(currDate.getDate() + 1)
- console.log(currDate)
- var currvalue = stepsDataLoader.getTotalForDate(currDate)
- if (currvalue > 0 || valuesArr.length > 0) {
- if (currvalue > maxValue) {
- maxValue = currvalue
+ function loadData() {
+ var currDate = new Date()
+ currDate.setDate(currDate.getDate() - 7)
+ for (var i = 0; i < 7; i++) {
+ currDate.setDate(currDate.getDate() + 1)
+ console.log(currDate)
+ var currvalue = stepsDataLoader.getTotalForDate(currDate)
+ if (currvalue > 0 || valuesArr.length > 0) {
+ if (currvalue > maxValue) {
+ maxValue = currvalue
+ }
+ valuesArr.push(currvalue)
+ labelsArr.push(weekday[currDate.getDay()])
}
- valuesArr.push(currvalue)
- labelsArr.push(weekday[currDate.getDay()])
}
+ dataLoadingDone()
}
- dataLoadingDone()
+ indicatorLineHeight: loggerSettings.stepGoalEnabled ? loggerSettings.stepGoalTarget : 0
}
- indicatorLineHeight: loggerSettings.stepGoalEnabled ? loggerSettings.stepGoalTarget : 0
+ }
+ onClicked: pageStack.push(detailPage)
+ Component {
+ id: detailPage
+ StepsDetailPage {}
}
}
diff --git a/src/stepCounter/StepsDetailPage.qml b/src/stepCounter/StepsDetailPage.qml
new file mode 100644
index 0000000..9d141dd
--- /dev/null
+++ b/src/stepCounter/StepsDetailPage.qml
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2023 Arseniy Movshev <dodoradio@outlook.com>
+ * 2019 Florent Revest <revestflo@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.15
+import org.asteroid.controls 1.0
+
+import org.asteroid.sensorlogd 1.0
+
+import "../graphs"
+
+Item {
+ Flickable {
+ anchors.fill: parent
+ contentHeight: contentColumn.implicitHeight
+ Column {
+ id: contentColumn
+ width: parent.width
+
+ Item { width: parent.width; height: parent.width*0.2}
+
+ StepsLineGraph {
+ id: graph
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width*0.9
+ height: app.height*2/3
+ startTime: new Date()
+ endTime: new Date()
+ }
+ Row {
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width*0.9
+ height: width/6
+ MouseArea {
+ height: parent.height
+ width: parent.width/3
+ Label {
+ anchors.centerIn: parent
+ text: "3 weeks"
+ }
+ onClicked: {
+ var d = graph.endTime
+ d.setDate(d.getDate() - 20)
+ graph.startTime = d
+ }
+ }
+ MouseArea {
+ height: parent.height
+ width: parent.width/3
+ Label {
+ anchors.centerIn: parent
+ text: "week"
+ }
+ onClicked: {
+ var d = graph.endTime
+ d.setDate(d.getDate() - 6)
+ graph.startTime = d
+ }
+ }
+ MouseArea {
+ height: parent.height
+ width: parent.width/3
+ Label {
+ anchors.centerIn: parent
+ text: "day"
+ }
+ onClicked: {
+ graph.startTime = graph.endTime
+ }
+ }
+ }
+
+ Item { width: parent.width; height: parent.width*0.2}
+ }
+ }
+ PageHeader {
+ text: "Steps"
+ }
+}