mirror of https://github.com/espruino/BangleApps
Merge pull request #1443 from rigrig/widcal
widcal: New widget with the current datepull/1433/head^2
commit
cb0e5b3c1d
|
@ -0,0 +1 @@
|
|||
0.01: First version
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"id": "widcal",
|
||||
"name": "Calendar Widget",
|
||||
"version": "0.01",
|
||||
"description": "Widget with the current date",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
"tags": "widget,calendar",
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"widcal.wid.js","url":"widget.js"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
(function() {
|
||||
WIDGETS["cal"] = {
|
||||
area: "tl", width: 22, draw: function() {
|
||||
const x = this.x, y = this.y,
|
||||
x2 = x+21, y2 = y+23,
|
||||
date = new Date(),
|
||||
month = require("locale").month(date, true),
|
||||
day = date.getDate();
|
||||
|
||||
g.reset().setFontAlign(0, 0) // center all text
|
||||
// header
|
||||
.setBgColor("#f00").setColor("#fff")
|
||||
.clearRect(x, y, x2, y+8).setFont("4x6").drawString(month, (x+x2)/2+1, y+5)
|
||||
// date
|
||||
.setBgColor("#fff").setColor("#000")
|
||||
.clearRect(x, y+9, x2, y2).setFont("Vector:16").drawString(day, (x+x2)/2+2, y+17);
|
||||
if (!g.theme.dark) {
|
||||
// black border around date for light themes
|
||||
g.setColor("#000").drawPoly([
|
||||
x, y+9,
|
||||
x, y2,
|
||||
x2, y2,
|
||||
x2, y+9
|
||||
]);
|
||||
}
|
||||
// redraw when date changes
|
||||
setTimeout(()=>WIDGETS["cal"].draw(), (86401 - Math.floor(date/1000) % 86400)*1000);
|
||||
}
|
||||
};
|
||||
})();
|
Binary file not shown.
After Width: | Height: | Size: 783 B |
Loading…
Reference in New Issue