From 71b9b3c3b1242dd571170fb0f8dd22760a1b4c53 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Mar 2024 13:41:14 +0100 Subject: Use closures for `Svg::style` --- examples/svg/src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs index 4e238048..0870dce4 100644 --- a/examples/svg/src/main.rs +++ b/examples/svg/src/main.rs @@ -41,12 +41,12 @@ impl Sandbox for Tiger { )); let svg = svg(handle).width(Length::Fill).height(Length::Fill).style( - if self.apply_color_filter { - |_theme, _status| svg::Appearance { - color: Some(color!(0x0000ff)), - } - } else { - |_theme, _status| svg::Appearance::default() + |_theme, _status| svg::Appearance { + color: if self.apply_color_filter { + Some(color!(0x0000ff)) + } else { + None + }, }, ); -- cgit From aeb72d528fce58ac94df3c015c10d6fe05f81a01 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Mar 2024 14:35:55 +0100 Subject: Use closures for `Text::style` --- examples/component/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs index a1572b1d..d4f99798 100644 --- a/examples/component/src/main.rs +++ b/examples/component/src/main.rs @@ -83,7 +83,10 @@ mod numeric_input { impl Component for NumericInput where - Theme: button::DefaultStyle + text_input::DefaultStyle + 'static, + Theme: text::DefaultStyle + + button::DefaultStyle + + text_input::DefaultStyle + + 'static, { type State = (); type Event = Event; @@ -158,7 +161,10 @@ mod numeric_input { impl<'a, Message, Theme> From> for Element<'a, Message, Theme> where - Theme: button::DefaultStyle + text_input::DefaultStyle + 'static, + Theme: text::DefaultStyle + + button::DefaultStyle + + text_input::DefaultStyle + + 'static, Message: 'a, { fn from(numeric_input: NumericInput) -> Self { -- cgit From 252eb88703196dd1d373fb45cbbb7ee7b85f3726 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Mar 2024 14:58:06 +0100 Subject: Use closures for `Checkbox::style` --- examples/checkbox/src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index 121c99ea..ee745c03 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -63,17 +63,16 @@ impl Application for Example { let default_checkbox = checkbox("Default", self.default) .on_toggle(Message::DefaultToggled); - let styled_checkbox = |label, style| { + let styled_checkbox = |label| { checkbox(label, self.styled) .on_toggle_maybe(self.default.then_some(Message::StyledToggled)) - .style(style) }; let checkboxes = row![ - styled_checkbox("Primary", checkbox::primary), - styled_checkbox("Secondary", checkbox::secondary), - styled_checkbox("Success", checkbox::success), - styled_checkbox("Danger", checkbox::danger), + styled_checkbox("Primary").style(checkbox::primary), + styled_checkbox("Secondary").style(checkbox::secondary), + styled_checkbox("Success").style(checkbox::success), + styled_checkbox("Danger").style(checkbox::danger), ] .spacing(20); -- cgit From 98621aa344a7a0e1b23f320d21a4687af559998e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Mar 2024 16:52:53 +0100 Subject: Remove `themer` use from `gradient` example :tada: --- examples/gradient/src/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs index 4a8b2fa5..8ed4c830 100644 --- a/examples/gradient/src/main.rs +++ b/examples/gradient/src/main.rs @@ -1,6 +1,6 @@ use iced::application; use iced::widget::{ - checkbox, column, container, horizontal_space, row, slider, text, themer, + checkbox, column, container, horizontal_space, row, slider, text, }; use iced::{gradient, window}; use iced::{ @@ -70,16 +70,16 @@ impl Sandbox for Gradient { transparent, } = *self; - let gradient = gradient::Linear::new(angle) - .add_stop(0.0, start) - .add_stop(1.0, end); + let gradient_box = container(horizontal_space()) + .style(move |_theme, _status| { + let gradient = gradient::Linear::new(angle) + .add_stop(0.0, start) + .add_stop(1.0, end); - let gradient_box = themer( - gradient, - container(horizontal_space()) - .width(Length::Fill) - .height(Length::Fill), - ); + gradient.into() + }) + .width(Length::Fill) + .height(Length::Fill); let angle_picker = row![ text("Angle").width(64), -- cgit