diff options
Diffstat (limited to 'examples/gradient/src/main.rs')
-rw-r--r-- | examples/gradient/src/main.rs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs index a021c164..1a264063 100644 --- a/examples/gradient/src/main.rs +++ b/examples/gradient/src/main.rs @@ -1,7 +1,7 @@ use iced::application; use iced::theme::{self, Theme}; use iced::widget::{ - checkbox, column, container, horizontal_space, row, slider, text, + checkbox, column, container, horizontal_space, row, slider, text, themer, }; use iced::{gradient, window}; use iced::{ @@ -71,20 +71,24 @@ impl Sandbox for Gradient { transparent, } = *self; - let gradient_box = container(horizontal_space()) - .width(Length::Fill) - .height(Length::Fill) - .style(move |_: &_| { - let gradient = gradient::Linear::new(angle) - .add_stop(0.0, start) - .add_stop(1.0, end) - .into(); - - container::Appearance { - background: Some(Background::Gradient(gradient)), - ..Default::default() - } - }); + let appearance = { + let gradient = gradient::Linear::new(angle) + .add_stop(0.0, start) + .add_stop(1.0, end) + .into(); + + container::Appearance { + background: Some(Background::Gradient(gradient)), + ..Default::default() + } + }; + + let gradient_box = themer( + move |_| appearance, + container(horizontal_space()) + .width(Length::Fill) + .height(Length::Fill), + ); let angle_picker = row![ text("Angle").width(64), |