Skip to content

Commit

Permalink
fix: style sheets not being applied to row, title and description wid…
Browse files Browse the repository at this point in the history
…gets
  • Loading branch information
friedow authored and oknozor committed Sep 25, 2023
1 parent c044ccf commit 632fc4c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/app/entries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ pub(crate) trait AsEntry<'a> {
.size(theme.title.font_size)
.into()]),
)
// .style(&theme.title)
.style(iced::theme::Container::Custom(Box::new(
&theme.title,
)))
.padding(theme.title.padding.to_iced_padding())
.width(theme.title.width)
.height(theme.title.height)
Expand All @@ -62,6 +64,9 @@ pub(crate) trait AsEntry<'a> {
container(row!(
text(description.as_ref()).size(theme.description.font_size)
))
.style(iced::theme::Container::Custom(Box::new(
&theme.description,
)))
.padding(theme.description.padding.to_iced_padding())
.width(theme.description.width)
.height(theme.description.height)
Expand All @@ -77,7 +82,9 @@ pub(crate) trait AsEntry<'a> {
};

Container::new(row.push(column))
// .style(theme.into())
.style(iced::theme::Container::Custom(Box::new(
theme,
)))
.padding(theme.padding.to_iced_padding())
.width(theme.width)
.height(theme.height)
Expand Down
18 changes: 17 additions & 1 deletion src/app/style/rows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use generic::GenericContainerStyle;
use iced::alignment::{Horizontal, Vertical};
use iced::Length;
use icon::IconStyle;
use iced_native::Background;
use iced_style::container::{Appearance, StyleSheet};
pub mod generic;
pub mod icon;

Expand Down Expand Up @@ -33,13 +35,27 @@ pub struct RowStyles {
pub category_icon: IconStyle,
}

impl StyleSheet for &RowStyles {
type Style = iced::Theme;

fn appearance(&self, _: &Self::Style) -> Appearance {
Appearance {
text_color: Some(self.color.into()),
background: Some(Background::Color(self.background.into())),
border_radius: self.border_radius,
border_width: self.border_width,
border_color: self.border_color.into(),
}
}
}

impl Default for RowStyles {
fn default() -> Self {
RowStyles {
width: Length::Fill,
height: Length::Shrink,
background: OnagreColor::DEFAULT_BACKGROUND,
color: OnagreColor::WHITE,
color: OnagreColor::DEFAULT_TEXT,
border_radius: 0.0,
border_width: 0.0,
padding: OnagrePadding::from(5),
Expand Down

0 comments on commit 632fc4c

Please sign in to comment.