From 704ec9cb5cdc1d44f2df2f15de700b0af330b1d7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 5 Mar 2024 15:53:59 +0100 Subject: Simplify theming for `TextInput` widget --- widget/src/combo_box.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'widget/src/combo_box.rs') diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs index 0cca8d56..2ecf799d 100644 --- a/widget/src/combo_box.rs +++ b/widget/src/combo_box.rs @@ -32,7 +32,7 @@ pub struct ComboBox< Theme = crate::Theme, Renderer = crate::Renderer, > where - Theme: text_input::StyleSheet + menu::StyleSheet, + Theme: text_input::Style + menu::StyleSheet, Renderer: text::Renderer, { state: &'a State, @@ -51,7 +51,7 @@ pub struct ComboBox< impl<'a, T, Message, Theme, Renderer> ComboBox<'a, T, Message, Theme, Renderer> where T: std::fmt::Display + Clone, - Theme: text_input::StyleSheet + menu::StyleSheet, + Theme: text_input::Style + menu::StyleSheet, Renderer: text::Renderer, { /// Creates a new [`ComboBox`] with the given list of options, a placeholder, @@ -121,20 +121,17 @@ where // TODO: Define its own `StyleSheet` trait pub fn style(mut self, style: S) -> Self where - S: Into<::Style> - + Into<::Style> - + Clone, + S: Into<::Style>, { - self.menu_style = style.clone().into(); - self.text_input = self.text_input.style(style); + self.menu_style = style.into(); self } /// Sets the style of the [`TextInput`] of the [`ComboBox`]. - pub fn text_input_style(mut self, style: S) -> Self - where - S: Into<::Style> + Clone, - { + pub fn text_input_style( + mut self, + style: fn(&Theme, text_input::Status) -> text_input::Appearance, + ) -> Self { self.text_input = self.text_input.style(style); self } @@ -300,8 +297,8 @@ where T: Display + Clone + 'static, Message: Clone, Theme: container::Style - + text_input::StyleSheet - + scrollable::Tradition + + text_input::Style + + scrollable::Style + menu::StyleSheet, Renderer: text::Renderer, { @@ -720,8 +717,8 @@ where T: Display + Clone + 'static, Message: Clone + 'a, Theme: container::Style - + text_input::StyleSheet - + scrollable::Tradition + + text_input::Style + + scrollable::Style + menu::StyleSheet + 'a, Renderer: text::Renderer + 'a, -- cgit