Save theme and restore

With dark theme otherwise theme stays dark for Fast Loading.

Also added to readme that the the font for the date is increased with setting to hide the battery.
master
Alexander Browne 2025-05-31 15:42:46 -05:00
parent eefd0c30cd
commit 8893d2431c
2 changed files with 3 additions and 1 deletions

View File

@ -21,5 +21,5 @@
* date and battery can be printed both below hands (as if hands were physical) and above (more readable) * date and battery can be printed both below hands (as if hands were physical) and above (more readable)
* hour hand can be made slighly shorter to improve readability when minute hand is behind a number * hour hand can be made slighly shorter to improve readability when minute hand is behind a number
* show the weekday and not the year * show the weekday and not the year
* hide the battery percentage * hide the battery percentage; the font for the date is increased since there is more space
* dark theme (enabled by default); disable to follow system theme * dark theme (enabled by default); disable to follow system theme

View File

@ -9,6 +9,7 @@ const defaultSettings = {
}; };
const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{});
const origTheme = g.theme;
if (settings.darkTheme) { if (settings.darkTheme) {
g.setTheme({bg: "#000"}); g.setTheme({bg: "#000"});
g.setTheme({fg: "#FFF"}); g.setTheme({fg: "#FFF"});
@ -168,6 +169,7 @@ const drawScale = function() {
Bangle.setUI({ Bangle.setUI({
mode: "clock", mode: "clock",
remove: function() { remove: function() {
if (settings.darkTheme) g.setTheme(origTheme);
Bangle.removeListener('lcdPower', updateState); Bangle.removeListener('lcdPower', updateState);
Bangle.removeListener('lock', updateState); Bangle.removeListener('lock', updateState);
Bangle.removeListener('charging', draw); Bangle.removeListener('charging', draw);