Added ability to hide moon phase widget

master
David Volovskiy 2025-04-18 07:23:00 -04:00
parent 9be612592d
commit 942c2e190f
4 changed files with 22 additions and 5 deletions

View File

@ -7,3 +7,4 @@
0.07: Use default Bangle formatter for booleans
0.08: Better formula for the moon's phase
0.09: Fix variable declaration
0.10: Added ability to hide widget

View File

@ -1,7 +1,7 @@
{
"id": "widmp",
"name": "Moon Phase",
"version": "0.09",
"version": "0.10",
"description": "Display the current moon phase in blueish (in light mode) or white (in dark mode) for both hemispheres. In the southern hemisphere the 'My Location' app is needed.",
"icon": "widget.png",
"type": "widget",

View File

@ -2,6 +2,7 @@
var settings = Object.assign({
default_colour: true,
hide: false,
red: 0,
green: 0,
blue: 0,
@ -30,6 +31,13 @@
writeSettings();
}
},
"Hide Widget": {
value: settings.hide,
onchange: () => {
settings.hide = !settings.hide;
writeSettings();
}
},
"Custom...": () => E.showMenu(custommenu)
};

View File

@ -3,6 +3,7 @@
var lastCalculated = 0; // When we last calculated the phase
var phase = 0; // The last phase we calculated
var southernHemisphere = false; // when in southern hemisphere -- use the "My Location" App
var settings;
// https://github.com/deirdreobyrne/LunarPhase
function moonPhase(sec) {
@ -40,13 +41,17 @@
}
}
function setMoonColour(g) {
var settings = Object.assign({
function reloadSettings() {
settings = Object.assign({
default_colour: true,
hide: false,
red: 0,
green: 0,
blue: 0,
}, require('Storage').readJSON("widmp.json", true) || {});
}
function setMoonColour(g) {
if (settings.default_colour) {
if (g.theme.dark) {
g.setColor(0xffff); // white
@ -62,6 +67,7 @@
function draw() {
if (settings.hide) return;
const CenterX = this.x + 12, CenterY = this.y + 12, Radius = 11;
let leftFactor, rightFactor;
@ -90,9 +96,11 @@
drawMoonPhase(CenterX,CenterY, Radius, leftFactor,rightFactor);
}
reloadSettings();
var wid = settings.hide ? 0 : 24;
WIDGETS["widmp"] = {
area: "tr",
width: 24,
width: wid,
draw: draw
};