use iced::{Theme, theme::Palette, Color};
struct State {
user_primary_color: Color,
dark_mode: bool,
}
impl State {
fn create_theme(&self) -> Theme {
let palette = if self.dark_mode {
Palette {
background: Color::from_rgb(0.1, 0.1, 0.1),
text: Color::from_rgb(0.9, 0.9, 0.9),
primary: self.user_primary_color,
success: Color::from_rgb(0.2, 0.7, 0.3),
warning: Color::from_rgb(0.9, 0.7, 0.2),
danger: Color::from_rgb(0.8, 0.2, 0.2),
}
} else {
Palette {
background: Color::WHITE,
text: Color::BLACK,
primary: self.user_primary_color,
success: Color::from_rgb(0.1, 0.5, 0.2),
warning: Color::from_rgb(0.7, 0.5, 0.1),
danger: Color::from_rgb(0.7, 0.2, 0.2),
}
};
Theme::custom("User Theme", palette)
}
}
fn theme(state: &State) -> Theme {
state.create_theme()
}