summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2025-04-17 00:30:03 +0200
committerpml68 <contact@pml68.dev>2025-04-17 00:30:03 +0200
commitb2b7dddb28732fbf8b070dd96922eb7df50318cb (patch)
treec6a8a61844ad7caa5ef5ded376ec19851e1cf1fe /crates
parentfeat(material_theme): implement `svg::Catalog` (under feature flag) (diff)
downloadiced-builder-b2b7dddb28732fbf8b070dd96922eb7df50318cb.tar.gz
feat(material_theme): implement `qr_code::Catalog` (under feature flag)
Diffstat (limited to '')
-rw-r--r--crates/material_theme/Cargo.toml2
-rw-r--r--crates/material_theme/src/lib.rs2
-rw-r--r--crates/material_theme/src/qr_code.rs24
3 files changed, 28 insertions, 0 deletions
diff --git a/crates/material_theme/Cargo.toml b/crates/material_theme/Cargo.toml
index ad825fd..e1da2fb 100644
--- a/crates/material_theme/Cargo.toml
+++ b/crates/material_theme/Cargo.toml
@@ -21,6 +21,8 @@ dialog = ["dep:iced_dialog"]
markdown = ["iced_widget/markdown"]
# Provides support for the SVG widget.
svg = ["iced_widget/svg"]
+# Provides support for the QR code widget.
+qr_code = ["iced_widget/qr_code"]
[dependencies]
iced_widget = "0.14.0-dev"
diff --git a/crates/material_theme/src/lib.rs b/crates/material_theme/src/lib.rs
index a41dfd5..06ad838 100644
--- a/crates/material_theme/src/lib.rs
+++ b/crates/material_theme/src/lib.rs
@@ -13,6 +13,8 @@ pub mod dialog;
pub mod markdown;
pub mod menu;
pub mod pick_list;
+#[cfg(feature = "qr_code")]
+pub mod qr_code;
pub mod scrollable;
#[cfg(feature = "svg")]
pub mod svg;
diff --git a/crates/material_theme/src/qr_code.rs b/crates/material_theme/src/qr_code.rs
new file mode 100644
index 0000000..f93fb77
--- /dev/null
+++ b/crates/material_theme/src/qr_code.rs
@@ -0,0 +1,24 @@
+use iced_widget::qr_code::{Catalog, Style, StyleFn};
+
+use super::Theme;
+
+impl Catalog for Theme {
+ type Class<'a> = StyleFn<'a, Self>;
+
+ fn default<'a>() -> Self::Class<'a> {
+ Box::new(default)
+ }
+
+ fn style(&self, class: &Self::Class<'_>) -> Style {
+ class(self)
+ }
+}
+
+pub fn default(theme: &Theme) -> Style {
+ let surface = theme.colorscheme.surface;
+
+ Style {
+ cell: surface.on_surface,
+ background: surface.color,
+ }
+}