diff options
author | 2024-03-06 21:27:03 +0100 | |
---|---|---|
committer | 2024-03-06 21:27:03 +0100 | |
commit | 7c4bf70023a8092faad9630c2c87fbf41bd6ab76 (patch) | |
tree | a02aa7fa62276e4e9b870f4f88ba448c0a264e2b /examples | |
parent | 34e7c6593a9e0f56cee5db18b7258717cf6bc11b (diff) | |
download | iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.tar.gz iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.tar.bz2 iced-7c4bf70023a8092faad9630c2c87fbf41bd6ab76.zip |
Simplify theming for `Application`
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gradient/src/main.rs | 16 | ||||
-rw-r--r-- | examples/solar_system/src/main.rs | 15 |
2 files changed, 12 insertions, 19 deletions
diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs index 3334bde9..6d3ff125 100644 --- a/examples/gradient/src/main.rs +++ b/examples/gradient/src/main.rs @@ -1,11 +1,11 @@ use iced::application; -use iced::theme::{self, Theme}; use iced::widget::{ checkbox, column, container, horizontal_space, row, slider, text, themer, }; use iced::{gradient, window}; use iced::{ Alignment, Background, Color, Element, Length, Radians, Sandbox, Settings, + Theme, }; pub fn main() -> iced::Result { @@ -115,16 +115,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) } } } diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index a58ca683..4cc625da 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -9,7 +9,6 @@ use iced::application; use iced::executor; use iced::mouse; -use iced::theme::{self, Theme}; use iced::widget::canvas; use iced::widget::canvas::gradient; use iced::widget::canvas::stroke::{self, Stroke}; @@ -17,7 +16,7 @@ use iced::widget::canvas::Path; use iced::window; use iced::{ Application, Color, Command, Element, Length, Point, Rectangle, Renderer, - Settings, Size, Subscription, Vector, + Settings, Size, Subscription, Theme, Vector, }; use std::time::Instant; @@ -80,15 +79,11 @@ impl Application for SolarSystem { Theme::Dark } - fn style(&self) -> theme::Application { - fn dark_background(_theme: &Theme) -> application::Appearance { - application::Appearance { - background_color: Color::BLACK, - text_color: Color::WHITE, - } + fn style(&self, _theme: &Theme) -> application::Appearance { + application::Appearance { + background_color: Color::BLACK, + text_color: Color::WHITE, } - - theme::Application::custom(dark_background) } fn subscription(&self) -> Subscription<Message> { |