From 849cc869be51ccf79b603662fb7db13c241fbc9a Mon Sep 17 00:00:00 2001 From: Polesznyák Márk Date: Fri, 21 Nov 2025 11:28:07 +0100 Subject: chore: update as necessary for upstream iced changes --- src/lib.rs | 40 ++++++++++++++++++++++------------------ src/toggler.rs | 19 +++++++++++++++++-- 2 files changed, 39 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 26828f0..12d0a6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,11 +84,11 @@ impl Theme { }) } - pub fn name(&self) -> Cow<'static, str> { + pub fn name(&self) -> &str { match self { - Self::Dark => "Dark".into(), - Self::Light => "Light".into(), - Self::Custom(custom) => custom.name.clone(), + Self::Dark => "Dark", + Self::Light => "Light", + Self::Custom(custom) => &custom.name, } } @@ -116,6 +116,21 @@ impl std::fmt::Display for Theme { } impl Base for Theme { + fn default(preference: Mode) -> Self { + match preference { + Mode::None | Mode::Dark => Self::Dark, + Mode::Light => Self::Light, + } + } + + fn mode(&self) -> Mode { + if self.is_dark() { + Mode::Dark + } else { + Mode::Light + } + } + fn base(&self) -> Style { Style { background_color: self.colors().surface.color, @@ -136,19 +151,8 @@ impl Base for Theme { }) } - fn default(preference: Mode) -> Self { - match preference { - Mode::None | Mode::Dark => Self::Dark, - Mode::Light => Self::Light, - } - } - - fn mode(&self) -> Mode { - if self.is_dark() { - Mode::Dark - } else { - Mode::Light - } + fn name(&self) -> &str { + self.name() } } @@ -207,7 +211,7 @@ impl From for Custom { match theme { Theme::Custom(custom) => custom, theme => Self { - name: theme.name(), + name: theme.name().to_owned().into(), is_dark: theme.is_dark(), colorscheme: theme.colors(), }, diff --git a/src/toggler.rs b/src/toggler.rs index 5cebc88..cf2aa1d 100644 --- a/src/toggler.rs +++ b/src/toggler.rs @@ -21,6 +21,7 @@ impl Catalog for Theme { pub fn styled( background: Color, foreground: Color, + text_color: Color, border: Option, ) -> Style { Style { @@ -30,6 +31,7 @@ pub fn styled( foreground, foreground_border_width: 0.0, foreground_border_color: Color::TRANSPARENT, + text_color: Some(text_color), } } @@ -40,18 +42,29 @@ pub fn default(theme: &Theme, status: Status) -> Style { match status { Status::Active { is_toggled } => { if is_toggled { - styled(primary.color, primary.on_primary, None) + styled( + primary.color, + primary.on_primary, + surface.on_surface, + None, + ) } else { styled( surface.surface_container.highest, theme.colors().outline.color, + surface.on_surface, Some(theme.colors().outline.color), ) } } Status::Hovered { is_toggled } => { if is_toggled { - styled(primary.color, primary.primary_container, None) + styled( + primary.color, + primary.primary_container, + surface.on_surface, + None, + ) } else { styled( mix( @@ -60,6 +73,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { HOVERED_LAYER_OPACITY, ), surface.on_surface_variant, + surface.on_surface, Some(theme.colors().outline.color), ) } @@ -67,6 +81,7 @@ pub fn default(theme: &Theme, status: Status) -> Style { Status::Disabled => styled( disabled_container(surface.surface_container.highest), disabled_text(surface.on_surface), + surface.on_surface, Some(disabled_text(surface.on_surface)), ), } -- cgit v1.2.3