Skip to content

Commit

Permalink
Suggestions from review: emit events from Bangle and moving force_blu…
Browse files Browse the repository at this point in the history
…r calls
  • Loading branch information
Corwin Kerr committed Dec 1, 2024
1 parent a906075 commit 9ec6acc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions apps/widclkinfo/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ if (!require("clock_info").loadCount) { // don't load if a clock_info was alread
widget_utils.on("hidden", () => {
console.log("hidden");
clockInfoMenu.y = -24;
clockInfoMenu.force_blur(); // needs to be here so it doesn't stay the focused color
if (clockInfoMenu.focus) {
//clockInfoMenu.force_blur();
clockInfoMenu.force_blur();
console.log("Forced blur bc hidden");
}
});
Expand Down
15 changes: 11 additions & 4 deletions modules/widget_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports.hide = function() {
w.area = "";
if (w.x!=undefined) g.clearRect(w.x,w.y,w.x+w.width-1,w.y+23);
}
// TODO: do we need to emit event here too?
};

/// Show any hidden widgets
Expand Down Expand Up @@ -132,11 +133,11 @@ exports.swipeOn = function(autohide) {
if (dir>0 && exports.offset>=0) { // fully down
stop = true;
exports.offset = 0;
exports.emit("shown");
Bangle.emit("widgets-shown");
} else if (dir<0 && exports.offset<-23) { // fully up
stop = true;
exports.offset = -24;
exports.emit("hidden");
Bangle.emit("widgets-hidden");
}
if (stop) {
clearInterval(exports.animInterval);
Expand All @@ -158,8 +159,14 @@ exports.swipeOn = function(autohide) {
anim(-4);
}, exports.autohide);
};
if (ud>0 && exports.offset<0) anim(4, cb);
if (ud<0 && exports.offset>-24) anim(-4);
if (ud>0 && exports.offset<0) {
Bangle.emit("widgets-start-show");
anim(4, cb);
}
if (ud<0 && exports.offset>-24) {
Bangle.emit("widgets-start-hide");
anim(-4);
}
};
Bangle.on("swipe", exports.swipeHandler);
Bangle.drawWidgets();
Expand Down

0 comments on commit 9ec6acc

Please sign in to comment.