From 5353420ace1b22d7ea6ba80d286464d8342ffca9 Mon Sep 17 00:00:00 2001 From: Alexander Browne Date: Fri, 30 May 2025 07:34:52 -0500 Subject: [PATCH] Changed to follow system them with setting for dark theme --- apps/andark/ChangeLog | 3 ++- apps/andark/README.md | 1 + apps/andark/app.js | 27 +++++++++++++++++---------- apps/andark/settings.js | 7 ++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/andark/ChangeLog b/apps/andark/ChangeLog index 731a84506..5541288e8 100644 --- a/apps/andark/ChangeLog +++ b/apps/andark/ChangeLog @@ -7,4 +7,5 @@ 0.06: Fix issue showing widgets when app is fast-loaded into from launcher with widgets disabled 0.07: Enable fast loading and queue updates to the second 0.08: Restore redraw on charging event + fixup for safer fast-loading -0.09: Add setting to show the weekday and not the year + add setting to hide the battery +0.09: Add setting to show the weekday and not the year + add setting to hide the battery + + changed to follow system them with setting for dark theme diff --git a/apps/andark/README.md b/apps/andark/README.md index 71575544c..c02964ea0 100644 --- a/apps/andark/README.md +++ b/apps/andark/README.md @@ -16,3 +16,4 @@ * hour hand can be made slighly shorter to improve readability when minute hand is behind a number * show the weekday and not the year * hide the battery percentage +* dark theme (enabled by default); disable to follow system theme diff --git a/apps/andark/app.js b/apps/andark/app.js index 464ddd689..be8e969f4 100644 --- a/apps/andark/app.js +++ b/apps/andark/app.js @@ -4,10 +4,16 @@ const defaultSettings = { textAboveHands : false, shortHrHand : false, weekdayNoYear : false, - noBattery : false + noBattery : false, + darkTheme : true }; const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); +if (settings.darkTheme) { + g.setTheme({bg: "#000"}); + g.setTheme({fg: "#FFF"}); +} + const c={"x":g.getWidth()/2,"y":g.getHeight()/2}; const zahlpos=(function() { @@ -38,7 +44,7 @@ const zeiger = function(len,dia,tim) { const drawHands = function(d) { let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds(); - g.setColor(1,1,1); + g.setColor(g.theme.fg); if(h>12){ h=h-12; @@ -64,8 +70,9 @@ const drawHands = function(d) { }; const drawText = function(d) { - g.setBgColor(0,0,0); - g.setColor(1,1,1); +//g.setFont("Vector",10); + g.setBgColor(g.theme.bg); + g.setColor(g.theme.fg); const dateStr = settings.weekdayNoYear ? require("locale").dow(d, 1)+" "+d.getDate()+" "+require("locale").month(d, 1) : require("locale").date(d); @@ -86,8 +93,8 @@ const drawText = function(d) { const drawNumbers = function() { //draws the numbers on the screen g.setFont("Vector",20); - g.setColor(1,1,1); - g.setBgColor(0,0,0); + g.setColor(g.theme.fg); + g.setBgColor(g.theme.bg); for(let i = 0;i<12;i++){ g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true); } @@ -123,7 +130,7 @@ const queueDraw = function() { const draw = function() { // draw black rectangle in the middle to clear screen from scale and hands - g.setColor(0,0,0); + g.setColor(g.theme.bg); g.fillRect(10,10,2*c.x-10,2*c.x-10); // prepare for drawing the text g.setFontAlign(0,0); @@ -141,7 +148,7 @@ const draw = function() { //draws the scale once the app is startet const drawScale = function() { // clear the screen - g.setBgColor(0,0,0); + g.setBgColor(g.theme.bg); g.clear(); // draw the ticks of the scale for(let i=-14;i<47;i++){ @@ -149,9 +156,9 @@ const drawScale = function() { let d=2; if(i%5==0){d=5;} g.fillPoly(zeiger(300,d,win),true); - g.setColor(0,0,0); + g.setColor(g.theme.bg); g.fillRect(10,10,2*c.x-10,2*c.x-10); - g.setColor(1,1,1); + g.setColor(g.theme.fg); } }; diff --git a/apps/andark/settings.js b/apps/andark/settings.js index 886d1d755..d1cba0e30 100644 --- a/apps/andark/settings.js +++ b/apps/andark/settings.js @@ -4,7 +4,8 @@ textAboveHands : false, shortHrHand : false, weekdayNoYear : false, - noBattery : false + noBattery : false, + darkTheme : true } let settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); @@ -32,6 +33,10 @@ value : !!settings.noBattery, onchange : v => { settings.noBattery=v; save();} }, + /*LANG*/'Dark theme': { + value : !!settings.darkTheme, + onchange : v => { settings.darkTheme=v; save();} + }, }; E.showMenu(appMenu);