Skip to content

Commit 63aa627

Browse files
author
thyttan
committed
dsky_clock: hide widgets before building layout
so that the layout doesn't account for the widget bar when `dsky_clock` is fast loaded into. Also handle the hardware button through the layout library instead of `Bangle.setUI`. Also set `Bangle.CLOCK` directly.
1 parent ebb2f7d commit 63aa627

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

apps/dsky_clock/app.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const LightFont='Teletext5x9Ascii';
1414
const DataFont='7x11Numeric7Seg:2';
1515
var mode = 0;
1616

17+
if (global.WIDGETS) {require("widget_utils").swipeOn();} // If `dsky_clock` was fast loaded into we need to hide the widgets before setting the layout so elements are not moved down.
18+
1719
var layout = new Layout(
1820
{type:"h", c:[
1921
{type:"",width:6},
@@ -54,7 +56,10 @@ var layout = new Layout(
5456
]},
5557
{type:"",width:5},
5658
],
57-
lazy:true});
59+
lazy:true},
60+
{btns:[
61+
{label:"", cb: Bangle.showLauncher}
62+
], lazy:true});
5863
layout.update();
5964

6065
//support functioe_ns
@@ -346,12 +351,6 @@ function queueDraw() {
346351
}, 60000 - (Date.now() % 60000));
347352
}
348353

349-
// Show launcher when middle button pressed
350-
Bangle.setUI("clock");
351-
352-
Bangle.loadWidgets();
353-
require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe
354-
355354
Bangle.on('lock',on=>{
356355
mode = 0;
357356
drawMain(); // draw immediately
@@ -376,3 +375,7 @@ Bangle.on('swipe', function(directionLR) {
376375
g.clear();
377376
draw_bg();
378377
drawMain();
378+
379+
Bangle.CLOCK = 1;
380+
Bangle.loadWidgets();
381+
require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe

0 commit comments

Comments
 (0)