summaryrefslogtreecommitdiff
path: root/material_theme
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--material_theme/Cargo.toml3
-rw-r--r--material_theme/src/lib.rs74
2 files changed, 44 insertions, 33 deletions
diff --git a/material_theme/Cargo.toml b/material_theme/Cargo.toml
index 5a48dc0..e88ce92 100644
--- a/material_theme/Cargo.toml
+++ b/material_theme/Cargo.toml
@@ -14,12 +14,15 @@ rust-version = "1.85"
[features]
default = []
animate = ["dep:iced_anim"]
+dialog = ["dep:iced_dialog"]
[dependencies]
iced_widget = "0.14.0-dev"
serde.workspace = true
toml.workspace = true
dark-light = "2.0.0"
+iced_dialog.workspace = true
+iced_dialog.optional = true
[dependencies.iced_anim]
workspace = true
diff --git a/material_theme/src/lib.rs b/material_theme/src/lib.rs
index 930e511..87cf353 100644
--- a/material_theme/src/lib.rs
+++ b/material_theme/src/lib.rs
@@ -28,31 +28,6 @@ impl Theme {
}
}
-#[cfg(feature = "animate")]
-impl iced_anim::Animate for Theme {
- fn components() -> usize {
- ColorScheme::components()
- }
-
- fn update(&mut self, components: &mut impl Iterator<Item = f32>) {
- let mut colors = self.colorscheme;
- colors.update(components);
-
- *self = Theme::new("Animating Theme", colors);
- }
-
- fn distance_to(&self, end: &Self) -> Vec<f32> {
- self.colorscheme.distance_to(&end.colorscheme)
- }
-
- fn lerp(&mut self, start: &Self, end: &Self, progress: f32) {
- let mut colors = self.colorscheme;
- colors.lerp(&start.colorscheme, &end.colorscheme, progress);
-
- *self = Theme::new("Animating Theme", colors);
- }
-}
-
impl Clone for Theme {
fn clone(&self) -> Self {
Self {
@@ -92,6 +67,47 @@ impl Base for Theme {
}
}
+#[cfg(feature = "animate")]
+impl iced_anim::Animate for Theme {
+ fn components() -> usize {
+ ColorScheme::components()
+ }
+
+ fn update(&mut self, components: &mut impl Iterator<Item = f32>) {
+ let mut colors = self.colorscheme;
+ colors.update(components);
+
+ *self = Theme::new("Animating Theme", colors);
+ }
+
+ fn distance_to(&self, end: &Self) -> Vec<f32> {
+ self.colorscheme.distance_to(&end.colorscheme)
+ }
+
+ fn lerp(&mut self, start: &Self, end: &Self, progress: f32) {
+ let mut colors = self.colorscheme;
+ colors.lerp(&start.colorscheme, &end.colorscheme, progress);
+
+ *self = Theme::new("Animating Theme", colors);
+ }
+}
+
+#[cfg(feature = "dialog")]
+impl iced_dialog::dialog::Catalog for Theme {
+ fn default_container<'a>()
+ -> <Self as iced_widget::container::Catalog>::Class<'a> {
+ Box::new(container::surface)
+ }
+}
+
+pub static DARK: LazyLock<Theme> = LazyLock::new(|| {
+ toml::from_str(DARK_THEME_CONTENT).expect("parse dark theme")
+});
+
+pub static LIGHT: LazyLock<Theme> = LazyLock::new(|| {
+ toml::from_str(LIGHT_THEME_CONTENT).expect("parse light theme")
+});
+
#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
#[cfg_attr(feature = "animate", derive(iced_anim::Animate))]
pub struct ColorScheme {
@@ -106,14 +122,6 @@ pub struct ColorScheme {
pub shadow: Color,
}
-pub static DARK: LazyLock<Theme> = LazyLock::new(|| {
- toml::from_str(DARK_THEME_CONTENT).expect("parse dark theme")
-});
-
-pub static LIGHT: LazyLock<Theme> = LazyLock::new(|| {
- toml::from_str(LIGHT_THEME_CONTENT).expect("parse light theme")
-});
-
#[derive(Debug, Clone, Copy, PartialEq, Deserialize)]
#[cfg_attr(feature = "animate", derive(iced_anim::Animate))]
pub struct Primary {