Let a Theme control the text_color of an application

This commit is contained in:
Héctor Ramón Jiménez 2022-05-26 01:10:26 +02:00
parent 3a820b45f3
commit 822a3cd04f
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 49 additions and 19 deletions

View file

@ -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)]