Implement naming timers with textinput apps

master
Travis Evans 2025-03-21 13:58:42 -05:00
parent 3a2b2bc60e
commit 11ab4144d4
1 changed files with 19 additions and 0 deletions

View File

@ -342,11 +342,26 @@ class TimerViewMenu {
}
edit_menu() {
let keyboard = null;
try { keyboard = require("textinput"); } catch (e) {}
const edit_menu = {
'': {
title: 'Edit: ' + this.timer.display_name(),
back: () => { this.top_menu(); },
},
'Name': {
value: this.timer.name,
onchange: () => {
setTimeout(() => {
keyboard.input({text:this.timer.name}).then(text => {
this.timer.name = text;
tt.set_timers_dirty();
setTimeout(() => { this.edit_menu(); }, 0);
});
}, 0);
}
},
'Start': this.edit_start_hms_menu.bind(this),
'Vibrate pattern': require("buzz_menu").pattern(
this.timer.vibrate_pattern,
@ -365,6 +380,10 @@ class TimerViewMenu {
},
};
if (!keyboard) {
delete edit_menu.Name;
}
E.showMenu(edit_menu);
}