Let a Theme control the text_color of an application
This commit is contained in:
parent
3a820b45f3
commit
822a3cd04f
5 changed files with 49 additions and 19 deletions
|
|
@ -31,12 +31,14 @@ impl Theme {
|
|||
|
||||
impl Default for Theme {
|
||||
fn default() -> Self {
|
||||
Self::Light
|
||||
Self::Dark
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Definition {
|
||||
fn background_color(&self) -> Color;
|
||||
|
||||
fn text_color(&self) -> Color;
|
||||
}
|
||||
|
||||
impl Definition for Theme {
|
||||
|
|
@ -45,6 +47,12 @@ impl Definition for Theme {
|
|||
|
||||
palette.background.base
|
||||
}
|
||||
|
||||
fn text_color(&self) -> Color {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
palette.background.text
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue