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 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'src/lib.rs') 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(), }, -- cgit v1.2.3