From d1e40495410049aedb6756be1febd83bae5eee1e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Mar 2024 15:35:48 +0100 Subject: Use closures for `TextInput::style` --- widget/src/combo_box.rs | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'widget/src/combo_box.rs') diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs index bddf2789..95667882 100644 --- a/widget/src/combo_box.rs +++ b/widget/src/combo_box.rs @@ -62,7 +62,7 @@ where on_selected: impl Fn(T) -> Message + 'static, ) -> Self where - Theme: DefaultStyle, + Theme: DefaultStyle + 'a, { let style = Theme::default_style(); @@ -125,7 +125,10 @@ where } /// Sets the style of the [`ComboBox`]. - pub fn style(mut self, style: impl Into>) -> Self { + pub fn style(mut self, style: impl Into>) -> Self + where + Theme: 'a, + { let style = style.into(); self.text_input = self.text_input.style(style.text_input); @@ -761,10 +764,10 @@ where } /// The style of a [`ComboBox`]. -#[derive(Debug, PartialEq, Eq)] +#[allow(missing_debug_implementations)] pub struct Style { /// The style of the [`TextInput`] of the [`ComboBox`]. - pub text_input: fn(&Theme, text_input::Status) -> text_input::Appearance, + pub text_input: text_input::Style<'static, Theme>, /// The style of the [`Menu`] of the [`ComboBox`]. /// @@ -772,22 +775,6 @@ pub struct Style { pub menu: menu::Style, } -impl Style { - /// The default style of a [`ComboBox`]. - pub const DEFAULT: Self = Self { - text_input: text_input::default, - menu: menu::Style::::DEFAULT, - }; -} - -impl Clone for Style { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for Style {} - /// The default style of a [`ComboBox`]. pub trait DefaultStyle: Sized { /// Returns the default style of a [`ComboBox`]. @@ -796,6 +783,9 @@ pub trait DefaultStyle: Sized { impl DefaultStyle for Theme { fn default_style() -> Style { - Style::::DEFAULT + Style { + text_input: Box::new(text_input::default), + menu: menu::Style::DEFAULT, + } } } -- cgit