forked from FOSS/BangleApps
barclock: add settings to hide date/widgets
parent
ecd5868821
commit
f90d5dbdca
|
@ -9,3 +9,4 @@
|
||||||
0.09: Fix time/date disappearing after fullscreen notification
|
0.09: Fix time/date disappearing after fullscreen notification
|
||||||
0.10: Use ClockFace library
|
0.10: Use ClockFace library
|
||||||
0.11: Use ClockFace.is12Hour
|
0.11: Use ClockFace.is12Hour
|
||||||
|
0.12: Add settings to hide date,widgets
|
||||||
|
|
|
@ -4,3 +4,6 @@ A simple digital clock showing seconds as a horizontal bar.
|
||||||
| 24hr style | 12hr style |
|
| 24hr style | 12hr style |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|  |  |
|
|  |  |
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
* `Show date`: display date at the bottom of screen
|
|
@ -51,6 +51,7 @@ function dateText(date) {
|
||||||
const ClockFace = require("ClockFace"),
|
const ClockFace = require("ClockFace"),
|
||||||
clock = new ClockFace({
|
clock = new ClockFace({
|
||||||
precision:1,
|
precision:1,
|
||||||
|
settingsFile:'barclock.settings.json',
|
||||||
init: function() {
|
init: function() {
|
||||||
const Layout = require("Layout");
|
const Layout = require("Layout");
|
||||||
this.layout = new Layout({
|
this.layout = new Layout({
|
||||||
|
@ -62,8 +63,8 @@ const ClockFace = require("ClockFace"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{id: "bar", type: "custom", fraction: 0, fillx: 1, height: 6, col: g.theme.fg2, render: renderBar},
|
{id: "bar", type: "custom", fraction: 0, fillx: 1, height: 6, col: g.theme.fg2, render: renderBar},
|
||||||
{height: 40},
|
this.showDate ? {height: 40} : {},
|
||||||
{id: "date", type: "txt", font: "10%", valign: 1},
|
this.showDate ? {id: "date", type: "txt", font: "10%", valign: 1} : {},
|
||||||
],
|
],
|
||||||
}, {lazy: true});
|
}, {lazy: true});
|
||||||
// adjustments based on screen size and whether we display am/pm
|
// adjustments based on screen size and whether we display am/pm
|
||||||
|
@ -82,7 +83,7 @@ const ClockFace = require("ClockFace"),
|
||||||
update: function(date, c) {
|
update: function(date, c) {
|
||||||
if (c.m) this.layout.time.label = timeText(date);
|
if (c.m) this.layout.time.label = timeText(date);
|
||||||
if (c.h) this.layout.ampm.label = ampmText(date);
|
if (c.h) this.layout.ampm.label = ampmText(date);
|
||||||
if (c.d) this.layout.date.label = dateText(date);
|
if (c.d && this.showDate) this.layout.date.label = dateText(date);
|
||||||
const SECONDS_PER_MINUTE = 60;
|
const SECONDS_PER_MINUTE = 60;
|
||||||
if (c.s) this.layout.bar.fraction = date.getSeconds()/SECONDS_PER_MINUTE;
|
if (c.s) this.layout.bar.fraction = date.getSeconds()/SECONDS_PER_MINUTE;
|
||||||
this.layout.render();
|
this.layout.render();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "barclock",
|
"id": "barclock",
|
||||||
"name": "Bar Clock",
|
"name": "Bar Clock",
|
||||||
"version": "0.11",
|
"version": "0.12",
|
||||||
"description": "A simple digital clock showing seconds as a bar",
|
"description": "A simple digital clock showing seconds as a bar",
|
||||||
"icon": "clock-bar.png",
|
"icon": "clock-bar.png",
|
||||||
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}],
|
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}],
|
||||||
|
@ -12,6 +12,10 @@
|
||||||
"allow_emulator": true,
|
"allow_emulator": true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"barclock.app.js","url":"clock-bar.js"},
|
{"name":"barclock.app.js","url":"clock-bar.js"},
|
||||||
|
{"name":"barclock.settings.js","url":"settings.js"},
|
||||||
{"name":"barclock.img","url":"clock-bar-icon.js","evaluate":true}
|
{"name":"barclock.img","url":"clock-bar-icon.js","evaluate":true}
|
||||||
|
],
|
||||||
|
"data": [
|
||||||
|
{"name":"barclock.settings.json"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
(function(back) {
|
||||||
|
let s = require('Storage').readJSON("barclock.settings.json", true) || {};
|
||||||
|
|
||||||
|
function saver(key) {
|
||||||
|
return value => {
|
||||||
|
s[key] = value;
|
||||||
|
require('Storage').writeJSON("barclock.settings.json", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const menu = {
|
||||||
|
"": {"title": /*LANG*/"Bar Clock"},
|
||||||
|
/*LANG*/"< Back": back,
|
||||||
|
/*LANG*/"Show date": require("ClockFace_menu").showDate(s.showDate, saver('showDate')),
|
||||||
|
/*LANG*/"Load widgets": require("ClockFace_menu").loadWidgets(s.loadWidgets, saver('loadWidgets')),
|
||||||
|
}
|
||||||
|
|
||||||
|
E.showMenu(menu);
|
||||||
|
});
|
Loading…
Reference in New Issue