diff options
| author | pml68 <contact@pml68.dev> | 2025-04-28 10:59:52 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-28 23:45:43 +0200 |
| commit | e17ce59fa4c907511f38795c342b2232a7bba26d (patch) | |
| tree | 0bbeddd19696de817a97f2109bae316e3a564f3a /src/types/project.rs | |
| parent | feat: switch to modified `iced_fontello` for custom Theme support (diff) | |
| download | iced-builder-e17ce59fa4c907511f38795c342b2232a7bba26d.tar.gz | |
feat: switch to fully custom, Material3-based theme
Diffstat (limited to 'src/types/project.rs')
| -rw-r--r-- | src/types/project.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/types/project.rs b/src/types/project.rs index 91b2bb1..11789ac 100644 --- a/src/types/project.rs +++ b/src/types/project.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use super::rendered_element::RenderedElement; use crate::Error; -use crate::theme::{theme_from_str, theme_index}; +use crate::appearance::iced_theme_from_str; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Project { @@ -33,8 +33,8 @@ impl Project { pub fn get_theme(&self) -> Theme { match &self.theme { - Some(theme) => theme_from_str(None, theme), - None => Theme::default(), + Some(theme) => iced_theme_from_str(theme), + None => iced::Theme::default(), } } @@ -90,20 +90,10 @@ impl Project { Some(ref element_tree) => { let (imports, view) = element_tree.codegen(); let theme = self.get_theme(); - let theme_code = theme.to_string().replace(" ", ""); - let mut theme_imports = ""; - if theme_index(&theme.to_string(), Theme::ALL).is_none() { - if theme_code.contains("Extended") { - theme_imports = "use iced::{{color,theme::{{Palette,palette::{{Extended,Background,Primary,Secondary,Success,Danger,Warning,Pair}}}}}};\n"; - } else { - theme_imports = "use iced::{{color,theme::Palette}};\n"; - } - } let app_code = format!( r#"// Automatically generated by iced Builder use iced::{{widget::{{{imports}}},Element}}; -{theme_imports} fn main() -> iced::Result {{ iced::application(State::default, State::update, State::view).title("{}").theme(State::theme).run() @@ -130,7 +120,7 @@ impl State {{ Some(ref t) => t, None => "New app", }, - theme_code + theme.to_string().replace(" ", "") ); let config = rust_format::Config::new_str() .edition(Edition::Rust2021) |
