From f10e936f00d4b83dcacfdebd2727b1a5cd1add95 Mon Sep 17 00:00:00 2001 From: Dan Mishin Date: Fri, 3 Mar 2023 10:01:49 +0300 Subject: Introduce disabled state for `TextInput` --- style/src/text_input.rs | 6 ++++++ style/src/theme.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'style/src') diff --git a/style/src/text_input.rs b/style/src/text_input.rs index 73b05852..2616ad5a 100644 --- a/style/src/text_input.rs +++ b/style/src/text_input.rs @@ -33,6 +33,9 @@ pub trait StyleSheet { /// Produces the [`Color`] of the value of a text input. fn value_color(&self, style: &Self::Style) -> Color; + /// Produces the [`Color`] of the value of a disabled text input. + fn disabled_color(&self, style: &Self::Style) -> Color; + /// Produces the [`Color`] of the selection of a text input. fn selection_color(&self, style: &Self::Style) -> Color; @@ -40,4 +43,7 @@ pub trait StyleSheet { fn hovered(&self, style: &Self::Style) -> Appearance { self.focused(style) } + + /// Produces the style of a disabled text input. + fn disabled(&self, style: &Self::Style) -> Appearance; } diff --git a/style/src/theme.rs b/style/src/theme.rs index 0d974a19..e13edb05 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1093,4 +1093,30 @@ impl text_input::StyleSheet for Theme { palette.primary.weak.color } + + fn disabled(&self, style: &Self::Style) -> text_input::Appearance { + if let TextInput::Custom(custom) = style { + return custom.disabled(self); + } + + let palette = self.extended_palette(); + + text_input::Appearance { + background: palette.background.base.color.into(), + border_radius: 2.0, + border_width: 1.0, + border_color: palette.background.weak.color, + icon_color: palette.background.weak.color, + } + } + + fn disabled_color(&self, style: &Self::Style) -> Color { + if let TextInput::Custom(custom) = style { + return custom.value_color(self); + } + + let palette = self.extended_palette(); + + palette.secondary.strong.color + } } -- cgit From 1de794aabfaa651f021ff2e5831397d7ce9fc53c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Apr 2023 04:34:37 +0200 Subject: Fine-tune built-in styling of disabled `TextInput` --- style/src/theme.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index e13edb05..6bd82a96 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -1102,21 +1102,19 @@ impl text_input::StyleSheet for Theme { let palette = self.extended_palette(); text_input::Appearance { - background: palette.background.base.color.into(), + background: palette.background.weak.color.into(), border_radius: 2.0, border_width: 1.0, - border_color: palette.background.weak.color, - icon_color: palette.background.weak.color, + border_color: palette.background.strong.color, + icon_color: palette.background.strong.color, } } fn disabled_color(&self, style: &Self::Style) -> Color { if let TextInput::Custom(custom) = style { - return custom.value_color(self); + return custom.disabled_color(self); } - let palette = self.extended_palette(); - - palette.secondary.strong.color + self.placeholder_color(style) } } -- cgit