From 49dfd6cd99b889e41ed1dfd89ab9446e2109a9d6 Mon Sep 17 00:00:00 2001 From: JD Hartley Date: Wed, 15 Jun 2022 19:35:20 -0700 Subject: [PATCH] Add AZMs (Active Zone Minutes) dataline (#42) --- app/datalines/azms.js | 26 ++++++++++++++++++++++++++ app/index.js | 3 ++- common/settings.js | 1 + resources/styles.css | 35 ++++++++++++++++------------------- 4 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 app/datalines/azms.js diff --git a/app/datalines/azms.js b/app/datalines/azms.js new file mode 100644 index 0000000..394d0a6 --- /dev/null +++ b/app/datalines/azms.js @@ -0,0 +1,26 @@ +import { me } from 'appbit'; +import clock from 'clock'; +import { today } from 'user-activity'; + +import Dataline from './Dataline'; +import { swapClass } from '../utils'; + +export default new Dataline({ + name: 'AZMS', + checkPermissions() { + return me.permissions.granted('access_activity'); + }, + updateValue() { + const raw = today.adjusted.activeZoneMinutes.total || 0; + const unit = `minute${raw === 1 ? '' : 's'}`; + + this.valueRef.text = `${raw} ${unit}`; + swapClass(this.valueRef.root, 'color', 'magenta'); + }, + start() { + clock.addEventListener('tick', this.updateValue); + }, + stop() { + clock.removeEventListener('tick', this.updateValue); + }, +}); diff --git a/app/index.js b/app/index.js index a864cab..92d663c 100644 --- a/app/index.js +++ b/app/index.js @@ -18,6 +18,7 @@ import DIST from './datalines/distance'; import LVLS from './datalines/levels'; import HRRT from './datalines/heartrate'; import CALS from './datalines/calories'; +import AZMS from './datalines/azms'; import { swapClass } from './utils'; // Set our clock granularity to seconds to update lines. @@ -38,7 +39,7 @@ const host = String(device.modelName) -const allDatalines = { TIME, DATE, BATT, STEP, DIST, LVLS, HRRT, CALS }; +const allDatalines = { TIME, DATE, BATT, STEP, DIST, LVLS, HRRT, CALS, AZMS }; let updatePromptLine; diff --git a/common/settings.js b/common/settings.js index d5f99f2..4ccde8f 100644 --- a/common/settings.js +++ b/common/settings.js @@ -7,6 +7,7 @@ const DATA_LINE_MAP = { DIST: 'Distance', HRRT: 'Heart rate', CALS: 'Calories burned', + AZMS: 'Active Zone Minutes', }; const getDatalineObjectByValue = (value) => { diff --git a/resources/styles.css b/resources/styles.css index f3a9fa5..d18ace4 100644 --- a/resources/styles.css +++ b/resources/styles.css @@ -15,11 +15,14 @@ svg.theme__DEFAULT { fill: #ffaa00; } .theme__DEFAULT.color__purple { - fill: #aa00aa; + fill: #c420c4; } .theme__DEFAULT.color__red { fill: #ff3333; } +.theme__DEFAULT.color__magenta { + fill: #ff66aa; +} svg.theme__DRACULA { @@ -44,92 +47,86 @@ svg.theme__DRACULA { .theme__DRACULA.color__red { fill: #ff5555; } +.theme__DRACULA.color__magenta { + fill: #FF79C6; +} svg.theme__HOPSCOTCH { viewport-fill: #322931; fill: #d5d3d5; } - #Labels.theme__HOPSCOTCH { fill: #797379; } - .theme__HOPSCOTCH.color__cyan { fill: #1290bf; } - .theme__HOPSCOTCH.color__green { fill: #8fc13e; } - .theme__HOPSCOTCH.color__orange { fill: #fd8b19; } - .theme__HOPSCOTCH.color__purple { fill: #c85e7c; } - .theme__HOPSCOTCH.color__red { fill: #dd464c; } +.theme__HOPSCOTCH.color__magenta { + fill: #149b93; /* Okay, not magenta but at least unique */ +} svg.theme__SOLARIZED_DARK { viewport-fill: #002b36; fill: #657b83; } - #Labels.theme__SOLARIZED_DARK { fill: #839496; } - .theme__SOLARIZED_DARK.color__cyan { fill: #2aa198; } - .theme__SOLARIZED_DARK.color__green { fill: #859900; } - .theme__SOLARIZED_DARK.color__orange { fill: #cb4b16; } - .theme__SOLARIZED_DARK.color__purple { fill: #6c71c4; } - .theme__SOLARIZED_DARK.color__red { fill: #dc322f; } +.theme__SOLARIZED_DARK.color__magenta { + fill: #d33682; +} svg.theme__SOLARIZED_LIGHT { viewport-fill: #eee8d5; fill: #657b83; } - #Labels.theme__SOLARIZED_LIGHT { fill: #586e75; } - .theme__SOLARIZED_LIGHT.color__cyan { fill: #2aa198; } - .theme__SOLARIZED_LIGHT.color__green { fill: #859900; } - .theme__SOLARIZED_LIGHT.color__orange { fill: #cb4b16; } - .theme__SOLARIZED_LIGHT.color__purple { fill: #6c71c4; } - .theme__SOLARIZED_LIGHT.color__red { fill: #dc322f; } +.theme__SOLARIZED_LIGHT.color__magenta { + fill: #d33682; +}