1//! Toggler style
2
3#![allow(clippy::module_name_repetitions)]
4
5use iced::widget::toggler::{Catalog, Status, Style};
6use iced::{Background, Color};
7
8use crate::StyleType;
9use crate::gui::styles::style_constants::BORDER_WIDTH;
10
11#[derive(Default)]
12pub enum TogglerType {
…lines 13–24 unchanged (12 lines)
25 ..colors.secondary
26 }
27 } else {
28 ext.buttons_color
29 };
30 Style {
31 background: Background::Color(bg_color),
32 background_border_width: BORDER_WIDTH,
33 background_border_color: bg_color,
34 foreground: Background::Color(colors.primary),
35 foreground_border_width: BORDER_WIDTH,
36 foreground_border_color: if is_active {
37 colors.secondary
38 } else {
39 Color::TRANSPARENT
40 },
41 text_color: None,
42 border_radius: None,
43 padding_ratio: 0.0,
44 }
45 }
46
47 #[allow(clippy::unused_self)]
48 fn hovered(&self, style: &StyleType, is_active: bool) -> Style {
49 let colors = style.get_palette();
…lines 50–53 unchanged (4 lines)
54 ..colors.secondary
55 }
56 } else {
57 ext.buttons_color
58 };
59 Style {
60 background: Background::Color(bg_color),
61 background_border_width: BORDER_WIDTH,
62 background_border_color: colors.secondary,
63 foreground: Background::Color(colors.primary),
64 foreground_border_width: BORDER_WIDTH,
65 foreground_border_color: if is_active {
66 colors.secondary
67 } else {
68 Color::TRANSPARENT
69 },
70 text_color: None,
71 border_radius: None,
72 padding_ratio: 0.0,
73 }
74 }
75}
76
77impl Catalog for StyleType {
78 type Class<'a> = TogglerType;
79
80 fn default<'a>() -> Self::Class<'a> {
81 Self::Class::default()
82 }
83
84 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
85 match status {
86 Status::Active { is_toggled } => class.active(self, is_toggled),
87 Status::Hovered { is_toggled } => class.hovered(self, is_toggled),
88 Status::Disabled { is_toggled } => class.active(self, is_toggled),
89 }
90 }
91}
92