-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathAutoMenuDelegate.mc
39 lines (28 loc) · 1013 Bytes
/
AutoMenuDelegate.mc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Toybox.Application as App;
using Toybox.WatchUi as Ui;
class AutoMenuDelegate extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if(item == :MiDuration) {
Ui.pushView(new Ui.NumberPicker(Ui.NUMBER_PICKER_TIME,
new Time.Duration(App.getApp().autoTimeSet)),
new AutoTimeDelegate(), Ui.SLIDE_LEFT);
}
else if(item == :MiSchedule) {
Ui.pushView(new Ui.NumberPicker(Ui.NUMBER_PICKER_TIME_OF_DAY,
new Time.Duration(App.getApp().autoStartSet)),
new AutoStartDelegate(), Ui.SLIDE_LEFT);
}
}
}
class AutoTimeDelegate extends Ui.NumberPickerDelegate {
function onNumberPicked(duration) {
var app = App.getApp();
app.autoTimeSet = duration.value().toNumber();
}
}
class AutoStartDelegate extends Ui.NumberPickerDelegate {
function onNumberPicked(duration) {
var app = App.getApp();
app.autoStartSet = duration.value().toNumber();
}
}