diff options
| author | pml68 <contact@pml68.dev> | 2025-04-28 10:56:49 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-28 10:56:49 +0200 |
| commit | dac7e82e0bff128097653fe05829b2d576fcdb2f (patch) | |
| tree | 6f36736e79eecd6904933c6876af1df58e6b605b /crates/material_theme/src/checkbox.rs | |
| parent | feat(material_theme): implement `image::Catalog` (under feature flag) (diff) | |
| download | iced-builder-dac7e82e0bff128097653fe05829b2d576fcdb2f.tar.gz | |
refactor(material_theme)!: make `Theme` an enum with `Custom` variant
Diffstat (limited to '')
| -rw-r--r-- | crates/material_theme/src/checkbox.rs | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/crates/material_theme/src/checkbox.rs b/crates/material_theme/src/checkbox.rs index ff038b0..7a3729c 100644 --- a/crates/material_theme/src/checkbox.rs +++ b/crates/material_theme/src/checkbox.rs @@ -2,7 +2,7 @@ use iced_widget::checkbox::{Catalog, Status, Style, StyleFn}; use iced_widget::core::{Background, Border, Color, border}; use super::Theme; -use crate::utils::{DISABLED_CONTAINER_OPACITY, HOVERED_LAYER_OPACITY, mix}; +use crate::utils::{HOVERED_LAYER_OPACITY, disabled_text, mix}; impl Catalog for Theme { type Class<'a> = StyleFn<'a, Self>; @@ -45,8 +45,8 @@ pub fn styled( } pub fn default(theme: &Theme, status: Status) -> Style { - let surface = theme.colorscheme.surface; - let primary = theme.colorscheme.primary; + let surface = theme.colors().surface; + let primary = theme.colors().primary; match status { Status::Active { is_checked } => styled( @@ -69,16 +69,10 @@ pub fn default(theme: &Theme, status: Status) -> Style { is_checked, ), Status::Disabled { is_checked } => styled( - Color { - a: DISABLED_CONTAINER_OPACITY, - ..surface.on_surface - }, + disabled_text(surface.on_surface), None, surface.color, - Color { - a: DISABLED_CONTAINER_OPACITY, - ..surface.on_surface - }, + disabled_text(surface.on_surface), Some(surface.on_surface), is_checked, ), @@ -86,8 +80,8 @@ pub fn default(theme: &Theme, status: Status) -> Style { } pub fn error(theme: &Theme, status: Status) -> Style { - let surface = theme.colorscheme.surface; - let error = theme.colorscheme.error; + let surface = theme.colors().surface; + let error = theme.colors().error; match status { Status::Active { is_checked } => styled( @@ -110,16 +104,10 @@ pub fn error(theme: &Theme, status: Status) -> Style { is_checked, ), Status::Disabled { is_checked } => styled( - Color { - a: DISABLED_CONTAINER_OPACITY, - ..surface.on_surface - }, + disabled_text(surface.on_surface), None, surface.color, - Color { - a: DISABLED_CONTAINER_OPACITY, - ..surface.on_surface - }, + disabled_text(surface.on_surface), Some(surface.on_surface), is_checked, ), |
