summaryrefslogtreecommitdiffstats
path: root/examples/gradient
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gradient')
-rw-r--r--examples/gradient/src/main.rs43
1 files changed, 18 insertions, 25 deletions
diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs
index a021c164..4a8b2fa5 100644
--- a/examples/gradient/src/main.rs
+++ b/examples/gradient/src/main.rs
@@ -1,11 +1,10 @@
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::{
- Alignment, Background, Color, Element, Length, Radians, Sandbox, Settings,
+ Alignment, Color, Element, Length, Radians, Sandbox, Settings, Theme,
};
pub fn main() -> iced::Result {
@@ -71,20 +70,16 @@ 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 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),
+ );
let angle_picker = row![
text("Angle").width(64),
@@ -111,16 +106,14 @@ impl Sandbox for Gradient {
.into()
}
- fn style(&self) -> theme::Application {
+ fn style(&self, theme: &Theme) -> application::Appearance {
if self.transparent {
- theme::Application::custom(|theme: &Theme| {
- application::Appearance {
- background_color: Color::TRANSPARENT,
- text_color: theme.palette().text,
- }
- })
+ application::Appearance {
+ background_color: Color::TRANSPARENT,
+ text_color: theme.palette().text,
+ }
} else {
- theme::Application::Default
+ application::default(theme)
}
}
}