iced_aw/style/
time_picker.rs1#![allow(clippy::doc_markdown)]
5use super::{Status, StyleFn};
6use iced_core::{Background, Color, Theme};
7
8#[derive(Clone, Copy, Debug)]
10pub struct Style {
11 pub background: Background,
13
14 pub border_radius: f32,
16
17 pub border_width: f32,
19
20 pub border_color: Color,
22
23 pub text_color: Color,
25
26 pub clock_number_color: Color,
29
30 pub clock_number_background: Color,
33
34 pub clock_dots_color: Color,
37
38 pub clock_hand_color: Color,
41
42 pub clock_hand_width: f32,
45}
46
47pub trait Catalog {
49 type Class<'a>;
51
52 fn default<'a>() -> Self::Class<'a>;
54
55 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style;
57}
58
59impl Catalog for Theme {
60 type Class<'a> = StyleFn<'a, Self, Style>;
61
62 fn default<'a>() -> Self::Class<'a> {
63 Box::new(primary)
64 }
65
66 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
67 class(self, status)
68 }
69}
70
71#[must_use]
73pub fn primary(theme: &Theme, status: Status) -> Style {
74 let palette = theme.extended_palette();
75 let foreground = theme.palette();
76
77 let base = Style {
78 background: palette.background.base.color.into(),
79 border_radius: 15.0,
80 border_width: 1.0,
81 border_color: foreground.text,
82 text_color: foreground.text,
83 clock_number_color: foreground.text,
84 clock_number_background: palette.background.base.color,
85 clock_dots_color: [0.87, 0.87, 0.87].into(),
86 clock_hand_color: [0.87, 0.87, 0.87].into(),
87 clock_hand_width: 3.0,
88 };
89
90 match status {
91 Status::Focused => Style {
92 border_color: Color::from_rgb(0.5, 0.5, 0.5),
93 ..base
94 },
95 Status::Hovered => Style {
96 clock_number_color: palette.primary.weak.text,
97 clock_number_background: palette.primary.weak.color,
98 ..base
99 },
100 Status::Selected => Style {
101 clock_number_color: palette.primary.strong.text,
102 clock_number_background: palette.primary.strong.color,
103 ..base
104 },
105 _ => base,
106 }
107}