Merge pull request #1224 from hughbarney/master
Flipper - utility to switch between light and dark theme and vice versamaster
commit
d79a88f287
17
apps.json
17
apps.json
|
|
@ -5427,5 +5427,22 @@
|
|||
{"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.",
|
||||
"readme":"README.md",
|
||||
"screenshots": [{"url":"flipper.png"}],
|
||||
"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.icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
0.01: first release
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Flipper
|
||||
|
||||

|
||||
|
||||
*A utility to switch from the dark to the light theme and vice versa*
|
||||
|
||||
* If the current theme is dark it will switch to the light theme
|
||||
* If the current theme is light it will switch to the dark theme
|
||||
* Combine with the awesome pattern launcher and it saves loads of time
|
||||
|
||||
|
||||
## Demo Video
|
||||
|
||||
There's no screenshot but there is a [demo video.](https://espruino.microco.sm/api/v1/files/9caa1afef7e4cce1d9b518af2dd271f1a57c5ecc.mp4)
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
* Nothing left to add
|
||||
|
||||
Written by: [Hugh Barney](https://github.com/hughbarney) For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/)
|
||||
|
|
@ -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