diff --git a/README.md b/README.md index ac6e7f7..34a6c51 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ ![languages](https://img.shields.io/badge/languages-JavaScript%20|%20CSS-blue) ![platform](https://img.shields.io/badge/platform-Fitbit%20Ionic-silver) -![version](https://img.shields.io/badge/version-%201.1.1-green) +![version](https://img.shields.io/badge/version-%201.2.0-green) [![FitbitBuild Actions Status](https://github.com/smirko-dev/fitbit-clockface/workflows/FitbitBuild/badge.svg)](https://github.com/smirko-dev/fitbit-clockface/actions) + ## Description This is a simple clock face for Fitbit Ionic. @@ -13,6 +14,7 @@ It comes with - languages: de-DE, en-EN - battery icon with status in percentage - next calendar event of the current day +- step count in case of no events Find the latest published version in the [Fitbit gallery](https://gallery.fitbit.com/details/ae441b73-2660-407f-b796-a98d1d0583a0). @@ -20,9 +22,12 @@ The clockface is based on https://github.com/Fitbit/sdk-calendar-clock/. Icons are from https://materialdesignicons.com/ ([Apache license version 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)). -## Screenshot -![Screenshot](screenshot.png) +## Screenshots + +![Appointment](screenshot.png) ![Activity](screenshot2.png) + + ## How to build diff --git a/app/index.js b/app/index.js index 213b8fa..c8c0b07 100644 --- a/app/index.js +++ b/app/index.js @@ -2,6 +2,7 @@ import document from "document"; import { battery } from "power"; import { preferences } from "user-settings"; import { display } from "display"; +import { today } from 'user-activity'; import { me } from "appbit"; import * as util from "../common/utils"; import * as appointment from "./appointment"; @@ -16,6 +17,9 @@ const appointmentsLabel = document.getElementById("appointmentsLabel"); const batteryImage = document.getElementById("batteryImage"); const batteryLabel = document.getElementById("batteryLabel"); +const footstepImage = document.getElementById("footstepImage"); +const activityLabel = document.getElementById("activityLabel"); + clock.initialize("minutes", data => { // Update elements with each tick hourLabel.text = data.hours; @@ -50,12 +54,25 @@ function renderAppointment() { if (event) { const date = fromEpochSec(event.startDate); appointmentsLabel.text = timeString(date) + " " + event.title; + hideActivity(); } else { appointmentsLabel.text = "" + renderActivity(); } } +function hideActivity() { + footstepImage.image = "" + activityLabel.text = "" +} + +function renderActivity() { + footstepImage.image = "shoe-print.png" + footstepImage.style.fill = "blue" + activityLabel.text = today.adjusted.steps +} + function renderBattery() { // Update the battery element every time when battery changed batteryLabel.text = Math.floor(battery.chargeLevel) + "%"; diff --git a/package.json b/package.json index 9f8df6a..3a42632 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "wipeColor": "", "requestedPermissions": [ "access_calendar", - "run_background" + "run_background", + "access_activity" ], "buildTargets": [ "higgs" diff --git a/resources/index.gui b/resources/index.gui index f291c02..ef5a4af 100644 --- a/resources/index.gui +++ b/resources/index.gui @@ -5,4 +5,6 @@