Switch to triple-picker for setting timers

master
Travis Evans 2025-04-07 14:43:28 -05:00
parent 0fdd128f37
commit ac2a1c5e53
1 changed files with 31 additions and 48 deletions

View File

@ -1,5 +1,6 @@
const Layout = require('Layout'); const Layout = require('Layout');
const locale = require('locale'); const locale = require('locale');
const pickers = require('more_pickers');
const tt = require('tevtimer'); const tt = require('tevtimer');
@ -682,7 +683,7 @@ class TimerViewMenu {
}, 0); }, 0);
} }
}, },
'Start': this.edit_start_hms_menu.bind(this), 'Start': this.edit_start.bind(this),
'Vibrate pattern': require("buzz_menu").pattern( 'Vibrate pattern': require("buzz_menu").pattern(
this.timer.vibrate_pattern, this.timer.vibrate_pattern,
v => this.timer.vibrate_pattern = v), v => this.timer.vibrate_pattern = v),
@ -707,60 +708,42 @@ class TimerViewMenu {
E.showMenu(edit_menu); E.showMenu(edit_menu);
} }
edit_start_hms_menu() { edit_start() {
let origin_hms = { let origin_hms = {
h: Math.floor(this.timer.origin / 3600), h: Math.floor(this.timer.origin / 3600),
m: Math.floor(this.timer.origin / 60) % 60, m: Math.floor(this.timer.origin / 60) % 60,
s: Math.floor(this.timer.origin % 60), s: Math.floor(this.timer.origin % 60),
}; };
const update_origin = () => { function picker_format(v) {
this.timer.origin = origin_hms.h * 3600 // Display leading 0 for single digit values in the picker
+ origin_hms.m * 60 return v < 10 ? '0' + v : v;
+ origin_hms.s; }
};
const edit_start_hms_menu = { pickers.triplePicker({
'': { title: "Set Start",
title: 'Start (HMS)', value_1: origin_hms.h,
back: this.edit_menu.bind(this), value_2: origin_hms.m,
}, value_3: origin_hms.s,
'Hours': { format_2: picker_format,
value: origin_hms.h, format_3: picker_format,
min: 0, min_1: 0,
max: 9999, max_1: 99,
wrap: true, min_2: 0,
onchange: v => { max_2: 59,
origin_hms.h = v; min_3: 0,
update_origin(); max_3: 59,
tt.set_timers_dirty(); wrap_1: false,
} wrap_2: true,
}, wrap_3: true,
'Minutes': { separator_1: ':',
value: origin_hms.m, separator_2: ':',
min: 0, back: this.edit_menu.bind(this),
max: 59, onchange: (h, m, s) => {
wrap: true, this.timer.origin = h * 3600 + m * 60 + s;
onchange: v => { tt.set_timers_dirty();
origin_hms.m = v; }
update_origin(); });
tt.set_timers_dirty();
}
},
'Seconds': {
value: origin_hms.s,
min: 0,
max: 59,
wrap: true,
onchange: v => {
origin_hms.s = v;
update_origin();
tt.set_timers_dirty();
}
},
};
E.showMenu(edit_start_hms_menu);
} }
} }