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-02 19:06:17 +00:00
|
|
|
|
2022-11-06 04:05:47 +00:00
|
|
|
const keypad = require("keytimer-keys.js");
|
|
|
|
const timerView = require("keytimer-tview.js");
|
2022-11-02 19:06:17 +00:00
|
|
|
|
2023-05-12 22:40:51 +00:00
|
|
|
Bangle.KEYTIMER = true;
|
|
|
|
|
2022-11-02 19:06:17 +00:00
|
|
|
Bangle.loadWidgets();
|
|
|
|
Bangle.drawWidgets();
|
|
|
|
|
|
|
|
E.on('kill', () => {
|
2023-05-12 22:40:51 +00:00
|
|
|
storage.writeJSON('keytimer.json', common.state);
|
2022-11-02 19:06:17 +00:00
|
|
|
});
|
|
|
|
|
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.
|
2022-11-02 19:06:17 +00:00
|
|
|
Bangle.on('touch', (button, xy) => {
|
2023-05-12 22:40:51 +00:00
|
|
|
if (common.timerExists()) timerView.touch(button, xy);
|
2022-11-02 19:06:17 +00:00
|
|
|
else keypad.touch(button, xy);
|
|
|
|
});
|
|
|
|
|
|
|
|
Bangle.on('swipe', dir => {
|
2023-05-12 22:40:51 +00:00
|
|
|
if (!common.timerExists()) keypad.swipe(dir);
|
2022-11-02 19:06:17 +00:00
|
|
|
});
|
|
|
|
|
2023-05-12 22:40:51 +00:00
|
|
|
if (common.timerExists()) timerView.show(common);
|
2022-11-02 19:06:17 +00:00
|
|
|
else keypad.show(common);
|