mirror of https://github.com/espruino/BangleApps
commit
1c2456dc9e
|
@ -27,4 +27,5 @@
|
|||
0.26: Use clkinfo.addInteractive instead of a custom implementation
|
||||
0.27: Clean out some leftovers in the remove function after switching to
|
||||
clkinfo.addInteractive that would cause ReferenceError.
|
||||
0.28: Option to show (1) time only and (2) week of year.
|
||||
0.28: Option to show (1) time only and (2) week of year.
|
||||
0.29: use setItem of clockInfoMenu to change the active item
|
|
@ -327,9 +327,7 @@ Bangle.on('lock', lockListenerBw);
|
|||
|
||||
let charging = function(charging){
|
||||
// Jump to battery
|
||||
clockInfoMenu.menuA = 0;
|
||||
clockInfoMenu.menuB = 2;
|
||||
clockInfoMenu.redraw();
|
||||
clockInfoMenu.setItem(0, 2);
|
||||
drawTime();
|
||||
}
|
||||
Bangle.on('charging', charging);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "bwclk",
|
||||
"name": "BW Clock",
|
||||
"version": "0.28",
|
||||
"version": "0.29",
|
||||
"description": "A very minimalistic clock.",
|
||||
"readme": "README.md",
|
||||
"icon": "app.png",
|
||||
|
|
|
@ -296,6 +296,23 @@ exports.addInteractive = function(menu, options) {
|
|||
options.redraw = function() {
|
||||
drawItem(menu[options.menuA].items[options.menuB]);
|
||||
};
|
||||
options.setItem = function (menuA, menuB) {
|
||||
if (!menu[menuA] || !menu[menuA].items[menuB] || (options.menuA == menuA && options.menuB == menuB)) {
|
||||
// menuA or menuB did not exist or did not change
|
||||
return false;
|
||||
}
|
||||
|
||||
const oldMenuItem = menu[options.menuA].items[options.menuB];
|
||||
if (oldMenuItem) {
|
||||
menuHideItem(oldMenuItem);
|
||||
oldMenuItem.removeAllListeners("draw");
|
||||
}
|
||||
options.menuA = menuA;
|
||||
options.menuB = menuB;
|
||||
menuShowItem(menu[options.menuA].items[options.menuB]);
|
||||
|
||||
return true;
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue