diff options
Diffstat (limited to 'examples/styling')
-rw-r--r-- | examples/styling/src/main.rs | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 27b3ead4..044f75a9 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -5,7 +5,7 @@ use iced::text_input; use iced::{ Alignment, Button, Checkbox, Column, Container, Element, Length, ProgressBar, Radio, Row, Rule, Sandbox, Scrollable, Settings, Slider, - Space, Text, TextInput, Toggler, + Space, Text, TextInput, Theme, Toggler, }; pub fn main() -> iced::Result { @@ -115,8 +115,7 @@ impl Sandbox for Styling { Message::TogglerToggled, ) .width(Length::Shrink) - .spacing(10) - .style(self.theme); + .spacing(10); let content = Column::new() .spacing(20) @@ -151,12 +150,18 @@ impl Sandbox for Styling { .style(self.theme) .into() } + + fn theme(&self) -> Theme { + match self.theme { + style::Theme::Light => Theme::Light, + style::Theme::Dark => Theme::Dark, + } + } } mod style { use iced::{ checkbox, container, progress_bar, rule, scrollable, text_input, - toggler, }; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -220,15 +225,6 @@ mod style { } } - impl From<Theme> for Box<dyn toggler::StyleSheet> { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Toggler.into(), - } - } - } - impl From<Theme> for Box<dyn rule::StyleSheet> { fn from(theme: Theme) -> Self { match theme { @@ -241,7 +237,7 @@ mod style { mod dark { use iced::{ checkbox, container, progress_bar, rule, scrollable, text_input, - toggler, Color, + Color, }; const SURFACE: Color = Color::from_rgb( @@ -404,35 +400,6 @@ mod style { } } - pub struct Toggler; - - impl toggler::StyleSheet for Toggler { - fn active(&self, is_active: bool) -> toggler::Style { - toggler::Style { - background: if is_active { ACTIVE } else { SURFACE }, - background_border: None, - foreground: if is_active { Color::WHITE } else { ACTIVE }, - foreground_border: None, - } - } - - fn hovered(&self, is_active: bool) -> toggler::Style { - toggler::Style { - background: if is_active { ACTIVE } else { SURFACE }, - background_border: None, - foreground: if is_active { - Color { - a: 0.5, - ..Color::WHITE - } - } else { - Color { a: 0.5, ..ACTIVE } - }, - foreground_border: None, - } - } - } - pub struct Rule; impl rule::StyleSheet for Rule { |