From 69ee975bf761578f59ba41b21575f7c0764b3681 Mon Sep 17 00:00:00 2001 From: dodoradio Date: Thu, 20 Jul 2023 23:48:37 +0100 Subject: Add steps detail page Currently this is a direct clone of the heartrate detail page, and isn't specialised for steps in any way --- src/stepCounter/StepCounterPreview.qml | 92 +++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 41 deletions(-) (limited to 'src/stepCounter/StepCounterPreview.qml') 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 {} } } -- cgit v1.2.3-54-g00ecf