BangleApps/apps/keytimer/app.js

28 lines
738 B
JavaScript
Raw Permalink Normal View History

2023-05-12 22:40:51 +00:00
const storage = require('Storage');
2022-11-06 04:05:47 +00:00
const common = require("keytimer-com.js");
2022-11-06 04:05:47 +00:00
const keypad = require("keytimer-keys.js");
const timerView = require("keytimer-tview.js");
2023-05-12 22:40:51 +00:00
Bangle.KEYTIMER = true;
Bangle.loadWidgets();
Bangle.drawWidgets();
E.on('kill', () => {
2023-05-12 22:40:51 +00:00
storage.writeJSON('keytimer.json', common.state);
});
2023-05-12 22:40:51 +00:00
// Handle touch here. I would implement these separately in each view, but I can't figure out how to clear the event listeners.
Bangle.on('touch', (button, xy) => {
2023-05-12 22:40:51 +00:00
if (common.timerExists()) timerView.touch(button, xy);
else keypad.touch(button, xy);
});
Bangle.on('swipe', dir => {
2023-05-12 22:40:51 +00:00
if (!common.timerExists()) keypad.swipe(dir);
});
2023-05-12 22:40:51 +00:00
if (common.timerExists()) timerView.show(common);
else keypad.show(common);