From 28d09bfff1dde55190986bab10d7aaeb0ceb49de Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 27 May 2022 01:26:57 +0200 Subject: Implement theme styling for `Radio` --- examples/scrollable/src/main.rs | 15 ++++++--------- examples/scrollable/src/style.rs | 40 ++-------------------------------------- 2 files changed, 8 insertions(+), 47 deletions(-) (limited to 'examples/scrollable/src') diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index 8e027504..e49aa63b 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -69,15 +69,12 @@ impl Sandbox for ScrollableDemo { let choose_theme = style::Theme::ALL.iter().fold( Column::new().spacing(10).push(Text::new("Choose a theme:")), |column, option| { - column.push( - Radio::new( - *option, - format!("{:?}", option), - Some(*theme), - Message::ThemeChanged, - ) - .style(*theme), - ) + column.push(Radio::new( + *option, + format!("{:?}", option), + Some(*theme), + Message::ThemeChanged, + )) }, ); diff --git a/examples/scrollable/src/style.rs b/examples/scrollable/src/style.rs index 0ed38b00..0581a8c8 100644 --- a/examples/scrollable/src/style.rs +++ b/examples/scrollable/src/style.rs @@ -1,4 +1,4 @@ -use iced::{container, radio, rule, scrollable}; +use iced::{container, rule, scrollable}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Theme { @@ -25,15 +25,6 @@ impl<'a> From for Box { } } -impl<'a> From for Box { - fn from(theme: Theme) -> Self { - match theme { - Theme::Light => Default::default(), - Theme::Dark => dark::Radio.into(), - } - } -} - impl<'a> From for Box { fn from(theme: Theme) -> Self { match theme { @@ -53,7 +44,7 @@ impl From for Box { } mod dark { - use iced::{container, radio, rule, scrollable, Color}; + use iced::{container, rule, scrollable, Color}; const BACKGROUND: Color = Color::from_rgb( 0x36 as f32 / 255.0, @@ -73,12 +64,6 @@ mod dark { 0xE9 as f32 / 255.0, ); - const ACTIVE: Color = Color::from_rgb( - 0x72 as f32 / 255.0, - 0x89 as f32 / 255.0, - 0xDA as f32 / 255.0, - ); - const SCROLLBAR: Color = Color::from_rgb( 0x2E as f32 / 255.0, 0x33 as f32 / 255.0, @@ -107,27 +92,6 @@ mod dark { } } - 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 Scrollable; impl scrollable::StyleSheet for Scrollable { -- cgit