From 53dc5464c2f595d1a32174598e280428d3265f15 Mon Sep 17 00:00:00 2001 From: pml68 Date: Tue, 8 Apr 2025 19:40:45 +0200 Subject: feat(material_theme): impl `menu::Catalog`, change `dialog::Catalog` impl --- material_theme/src/menu.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 material_theme/src/menu.rs (limited to 'material_theme/src/menu.rs') diff --git a/material_theme/src/menu.rs b/material_theme/src/menu.rs new file mode 100644 index 0000000..d1bebec --- /dev/null +++ b/material_theme/src/menu.rs @@ -0,0 +1,29 @@ +use iced_widget::core::{Background, border}; +use iced_widget::overlay::menu::{Catalog, Style, StyleFn}; + +use super::Theme; + +impl Catalog for Theme { + type Class<'a> = StyleFn<'a, Self>; + + fn default<'a>() -> ::Class<'a> { + Box::new(default) + } + + fn style(&self, class: &::Class<'_>) -> Style { + class(self) + } +} + +pub fn default(theme: &Theme) -> Style { + let surface = theme.colorscheme.surface; + let secondary = theme.colorscheme.secondary; + + Style { + border: border::rounded(4), + background: Background::Color(surface.surface_container.base), + text_color: surface.on_surface, + selected_background: Background::Color(secondary.secondary_container), + selected_text_color: secondary.on_secondary_container, + } +} -- cgit v1.2.3