Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fullscreen mode and widgets to line_clock app #3381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/line_clock/ChangeLog
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.1: init app
0.2: add ability to display widgets
20 changes: 19 additions & 1 deletion apps/line_clock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ const numberOffset = 85;
const numberSize = 22;

const storage = require('Storage');
const widget_utils = require("widget_utils");

const SETTINGS_FILE = "line_clock.setting.json";

let initialSettings = {
screen: "Full",
showLock: true,
showMinute: true,
};
Expand All @@ -23,6 +25,11 @@ for (const key in saved_settings) {
initialSettings[key] = saved_settings[key];
}

let isFullscreen = function() {
const s = initialSettings.screen.toLowerCase();
return s === "full";
};

let gWidth = g.getWidth(), gCenterX = gWidth/2;
let gHeight = g.getHeight(), gCenterY = gHeight/2;

Expand Down Expand Up @@ -235,6 +242,14 @@ function lockListenerBw() {
}
Bangle.on('lock', lockListenerBw);

function drawWidgets() {
if(isFullscreen()){
widget_utils.hide();
} else {
Bangle.drawWidgets();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here can we use widget_utils.show() to undo any other changes it might've made?

}
}

Bangle.setUI({
mode : "clock",
// TODO implement https://www.espruino.com/Bangle.js+Fast+Load
Expand Down Expand Up @@ -267,7 +282,7 @@ function draw() {
g.setColor(g.theme.bg);
g.fillRect(0, 0, gWidth, gHeight);

if(initialSettings.showLock && Bangle.isLocked()){
if(initialSettings.showLock && Bangle.isLocked() && isFullscreen()){
g.setColor(g.theme.fg);
g.drawImage(imgLock(), gWidth-16, 2);
}
Expand All @@ -282,6 +297,9 @@ function draw() {
if(initialSettings.showMinute){
drawNumber(currentMinute);
}
drawWidgets()
}

Bangle.loadWidgets();

draw();
2 changes: 1 addition & 1 deletion apps/line_clock/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ "id": "line_clock",
"name": "Line Clock",
"shortName":"Line Clock",
"version":"0.1",
"version":"0.2",
"description": "a readable analog clock",
"icon": "app-icon.png",
"type": "clock",
Expand Down
12 changes: 12 additions & 0 deletions apps/line_clock/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// initialize with default settings...
const storage = require('Storage')
let settings = {
screen: "Full",
showLock: true,
showMinute: true,
};
Expand All @@ -16,9 +17,20 @@
storage.write(SETTINGS_FILE, settings)
}

const screenOptions = ["Normal", "Full"];

E.showMenu({
'': { 'title': 'Line Clock' },
'< Back': back,
'Screen': {
value: 0 | screenOptions.indexOf(settings.screen),
min: 0, max: 2,
format: v => screenOptions[v],
onchange: v => {
settings.screen = screenOptions[v];
save();
},
},
'Show Lock': {
value: settings.showLock,
onchange: () => {
Expand Down