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/scrollable.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/scrollable.rs | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/crates/material_theme/src/scrollable.rs b/crates/material_theme/src/scrollable.rs index ee739ba..341f047 100644 --- a/crates/material_theme/src/scrollable.rs +++ b/crates/material_theme/src/scrollable.rs @@ -1,4 +1,4 @@ -use iced_widget::core::{Border, Color, border}; +use iced_widget::core::{Background, Border, border}; use iced_widget::scrollable::{ Catalog, Rail, Scroller, Status, Style, StyleFn, }; @@ -7,8 +7,8 @@ use super::Theme; use super::container::surface_container; use super::utils::mix; use crate::utils::{ - DISABLED_CONTAINER_OPACITY, DISABLED_TEXT_OPACITY, HOVERED_LAYER_OPACITY, - PRESSED_LAYER_OPACITY, + HOVERED_LAYER_OPACITY, PRESSED_LAYER_OPACITY, disabled_container, + disabled_text, }; impl Catalog for Theme { @@ -24,30 +24,23 @@ impl Catalog for Theme { } pub fn default(theme: &Theme, status: Status) -> Style { - let colors = theme.colorscheme.surface; + let surface = theme.colors().surface; let active = Rail { background: None, scroller: Scroller { - color: colors.on_surface, + color: surface.on_surface, border: border::rounded(400), }, border: Border::default(), }; let disabled = Rail { - background: Some( - Color { - a: DISABLED_CONTAINER_OPACITY, - ..colors.on_surface - } - .into(), - ), + background: Some(Background::Color(disabled_container( + surface.on_surface, + ))), scroller: Scroller { - color: Color { - a: DISABLED_TEXT_OPACITY, - ..colors.on_surface - }, + color: disabled_text(surface.on_surface), border: border::rounded(400), }, ..active @@ -86,8 +79,8 @@ pub fn default(theme: &Theme, status: Status) -> Style { let hovered_rail = Rail { scroller: Scroller { color: mix( - colors.on_surface, - colors.color, + surface.on_surface, + surface.color, HOVERED_LAYER_OPACITY, ), border: border::rounded(400), @@ -122,8 +115,8 @@ pub fn default(theme: &Theme, status: Status) -> Style { let dragged_rail = Rail { scroller: Scroller { color: mix( - colors.on_surface, - colors.color, + surface.on_surface, + surface.color, PRESSED_LAYER_OPACITY, ), border: border::rounded(400), |
