From 8d8dc754d3e7d9eefdfb9a948574c1672c40c553 Mon Sep 17 00:00:00 2001 From: Dominic Gerhauser Date: Tue, 2 Jul 2024 18:22:59 +0200 Subject: [PATCH] clearer wrong password response standard typography match desgings destructive color instead of #ff0000 set min width and height for poolkit buttons --- src/components/polkit_dialog.rs | 41 +++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/components/polkit_dialog.rs b/src/components/polkit_dialog.rs index 8e5179c..01b3d7e 100644 --- a/src/components/polkit_dialog.rs +++ b/src/components/polkit_dialog.rs @@ -166,15 +166,28 @@ impl State { pub fn view(&self) -> cosmic::Element<'_, Msg> { // TODO Allocates on every keypress? - + let active_theme = cosmic::theme::active(); + let cosmic_theme = active_theme.cosmic(); let placeholder = self.password_label.trim_end_matches(':'); let mut password_input = cosmic::widget::text_input(placeholder, &self.password).id(self.text_input_id.clone()); if !self.echo { password_input = password_input.password(); } - let mut cancel_button = cosmic::widget::button::standard(&self.msg_cancel); - let mut authenticate_button = cosmic::widget::button::suggested(&self.msg_authenticate); + let mut cancel_button = cosmic::widget::button(min_width_and_height( + cosmic::widget::text(&self.msg_cancel).size(14).into(), + 142.0, + 32.0, + )) + .padding([0, cosmic_theme.space_s()]) + .style(cosmic::theme::Button::Standard); + let mut authenticate_button = cosmic::widget::button(min_width_and_height( + cosmic::widget::text(&self.msg_authenticate).size(14).into(), + 142.0, + 32.0, + )) + .padding([0, cosmic_theme.space_s()]) + .style(cosmic::theme::Button::Suggested); if self.sensitive { password_input = password_input .on_input(Msg::Password) @@ -188,10 +201,10 @@ impl State { ]; if self.retries > 0 { right_column.push( - widget::text(&self.msg_invalid_password) - .style(cosmic::theme::Text::Color(iced::Color::from_rgb( - 1.0, 0.0, 0.0, - ))) + cosmic::widget::text::caption(&self.msg_invalid_password) + .style(cosmic::theme::Text::Color( + cosmic_theme.destructive_color().into(), + )) .into(), ); } @@ -227,3 +240,17 @@ impl State { ]) } } + +fn min_width_and_height<'a>( + e: cosmic::Element<'a, Msg>, + width: impl Into, + height: impl Into, +) -> cosmic::widget::Column<'a, Msg> { + cosmic::widget::column::with_children(vec![ + cosmic::widget::row::with_children(vec![e, cosmic::widget::vertical_space(height).into()]) + .align_items(iced::Alignment::Center) + .into(), + cosmic::widget::horizontal_space(width).into(), + ]) + .align_items(iced::Alignment::Center) +}