diff options
author | 2022-05-27 01:26:57 +0200 | |
---|---|---|
committer | 2022-05-27 01:29:36 +0200 | |
commit | 28d09bfff1dde55190986bab10d7aaeb0ceb49de (patch) | |
tree | df38cec7242de571d94378cd736a05bc82a622c2 /examples/styling | |
parent | d988d813d77bc23147a179586206048e6cc42157 (diff) | |
download | iced-28d09bfff1dde55190986bab10d7aaeb0ceb49de.tar.gz iced-28d09bfff1dde55190986bab10d7aaeb0ceb49de.tar.bz2 iced-28d09bfff1dde55190986bab10d7aaeb0ceb49de.zip |
Implement theme styling for `Radio`
Diffstat (limited to 'examples/styling')
-rw-r--r-- | examples/styling/src/main.rs | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs index 82876cb4..27b3ead4 100644 --- a/examples/styling/src/main.rs +++ b/examples/styling/src/main.rs @@ -61,15 +61,12 @@ impl Sandbox for Styling { let choose_theme = style::Theme::ALL.iter().fold( Column::new().spacing(10).push(Text::new("Choose a theme:")), |column, theme| { - column.push( - Radio::new( - *theme, - format!("{:?}", theme), - Some(self.theme), - Message::ThemeChanged, - ) - .style(self.theme), - ) + column.push(Radio::new( + *theme, + format!("{:?}", theme), + Some(self.theme), + Message::ThemeChanged, + )) }, ); @@ -158,7 +155,7 @@ impl Sandbox for Styling { mod style { use iced::{ - checkbox, container, progress_bar, radio, rule, scrollable, text_input, + checkbox, container, progress_bar, rule, scrollable, text_input, toggler, }; @@ -187,15 +184,6 @@ mod style { } } - impl<'a> From<Theme> for Box<dyn radio::StyleSheet + 'a> { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Radio.into(), - } - } - } - impl<'a> From<Theme> for Box<dyn text_input::StyleSheet + 'a> { fn from(theme: Theme) -> Self { match theme { @@ -252,8 +240,8 @@ mod style { mod dark { use iced::{ - checkbox, container, progress_bar, radio, rule, scrollable, - text_input, toggler, Color, + checkbox, container, progress_bar, rule, scrollable, text_input, + toggler, Color, }; const SURFACE: Color = Color::from_rgb( @@ -292,27 +280,6 @@ mod style { } } - pub struct Radio; - - impl radio::StyleSheet for Radio { - fn active(&self) -> radio::Style { - radio::Style { - background: SURFACE.into(), - dot_color: ACTIVE, - border_width: 1.0, - border_color: ACTIVE, - text_color: None, - } - } - - fn hovered(&self) -> radio::Style { - radio::Style { - background: Color { a: 0.5, ..SURFACE }.into(), - ..self.active() - } - } - } - pub struct TextInput; impl text_input::StyleSheet for TextInput { |