use freya_core::prelude::*;
use crate::{
get_theme,
theming::hooks::get_theme_or_default,
typography::{
TypographyThemePartial,
TypographyThemePreference,
},
};
pub trait RectThemeExt {
fn theme_background(self) -> Self;
fn theme_color(self) -> Self;
}
impl RectThemeExt for Rect {
fn theme_background(self) -> Self {
let theme = get_theme_or_default();
self.background(theme.read().colors.background)
}
fn theme_color(self) -> Self {
let theme = get_theme_or_default();
self.color(theme.read().colors.text_primary)
}
}
pub trait LabelThemeExt {
fn theme_color(self) -> Self;
fn title(self) -> Self;
fn subtitle(self) -> Self;
fn body(self) -> Self;
fn caption(self) -> Self;
fn overline(self) -> Self;
}
fn typography() -> crate::typography::TypographyTheme {
get_theme!(
&None::<TypographyThemePartial>,
TypographyThemePreference,
"typography"
)
}
impl LabelThemeExt for Label {
fn theme_color(self) -> Self {
let theme = get_theme_or_default();
self.color(theme.read().colors.text_primary)
}
fn title(self) -> Self {
self.font_size(typography().title)
}
fn subtitle(self) -> Self {
self.font_size(typography().subtitle)
}
fn body(self) -> Self {
self.font_size(typography().body)
}
fn caption(self) -> Self {
self.font_size(typography().caption)
}
fn overline(self) -> Self {
self.font_size(typography().overline)
}
}
pub trait ParagraphThemeExt {
fn theme_color(self) -> Self;
}
impl ParagraphThemeExt for Paragraph {
fn theme_color(self) -> Self {
let theme = get_theme_or_default();
self.color(theme.read().colors.text_primary)
}
}