widclose: new widget: a Close Button

pull/1574/head
Richard de Boer 2022-03-15 19:36:18 +01:00
parent aa3bf728fa
commit d8080a9d6e
No known key found for this signature in database
GPG Key ID: 8721727971871937
8 changed files with 37 additions and 0 deletions

1
apps/widclose/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New widget!

7
apps/widclose/README.md Normal file
View File

@ -0,0 +1,7 @@
# Close Button
Adds a ![X](preview.png) button to close the current app and go back to the clock.
(Widget is not visible on the clock screen)
![Light theme screenshot](screenshot_light.png)
![Dark theme screenshot](screenshot_dark.png)

BIN
apps/widclose/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,15 @@
{
"id": "widclose",
"name": "Close Button",
"version": "0.01",
"description": "A button to close the current app",
"readme": "README.md",
"icon": "icon.png",
"type": "widget",
"tags": "widget,tools",
"supports": ["BANGLEJS2"],
"screenshots": [{"url":"screenshot_light.png"},{"url":"screenshot_dark.png"}],
"storage": [
{"name":"widclose.wid.js","url":"widget.js"}
]
}

BIN
apps/widclose/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

14
apps/widclose/widget.js Normal file
View File

@ -0,0 +1,14 @@
if (!Bangle.CLOCK) WIDGETS.close = {
area: "tr", width: 24, sortorder: 10, // we want the right-most spot please
draw: function() {
Bangle.removeListener("touch", this.touch);
Bangle.on("touch", this.touch);
g.reset().setColor("#f00").drawImage(atob( // hardcoded red to match setUI back button
// b/w version of preview.png, 24x24
"GBgBABgAAf+AB//gD//wH//4P//8P//8fn5+fjx+fxj+f4H+/8P//8P/f4H+fxj+fjx+fn5+P//8P//8H//4D//wB//gAf+AABgA"
), this.x, this.y);
}, touch: function(_, c) {
const w = WIDGETS.close;
if (w && c.x>=w.x && c.x<=w.x+24 && c.y>=w.y && c.y<=w.y+24) load();
}
};