11use cosmic:: {
22 font:: Font ,
3- iced:: widget:: { self , container:: draw_background, rule:: FillMode } ,
3+ iced:: {
4+ widget:: { self , container:: draw_background, rule:: FillMode } ,
5+ Background ,
6+ } ,
47 iced_core:: {
58 alignment, event,
69 layout:: { Layout , Limits , Node } ,
@@ -16,30 +19,6 @@ use cosmic::{
1619
1720use super :: tab_text:: tab_text;
1821
19- /// The background color of the stack tab header.
20- pub ( super ) fn primary_container_color ( theme : & cosmic:: cosmic_theme:: Theme ) -> Color {
21- const PRIMARY_CONTAINER_DARK : Color = Color :: from_rgba ( 0.149 , 0.149 , 0.149 , 1.0 ) ;
22- const PRIMARY_CONTAINER_LIGHT : Color = Color :: from_rgba ( 0.894 , 0.894 , 0.894 , 1.0 ) ;
23-
24- if theme. is_dark {
25- PRIMARY_CONTAINER_DARK
26- } else {
27- PRIMARY_CONTAINER_LIGHT
28- }
29- }
30-
31- /// The background color for the selected stack tab.
32- pub ( super ) fn selected_state_color ( theme : & cosmic:: cosmic_theme:: Theme ) -> Color {
33- const SELECTED_STATE_DARK : Color = Color :: from_rgba ( 0.195 , 0.195 , 0.195 , 1.0 ) ;
34- const SELECTED_STATE_LIGHT : Color = Color :: from_rgba ( 0.8344 , 0.8344 , 0.8344 , 1.0 ) ;
35-
36- if theme. is_dark {
37- SELECTED_STATE_DARK
38- } else {
39- SELECTED_STATE_LIGHT
40- }
41- }
42-
4322#[ derive( Clone , Copy ) ]
4423pub ( super ) enum TabRuleTheme {
4524 ActiveActivated ,
@@ -79,27 +58,16 @@ pub(super) enum TabBackgroundTheme {
7958 Default ,
8059}
8160
82- impl TabBackgroundTheme {
83- /// Select the background color of stack tabs based on dark theme preference.
84- fn background_color ( self , theme : & theme:: Theme ) -> Color {
85- match self {
86- TabBackgroundTheme :: ActiveActivated | TabBackgroundTheme :: ActiveDeactivated => {
87- selected_state_color ( theme. cosmic ( ) )
88- }
89-
90- TabBackgroundTheme :: Default => primary_container_color ( theme. cosmic ( ) ) ,
91- }
92- }
93- }
94-
9561impl From < TabBackgroundTheme > for theme:: Container < ' _ > {
9662 fn from ( background_theme : TabBackgroundTheme ) -> Self {
9763 match background_theme {
9864 TabBackgroundTheme :: ActiveActivated => {
9965 Self :: custom ( move |theme| widget:: container:: Style {
10066 icon_color : Some ( Color :: from ( theme. cosmic ( ) . accent_text_color ( ) ) ) ,
10167 text_color : Some ( Color :: from ( theme. cosmic ( ) . accent_text_color ( ) ) ) ,
102- background : Some ( background_theme. background_color ( theme) . into ( ) ) ,
68+ background : Some ( Background :: Color (
69+ theme. cosmic ( ) . primary . component . selected . into ( ) ,
70+ ) ) ,
10371 border : Border {
10472 radius : 0.0 . into ( ) ,
10573 width : 0.0 ,
@@ -112,7 +80,9 @@ impl From<TabBackgroundTheme> for theme::Container<'_> {
11280 Self :: custom ( move |theme| widget:: container:: Style {
11381 icon_color : None ,
11482 text_color : None ,
115- background : Some ( background_theme. background_color ( theme) . into ( ) ) ,
83+ background : Some ( Background :: Color (
84+ theme. cosmic ( ) . primary . component . base . into ( ) ,
85+ ) ) ,
11686 border : Border {
11787 radius : 0.0 . into ( ) ,
11888 width : 0.0 ,
0 commit comments