Add Style variant support to application::StyleSheet

This commit is contained in:
Héctor Ramón Jiménez 2022-07-08 20:07:33 +02:00
parent fa55dff61d
commit bb07d017e8
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
11 changed files with 148 additions and 43 deletions

View file

@ -48,17 +48,31 @@ impl Default for Theme {
}
}
impl application::StyleSheet for Theme {
fn background_color(&self) -> Color {
let palette = self.extended_palette();
#[derive(Debug, Clone, Copy)]
pub enum Application {
Default,
Custom(fn(Theme) -> application::Appearance),
}
palette.background.base.color
impl Default for Application {
fn default() -> Self {
Self::Default
}
}
fn text_color(&self) -> Color {
impl application::StyleSheet for Theme {
type Style = Application;
fn appearance(&self, style: Self::Style) -> application::Appearance {
let palette = self.extended_palette();
palette.background.base.text
match style {
Application::Default => application::Appearance {
background_color: palette.background.base.color,
text_color: palette.background.base.text,
},
Application::Custom(f) => f(*self),
}
}
}