summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/graphs/StepsLineGraph.qml74
-rw-r--r--src/resources.qrc2
-rw-r--r--src/stepCounter/StepCounterPreview.qml92
-rw-r--r--src/stepCounter/StepsDetailPage.qml93
4 files changed, 220 insertions, 41 deletions
diff --git a/src/graphs/StepsLineGraph.qml b/src/graphs/StepsLineGraph.qml
new file mode 100644
index 0000000..c654901
--- /dev/null
+++ b/src/graphs/StepsLineGraph.qml
@@ -0,0 +1,74 @@
+/*
+ * 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.health 1.0
+import org.asteroid.sensorlogd 1.0
+
+Item {
+ id: graph
+ property date startTime: new Date()
+ property date endTime: new Date()
+
+ onStartTimeChanged: stepsGraph.loadGraphData(stepsDataLoader.getDataFromTo(startTime,endTime))
+ onEndTimeChanged: stepsGraph.loadGraphData(stepsDataLoader.getDataFromTo(startTime,endTime))
+
+ Component.onCompleted: {
+ stepsGraph.loadGraphData(stepsDataLoader.getDataFromTo(startTime,endTime))
+ }
+ StepsDataLoader { id: stepsDataLoader }
+ VerticalLabels { // labels column
+ id: markerParent
+ width: parent.width/8
+ startValue: 0
+ endValue: stepsGraph.maxValue
+ anchors {
+ left: parent.left
+ top: stepsGraph.top
+ bottom: stepsGraph.bottom
+ topMargin: stepsGraph.lineWidth/2
+ bottomMargin: anchors.topMargin
+ }
+ }
+ LineGraph {
+ id: stepsGraph
+ anchors {
+ left: markerParent.right
+ right: parent.right
+ top: parent.top
+ bottom: labelsRow.top
+ }
+ relativeMode: false
+ lineWidth: 4
+ }
+ TimeLabels {
+ id: labelsRow
+ height: Dims.w(5)
+ startTime: stepsGraph.minTime / 1000
+ endTime: stepsGraph.maxTime / 1000
+ anchors {
+ bottom: parent.bottom
+ left: stepsGraph.left
+ right: stepsGraph.right
+ rightMargin: stepsGraph.lineWidth/2
+ leftMargin: anchors.rightMargin
+ }
+ }
+}
diff --git a/src/resources.qrc b/src/resources.qrc
index 04c32f9..fb35c71 100644
--- a/src/resources.qrc
+++ b/src/resources.qrc
@@ -2,6 +2,7 @@
<qresource prefix="/">
<file>main.qml</file>
<file>stepCounter/StepCounterPreview.qml</file>
+ <file>stepCounter/StepsDetailPage.qml</file>
<file>heartrate/HeartratePreview.qml</file>
<file>heartrate/HeartrateDetailPage.qml</file>
<file>settings/RootSettingsPage.qml</file>
@@ -9,6 +10,7 @@
<file>settings/UiSettingsPage.qml</file>
<file>graphs/BarGraph.qml</file>
<file>graphs/HrGraph.qml</file>
+ <file>graphs/StepsLineGraph.qml</file>
<file>graphs/TimeLabels.qml</file>
<file>graphs/VerticalLabels.qml</file>
</qresource>
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"
+ }
+}