allow selecting button in modal

This commit is contained in:
🪞👃🪞 2025-04-04 16:46:03 +03:00
parent 2e072cb51c
commit 1d1fc483ba
4 changed files with 37 additions and 15 deletions

View file

@ -24,10 +24,14 @@ impl Content<TuiOut> for Taggart {
Color::Rgb(48,48,48),
Modifier::DIM
);
let message = Bsp::s(format!("Save {} change(s)?", self.tasks.len()),
Bsp::s("",
Bsp::e(" Clear changes ", Bsp::e(" Continue editing ", " Save "))));
let modal = Self::modal(message);
let options = [
if value == 0 { "[ Clear changes ]" } else { " Clear changes " },
if value == 1 { "[ Continue editing ]" } else { " Continue editing " },
if value == 2 { "[ Write and continue ]" } else { " Write and continue " },
];
let modal = Self::modal(Bsp::s(
format!("Save {} change(s)?", self.tasks.len()),
Bsp::s("", Bsp::e(options[0], Bsp::e(options[1], options[2])))));
Content::render(&modal, to)
},
Some(Mode::Quit { value }) => {
@ -36,10 +40,14 @@ impl Content<TuiOut> for Taggart {
Color::Rgb(48,48,48),
Modifier::DIM
);
let message = Bsp::s(format!("Save {} change(s) before exiting?", self.tasks.len()),
Bsp::s("",
Bsp::e(" Exit without saving ", Bsp::e(" Cancel ", " Save and exit "))));
let modal = Self::modal(message);
let options = [
if value == 0 { "[ Exit without saving ]" } else { " Exit without saving " },
if value == 1 { "[ Cancel ]" } else { " Cancel " },
if value == 2 { "[ Write and exit ]" } else { " Write and exit " },
];
let modal = Self::modal(Bsp::s(
format!("Save {} change(s) before exiting?", self.tasks.len()),
Bsp::s("", Bsp::e(options[0], Bsp::e(options[1], options[2])))));
Content::render(&modal, to)
},
_ => {},