From ebc7005e372cbd03b6922fcec13d5f8010f0a802 Mon Sep 17 00:00:00 2001 From: hughbarney Date: Wed, 5 Jan 2022 21:27:21 +0000 Subject: [PATCH 1/5] Flipper: switch between light and dark theme and vice versa --- apps.json | 15 ++++++++++++++ apps/flipper/flipper.app.js | 39 +++++++++++++++++++++++++++++++++++ apps/flipper/flipper.icon.js | 1 + apps/flipper/flipper.png | Bin 0 -> 644 bytes 4 files changed, 55 insertions(+) create mode 100644 apps/flipper/flipper.app.js create mode 100644 apps/flipper/flipper.icon.js create mode 100644 apps/flipper/flipper.png diff --git a/apps.json b/apps.json index ebafa9c97..a32522fa2 100644 --- a/apps.json +++ b/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} + ] } ] diff --git a/apps/flipper/flipper.app.js b/apps/flipper/flipper.app.js new file mode 100644 index 000000000..2e7d3551c --- /dev/null +++ b/apps/flipper/flipper.app.js @@ -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); diff --git a/apps/flipper/flipper.icon.js b/apps/flipper/flipper.icon.js new file mode 100644 index 000000000..16331c09e --- /dev/null +++ b/apps/flipper/flipper.icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4X/AAO/mMUzs975K+ggLKysUAYNVqoLFitUoAKBqtQBYkJBIQABqwLEgQLEqtABggJDqkVBaoNCBZQwEgILWgoJENYsVBIcVBYpDEgpSIBYMBKQg6CuogCBY1UgoLCXAQLDqAsDBYhSBqEJHAoLDoEBcQ4LBEwILIMooLdIg4LaVoyaGERLcFao4LIdRAACYYUQBY5RKAH4Ar")); diff --git a/apps/flipper/flipper.png b/apps/flipper/flipper.png new file mode 100644 index 0000000000000000000000000000000000000000..b91543070be72c6a53a11aabec8d779780d2bc11 GIT binary patch literal 644 zcmV-~0(-0O`Ea$39hd$rSFgp06=YM0Il{S zNt_9?Wo4B{?^|t~pJ#}Zrg02ZoGP${lF_V|5I_%73ZmJuT0&*lfPjaY0kbl|Sb3wL z2iZV)c;Qk98Bz=!?CoNy@mQ250PlrNr2`;lAs6C1E3GII=pLkuXTT=w$hHTa{YLQ` z0?xEdlzJYJ3F=Idm0(>vK^Pg(9sT9im&`Mr3Ts-00mn0N`_RDC^9pvhHpzW_4_+18 zL9D7-+xz_(>FX7?nT)LIEeMMfc@TeKdJw5k&EV#IQrPAaCrd~q@cQg1x6LKi2J!@! zbsCWl%(i2A&pkZvWCw5cpu zQ52!tv*A*c5t$$kc$hi6inbEUj%}3*5RIkQdBFF-Ff#srA^Yik31Y^IS-VB@>t~>A ez&Bk3zIg*Y=-nc5eyO+s0000 Date: Wed, 5 Jan 2022 22:04:50 +0000 Subject: [PATCH 2/5] Flipper: switch between light and dark theme and vice versa --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index a32522fa2..07d9c02ae 100644 --- a/apps.json +++ b/apps.json @@ -5432,7 +5432,7 @@ "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." + "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", From c5f77a06926cabc0fe7c7be4d503bd9c0b0e79e1 Mon Sep 17 00:00:00 2001 From: hughbarney Date: Wed, 5 Jan 2022 22:31:21 +0000 Subject: [PATCH 3/5] Flipper: switch between light and dark theme and vice versa --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 07d9c02ae..e643d1c7d 100644 --- a/apps.json +++ b/apps.json @@ -5440,7 +5440,7 @@ "allow_emulator": true, "storage": [ {"name":"flipper.app.js","url":"flipper.app.js"}, - {"name":"flipper.img","url":"flipper.app-icon.js","evaluate":true} + {"name":"flipper.img","url":"flipper.icon.js","evaluate":true} ] } ] From 4f4cb8aba5eae7542b1f8b5ae7990758592ffc45 Mon Sep 17 00:00:00 2001 From: hughbarney Date: Wed, 5 Jan 2022 22:36:45 +0000 Subject: [PATCH 4/5] Flipper: switch between light and dark theme and vice versa --- apps/flipper/ChangeLog | 1 + 1 file changed, 1 insertion(+) create mode 100644 apps/flipper/ChangeLog diff --git a/apps/flipper/ChangeLog b/apps/flipper/ChangeLog new file mode 100644 index 000000000..9db0e26c5 --- /dev/null +++ b/apps/flipper/ChangeLog @@ -0,0 +1 @@ +0.01: first release From 84174a270b695e20f01fab6de5f37920f6422e24 Mon Sep 17 00:00:00 2001 From: hughbarney Date: Wed, 5 Jan 2022 23:45:22 +0000 Subject: [PATCH 5/5] Flipper: added README --- apps.json | 2 ++ apps/flipper/README.md | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 apps/flipper/README.md diff --git a/apps.json b/apps.json index e643d1c7d..e9c4a9f6a 100644 --- a/apps.json +++ b/apps.json @@ -5433,6 +5433,8 @@ "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", diff --git a/apps/flipper/README.md b/apps/flipper/README.md new file mode 100644 index 000000000..88025b8b2 --- /dev/null +++ b/apps/flipper/README.md @@ -0,0 +1,20 @@ +# Flipper + +![](flipper.png) + + *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/)