diff options
Diffstat (limited to 'src/toggler.rs')
| -rw-r--r-- | src/toggler.rs | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/toggler.rs b/src/toggler.rs index 25730a2..ad6bbb1 100644 --- a/src/toggler.rs +++ b/src/toggler.rs @@ -1,4 +1,4 @@ -use iced_widget::core::Color; +use iced_widget::core::{Background, Color}; use iced_widget::toggler::{Catalog, Status, Style, StyleFn}; use super::Theme; @@ -19,19 +19,21 @@ impl Catalog for Theme { } pub fn styled( - background: Color, - foreground: Color, + background: Background, + foreground: Background, text_color: Color, border: Option<Color>, ) -> Style { Style { background, - background_border_width: if border.is_some() { 2.0 } else { 0.0 }, + background_border_width: if border.is_some() { 1.5 } else { 0.0 }, background_border_color: border.unwrap_or(Color::TRANSPARENT), foreground, - foreground_border_width: 2.0, + foreground_border_width: 0.0, foreground_border_color: Color::TRANSPARENT, text_color: Some(text_color), + border_radius: None, + padding_ratio: 0.2, } } @@ -42,11 +44,16 @@ pub fn default(theme: &Theme, status: Status) -> Style { match status { Status::Active { is_toggled } => { if is_toggled { - styled(primary.color, primary.text, surface.text, None) + styled( + primary.color.into(), + primary.text.into(), + surface.text, + None, + ) } else { styled( - surface.container.highest, - theme.colors().outline.color, + surface.container.highest.into(), + theme.colors().outline.color.into(), surface.text, Some(theme.colors().outline.color), ) @@ -54,15 +61,21 @@ pub fn default(theme: &Theme, status: Status) -> Style { } Status::Hovered { is_toggled } => { if is_toggled { - styled(primary.color, primary.container, surface.text, None) + styled( + primary.color.into(), + primary.container.into(), + surface.text, + None, + ) } else { styled( mix( surface.container.highest, surface.text, HOVERED_LAYER_OPACITY, - ), - surface.text_variant, + ) + .into(), + surface.text_variant.into(), surface.text, Some(theme.colors().outline.color), ) @@ -71,15 +84,15 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Disabled { is_toggled } => { if is_toggled { styled( - disabled_container(surface.text), - disabled_text(surface.color), + disabled_container(surface.text).into(), + disabled_text(surface.color).into(), surface.text, None, ) } else { styled( - disabled_container(surface.container.highest), - disabled_text(surface.text), + disabled_container(surface.container.highest).into(), + disabled_text(surface.text).into(), surface.text, Some(disabled_text(surface.text)), ) |
