From b2b7dddb28732fbf8b070dd96922eb7df50318cb Mon Sep 17 00:00:00 2001 From: pml68 Date: Thu, 17 Apr 2025 00:30:03 +0200 Subject: feat(material_theme): implement `qr_code::Catalog` (under feature flag) --- Cargo.lock | 98 ++++++++++++++++++++++++++++++++++++ crates/material_theme/Cargo.toml | 2 + crates/material_theme/src/lib.rs | 2 + crates/material_theme/src/qr_code.rs | 24 +++++++++ 4 files changed, 126 insertions(+) create mode 100644 crates/material_theme/src/qr_code.rs diff --git a/Cargo.lock b/Cargo.lock index 3bd023a..6f5e4cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1338,6 +1338,12 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +[[package]] +name = "float_next_after" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" + [[package]] name = "fnv" version = "1.0.7" @@ -1579,6 +1585,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -2110,6 +2125,7 @@ dependencies = [ "image", "kamadak-exif", "log", + "lyon_path", "raw-window-handle", "rustc-hash 2.1.1", "thiserror 1.0.69", @@ -2181,6 +2197,7 @@ dependencies = [ "iced_debug", "iced_graphics", "log", + "lyon", "resvg", "rustc-hash 2.1.1", "thiserror 1.0.69", @@ -2197,9 +2214,12 @@ dependencies = [ "log", "num-traits", "ouroboros", + "pulldown-cmark", + "qrcode", "rustc-hash 2.1.1", "thiserror 1.0.69", "unicode-segmentation", + "url", ] [[package]] @@ -2685,6 +2705,58 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +[[package]] +name = "lyon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e7f9cda98b5430809e63ca5197b06c7d191bf7e26dfc467d5a3f0290e2a74f" +dependencies = [ + "lyon_algorithms", + "lyon_tessellation", +] + +[[package]] +name = "lyon_algorithms" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f13c9be19d257c7d37e70608ed858e8eab4b2afcea2e3c9a622e892acbf43c08" +dependencies = [ + "lyon_path", + "num-traits", +] + +[[package]] +name = "lyon_geom" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8af69edc087272df438b3ee436c4bb6d7c04aa8af665cfd398feae627dbd8570" +dependencies = [ + "arrayvec", + "euclid", + "num-traits", +] + +[[package]] +name = "lyon_path" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0047f508cd7a85ad6bad9518f68cce7b1bf6b943fb71f6da0ee3bc1e8cb75f25" +dependencies = [ + "lyon_geom", + "num-traits", +] + +[[package]] +name = "lyon_tessellation" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579d42360a4b09846eff2feef28f538696c7d6c7439bfa65874ff3cbe0951b2c" +dependencies = [ + "float_next_after", + "lyon_path", + "num-traits", +] + [[package]] name = "lzma-rs" version = "0.3.0" @@ -2992,6 +3064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -3632,6 +3705,25 @@ dependencies = [ "syn", ] +[[package]] +name = "pulldown-cmark" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14" +dependencies = [ + "bitflags 2.9.0", + "getopts", + "memchr", + "pulldown-cmark-escape", + "unicase", +] + +[[package]] +name = "pulldown-cmark-escape" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" + [[package]] name = "qoi" version = "0.4.1" @@ -3641,6 +3733,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "qrcode" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "166f136dfdb199f98186f3649cf7a0536534a61417a1a30221b492b4fb60ce3f" + [[package]] name = "quick-error" version = "2.0.1" 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, + } +} -- cgit v1.2.3