Skip to content

Commit

Permalink
Merge pull request #206 from Redhawk18/main
Browse files Browse the repository at this point in the history
tab bar now follows iced's native theme and not hardcoded values
  • Loading branch information
Andrew Wheeler(Genusis) authored Feb 20, 2024
2 parents 2671392 + 2f62163 commit ed59455
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/style/tab_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ impl StyleSheet for Theme {

fn active(&self, style: &Self::Style, is_active: bool) -> Appearance {
let mut appearance = Appearance::default();
let palette = self.extended_palette();

match style {
TabBarStyles::Default => {
appearance.tab_label_background = if is_active {
Background::Color([0.9, 0.9, 0.9].into())
Background::Color(palette.primary.base.color)
} else {
Background::Color([0.87, 0.87, 0.87].into())
Background::Color(palette.background.strong.color)
};
appearance.text_color = palette.background.base.text;
}
TabBarStyles::Dark => {
appearance.tab_label_background = if is_active {
Expand Down Expand Up @@ -186,9 +188,14 @@ impl StyleSheet for Theme {
}

fn hovered(&self, style: &Self::Style, is_active: bool) -> Appearance {
let palette = self.extended_palette();
match style {
TabBarStyles::Default => Appearance {
tab_label_background: Background::Color([0.9, 0.9, 0.9].into()),
tab_label_background: Background::Color(if is_active {
palette.background.strong.color
} else {
palette.primary.strong.color
}),
..self.active(style, is_active)
},
TabBarStyles::Dark => Appearance {
Expand Down

0 comments on commit ed59455

Please sign in to comment.