summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/heartrate-game/Stats.qml
blob: 87487c94426fb1cfeb79bb251b42307e0b53f434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import HeartRateGame

GamePage {
    id: statsPage

    required property DeviceHandler deviceHandler

    Column {
        anchors.centerIn: parent
        width: parent.width

        Rectangle {
            id: resultRect
            anchors.horizontalCenter: parent.horizontalCenter
            width: height
            height: statsPage.height / 2 - GameSettings.fieldHeight
            radius: height / 2
            color: GameSettings.viewColor

            Column {
                anchors.centerIn: parent

                Text {
                    id: resultCaption
                    anchors.horizontalCenter: parent.horizontalCenter
                    width: resultRect.width * 0.8
                    height: resultRect.height * 0.15
                    horizontalAlignment: Text.AlignHCenter
                    fontSizeMode: Text.Fit
                    font.pixelSize: GameSettings.bigFontSize
                    color: GameSettings.textColor
                    text: qsTr("RESULT")
                }

                Text {
                    id: resultValue
                    anchors.horizontalCenter: parent.horizontalCenter
                    width: resultRect.width * 0.8
                    height: resultRect.height * 0.4
                    horizontalAlignment: Text.AlignHCenter
                    fontSizeMode: Text.Fit
                    font.pixelSize: GameSettings.hugeFontSize
                    font.bold: true
                    color: GameSettings.heartRateColor
                    text: (statsPage.deviceHandler.maxHR - statsPage.deviceHandler.minHR).toFixed(0)
                }
            }
        }


        Item {
            height: GameSettings.fieldHeight
            width: 1
        }

        StatsLabel {
            title: qsTr("MIN")
            value: statsPage.deviceHandler.minHR.toFixed(0)
        }

        StatsLabel {
            title: qsTr("MAX")
            value: statsPage.deviceHandler.maxHR.toFixed(0)
        }

        StatsLabel {
            title: qsTr("AVG")
            value: statsPage.deviceHandler.average.toFixed(1)
        }

        StatsLabel {
            title: qsTr("CALORIES")
            value: statsPage.deviceHandler.calories.toFixed(3)
        }
    }
}