fix: Navigation button theming

This commit is contained in:
Michael Aaron Murphy 2022-11-01 18:13:00 +01:00
parent 4a899189e6
commit 702ea033af
2 changed files with 9 additions and 8 deletions

View file

@ -694,19 +694,15 @@ impl svg::StyleSheet for Theme {
/* /*
* TODO: Text * TODO: Text
*/ */
#[derive(Clone, Copy)] #[derive(Clone, Copy, Default)]
pub enum Text { pub enum Text {
Accent,
#[default]
Default, Default,
Color(Color), Color(Color),
Custom(fn(&Theme) -> text::Appearance), Custom(fn(&Theme) -> text::Appearance),
} }
impl Default for Text {
fn default() -> Self {
Self::Default
}
}
impl From<Color> for Text { impl From<Color> for Text {
fn from(color: Color) -> Self { fn from(color: Color) -> Self {
Text::Color(color) Text::Color(color)
@ -718,6 +714,9 @@ impl text::StyleSheet for Theme {
fn appearance(&self, style: Self::Style) -> text::Appearance { fn appearance(&self, style: Self::Style) -> text::Appearance {
match style { match style {
Text::Accent => text::Appearance {
color: Some(self.cosmic().accent.base.into())
},
Text::Default => Default::default(), Text::Default => Default::default(),
Text::Color(c) => text::Appearance { color: Some(c) }, Text::Color(c) => text::Appearance { color: Some(c) },
Text::Custom(f) => f(self), Text::Custom(f) => f(self),

View file

@ -69,6 +69,7 @@ impl<Message: Clone> Component<Message, Renderer> for HeaderBar<Message> {
fn view(&self, _state: &Self::State) -> Element<Self::Event> { fn view(&self, _state: &Self::State) -> Element<Self::Event> {
let nav_button = { let nav_button = {
let text = widget::text(&self.nav_title) let text = widget::text(&self.nav_title)
.style(theme::Text::Accent)
.vertical_alignment(Vertical::Center) .vertical_alignment(Vertical::Center)
.width(Length::Shrink) .width(Length::Shrink)
.height(Length::Fill); .height(Length::Fill);
@ -81,6 +82,7 @@ impl<Message: Clone> Component<Message, Renderer> for HeaderBar<Message> {
}, },
24, 24,
) )
.style(theme::Svg::Accent)
.width(Length::Units(24)) .width(Length::Units(24))
.height(Length::Fill); .height(Length::Fill);
@ -88,7 +90,7 @@ impl<Message: Clone> Component<Message, Renderer> for HeaderBar<Message> {
.padding(4) .padding(4)
.spacing(4) .spacing(4)
.apply(widget::button) .apply(widget::button)
.style(theme::Button::Primary) .style(theme::Button::Secondary)
.on_press(HeaderEvent::ToggleSidebar) .on_press(HeaderEvent::ToggleSidebar)
.apply(widget::container) .apply(widget::container)
.center_y() .center_y()