feat: combine button label config into an array

This commit is contained in:
greg 2024-10-17 07:59:18 +02:00 committed by sxyazi
parent cb27f5c74a
commit d2fe67ab86
No known key found for this signature in database
3 changed files with 14 additions and 16 deletions

View file

@ -101,8 +101,7 @@ selected = { reversed = true }
# : Confirm {{{ # : Confirm {{{
[confirm] [confirm]
button_yes = " [Y]es " button_labels = [" [Y]es ", " (N)o "]
button_no = " (N)o "
border = { fg = "blue" } border = { fg = "blue" }
title = { fg = "blue" } title = { fg = "blue" }
content = { } content = { }

View file

@ -117,8 +117,7 @@ pub struct Input {
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Confirm { pub struct Confirm {
pub button_yes: String, pub button_labels: [String; 2],
pub button_no: String,
pub border: Style, pub border: Style,
pub title: Style, pub title: Style,
pub content: Style, pub content: Style,

View file

@ -14,10 +14,10 @@ impl Widget for Buttons {
let chunks = let chunks =
ratatui::layout::Layout::horizontal([Constraint::Fill(1), Constraint::Fill(1)]).split(area); ratatui::layout::Layout::horizontal([Constraint::Fill(1), Constraint::Fill(1)]).split(area);
Paragraph::new(Span::raw(&THEME.confirm.button_yes).style(THEME.confirm.buttons)) Paragraph::new(Span::raw(&THEME.confirm.button_labels[0]).style(THEME.confirm.buttons))
.centered() .centered()
.render(chunks[0], buf); .render(chunks[0], buf);
Paragraph::new(Span::raw(&THEME.confirm.button_no).style(THEME.confirm.buttons)) Paragraph::new(Span::raw(&THEME.confirm.button_labels[1]).style(THEME.confirm.buttons))
.centered() .centered()
.render(chunks[1], buf); .render(chunks[1], buf);
} }