From eea6c89ce603d452985581ebea3d42543142ab85 Mon Sep 17 00:00:00 2001 From: pml68 Date: Sun, 16 Feb 2025 15:32:11 +0100 Subject: feat!: add name to `Theme`, `is_dark` -> `dark` --- src/config.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 9d29af7..5569aae 100644 --- a/src/config.rs +++ b/src/config.rs @@ -79,13 +79,13 @@ impl Config { let content = fs::read_to_string(entry.path()).await.ok()?; let theme: Theme = toml::from_str(content.as_ref()).ok()?; - let name = entry.path().file_stem()?.to_string_lossy().to_string(); - Some(theme.into_iced_theme(name)) + Some(iced::Theme::from(theme)) }; + let mut selected = Theme::default().into(); let mut all = iced::Theme::ALL.to_owned(); - let mut selected = iced::Theme::default(); + all.push(Theme::default().into()); if theme_index(&theme_name, iced::Theme::ALL).is_some() { selected = theme_from_str(None, &theme_name); @@ -98,18 +98,11 @@ impl Config { continue; }; - let Some(file_name) = entry.file_name().to_str().map(String::from) - else { - continue; - }; - - if let Some(file_name) = file_name.strip_suffix(".toml") { - if let Some(theme) = read_entry(entry).await { - if file_name == theme_name { - selected = theme.clone(); - } - all.push(theme); + if let Some(theme) = read_entry(entry).await { + if theme.to_string() == theme_name { + selected = theme.clone(); } + all.push(theme); } } -- cgit v1.2.3