From 70f7cd31eb5055f80664c574e46003b202b2206f Mon Sep 17 00:00:00 2001 From: pml68 Date: Thu, 17 Apr 2025 00:29:42 +0200 Subject: feat(material_theme): implement `svg::Catalog` (under feature flag) --- crates/material_theme/Cargo.toml | 2 ++ crates/material_theme/src/lib.rs | 2 ++ crates/material_theme/src/svg.rs | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 crates/material_theme/src/svg.rs (limited to 'crates') diff --git a/crates/material_theme/Cargo.toml b/crates/material_theme/Cargo.toml index 0cfa571..ad825fd 100644 --- a/crates/material_theme/Cargo.toml +++ b/crates/material_theme/Cargo.toml @@ -19,6 +19,8 @@ animate = ["dep:iced_anim"] dialog = ["dep:iced_dialog"] # Provides support for the markdown widget. markdown = ["iced_widget/markdown"] +# Provides support for the SVG widget. +svg = ["iced_widget/svg"] [dependencies] iced_widget = "0.14.0-dev" diff --git a/crates/material_theme/src/lib.rs b/crates/material_theme/src/lib.rs index e7ff343..a41dfd5 100644 --- a/crates/material_theme/src/lib.rs +++ b/crates/material_theme/src/lib.rs @@ -14,6 +14,8 @@ pub mod markdown; pub mod menu; pub mod pick_list; pub mod scrollable; +#[cfg(feature = "svg")] +pub mod svg; pub mod text; pub mod text_input; pub mod utils; diff --git a/crates/material_theme/src/svg.rs b/crates/material_theme/src/svg.rs new file mode 100644 index 0000000..885d743 --- /dev/null +++ b/crates/material_theme/src/svg.rs @@ -0,0 +1,15 @@ +use iced_widget::svg::{Catalog, Status, Style, StyleFn}; + +use super::Theme; + +impl Catalog for Theme { + type Class<'a> = StyleFn<'a, Self>; + + fn default<'a>() -> Self::Class<'a> { + Box::new(|_theme, _status| Style::default()) + } + + fn style(&self, class: &Self::Class<'_>, status: Status) -> Style { + class(self, status) + } +} -- cgit v1.2.3