mirror of https://github.com/espruino/BangleApps
Flipper: switch between light and dark theme and vice versa
parent
1906dd2839
commit
ebc7005e37
15
apps.json
15
apps.json
|
@ -5427,5 +5427,20 @@
|
|||
{"name":"puzzle15.img","url":"puzzle15.app-icon.js","evaluate":true}
|
||||
],
|
||||
"data": [{"name":"puzzle15.json"}]
|
||||
},
|
||||
{
|
||||
"id": "flipper",
|
||||
"name": "flipper",
|
||||
"version": "0.01",
|
||||
"description": "Switch between dark and light theme and vice versa, combine with pattern launcher and swipe to flip."
|
||||
"icon": "flipper.png",
|
||||
"type": "app",
|
||||
"tags": "game",
|
||||
"supports": ["BANGLEJS2"],
|
||||
"allow_emulator": true,
|
||||
"storage": [
|
||||
{"name":"flipper.app.js","url":"flipper.app.js"},
|
||||
{"name":"flipper.img","url":"flipper.app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
const storage = require('Storage');
|
||||
let settings = storage.readJSON('setting.json', 1);
|
||||
|
||||
function cl(x) { return g.setColor(x).getColor(); }
|
||||
|
||||
function upd(th) {
|
||||
g.theme = th;
|
||||
settings.theme = th;
|
||||
storage.write('setting.json', settings);
|
||||
delete g.reset;
|
||||
g._reset = g.reset;
|
||||
g.reset = function(n) { return g._reset().setColor(th.fg).setBgColor(th.bg); };
|
||||
g.clear = function(n) { if (n) g.reset(); return g.clearRect(0,0,g.getWidth(),g.getHeight()); };
|
||||
g.clear(1);
|
||||
};
|
||||
|
||||
function flipTheme() {
|
||||
if (!g.theme.dark) {
|
||||
upd({
|
||||
fg:cl("#fff"), bg:cl("#000"),
|
||||
fg2:cl("#0ff"), bg2:cl("#000"),
|
||||
fgH:cl("#fff"), bgH:cl("#00f"),
|
||||
dark:true
|
||||
});
|
||||
} else {
|
||||
upd({
|
||||
fg:cl("#000"), bg:cl("#fff"),
|
||||
fg2:cl("#000"), bg2:cl("#cff"),
|
||||
fgH:cl("#000"), bgH:cl("#0ff"),
|
||||
dark:false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
||||
flipTheme();
|
||||
setTimeout(load, 20);
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEw4X/AAO/mMUzs975K+ggLKysUAYNVqoLFitUoAKBqtQBYkJBIQABqwLEgQLEqtABggJDqkVBaoNCBZQwEgILWgoJENYsVBIcVBYpDEgpSIBYMBKQg6CuogCBY1UgoLCXAQLDqAsDBYhSBqEJHAoLDoEBcQ4LBEwILIMooLdIg4LaVoyaGERLcFao4LIdRAACYYUQBY5RKAH4Ar"));
|
Binary file not shown.
After Width: | Height: | Size: 644 B |
Loading…
Reference in New Issue