Fix button styles for unsaved changes prompt

This commit is contained in:
Josh Megnauth 2024-02-27 23:33:05 -05:00 committed by Jeremy Soller
parent 3f90af8d98
commit 1686c72131

View file

@ -1020,20 +1020,18 @@ impl App {
// "Save" is displayed regardless if the file was already saved because the message handles // "Save" is displayed regardless if the file was already saved because the message handles
// "Save As" if necessary // "Save As" if necessary
let save = widget::text(fl!("save")); let save = fl!("save");
let save_button = widget::button(save) let save_button = widget::button::suggested(save)
.on_press(Message::Save) .on_press(Message::Save)
.style(theme::Button::Suggested)
.width(Length::Fill); .width(Length::Fill);
// "Save As" is only shown if the file has been saved previously // "Save As" is only shown if the file has been saved previously
// Rationale: The user may want to save the modified buffer as a new file // Rationale: The user may want to save the modified buffer as a new file
let save_as_button = match self.tab_model.data(entity) { let save_as_button = match self.tab_model.data(entity) {
Some(Tab::Editor(tab)) if tab.path_opt.is_some() => { Some(Tab::Editor(tab)) if tab.path_opt.is_some() => {
let save_as = widget::text(fl!("save-as")); let save_as = fl!("save-as");
let save_as_button = widget::button(save_as) let save_as_button = widget::button::suggested(save_as)
.on_press(Message::SaveAsDialog) .on_press(Message::SaveAsDialog)
.style(theme::Button::Suggested)
.width(Length::Fill); .width(Length::Fill);
Some(save_as_button) Some(save_as_button)
} }
@ -1046,24 +1044,21 @@ impl App {
// let diff_button = widget::button(diff.into()); // let diff_button = widget::button(diff.into());
// Discards unsaved changes // Discards unsaved changes
let discard = widget::text(fl!("discard")); let discard = fl!("discard");
let discard_button = widget::button(discard) let discard_button = widget::button::destructive(discard)
.on_press(Message::TabCloseForce(entity)) .on_press(Message::TabCloseForce(entity))
.style(theme::Button::Destructive)
.width(Length::Fill); .width(Length::Fill);
widget::column::with_children(vec![ widget::column::with_capacity(3)
widget::text(fl!("prompt-unsaved-changes")) .push(
.style(theme::Text::Color(warning_color.into())) widget::text(fl!("prompt-unsaved-changes"))
.into(), .style(theme::Text::Color(warning_color.into())),
widget::row::with_capacity(2) )
.push(save_button) .push(save_button)
.push_maybe(save_as_button) .push_maybe(save_as_button)
.into(), .push(discard_button)
discard_button.into(), .spacing(spacing.space_s)
]) .into()
.spacing(spacing.space_s)
.into()
} }
fn settings(&self) -> Element<Message> { fn settings(&self) -> Element<Message> {