1+ use crate :: config:: Theme as ConfigTheme ;
12use iced:: border:: Radius ;
23use iced:: widget:: { button, container} ;
34use iced:: { Background , Border , Color , widget:: text_input} ;
4-
5- use crate :: config:: Theme as ConfigTheme ;
6-
75/// Helper: mix base color with white (simple “tint”)
86pub fn tint ( mut c : Color , amount : f32 ) -> Color {
97 c. r = c. r + ( 1.0 - c. r ) * amount;
108 c. g = c. g + ( 1.0 - c. g ) * amount;
119 c. b = c. b + ( 1.0 - c. b ) * amount;
1210 c
1311}
14-
1512/// Helper: apply alpha
1613pub fn with_alpha ( mut c : Color , a : f32 ) -> Color {
1714 c. a = a;
1815 c
1916}
20-
2117pub fn rustcast_text_input_style (
2218 theme : & ConfigTheme ,
2319 round_bottom_edges : bool ,
2420) -> text_input:: Style {
25- let base_bg = theme. bg_color ( ) ;
26- let surface = with_alpha ( tint ( base_bg, 0.06 ) , 1.0 ) ;
27-
28- let border_color = theme. text_color ( 1. ) ;
29-
21+ let base = theme. bg_color ( ) ;
22+ let focused = false ; // if you have state, pass it in and use it
23+ let surface = glass_surface ( base, focused) ;
3024 text_input:: Style {
3125 background : Background :: Color ( surface) ,
3226 border : Border {
33- color : border_color ,
34- width : 1. ,
27+ color : glass_border ( theme . text_color ( 1.0 ) , focused ) ,
28+ width : 1.0 ,
3529 radius : Radius :: new ( 15. ) . bottom ( if round_bottom_edges { 15. } else { 0. } ) ,
3630 } ,
37- icon : theme. text_color ( 0.7 ) ,
38- placeholder : theme. text_color ( 0.45 ) ,
31+ icon : theme. text_color ( 0.75 ) ,
32+ placeholder : theme. text_color ( 0.50 ) ,
3933 value : theme. text_color ( 1.0 ) ,
40- selection : theme. text_color ( 0.2 ) ,
34+ selection : with_alpha ( theme. text_color ( 1.0 ) , 0.20 ) ,
4135 }
4236}
43-
4437pub fn contents_style ( theme : & ConfigTheme ) -> container:: Style {
4538 container:: Style {
4639 background : None ,
@@ -53,62 +46,62 @@ pub fn contents_style(theme: &ConfigTheme) -> container::Style {
5346 ..Default :: default ( )
5447 }
5548}
56-
5749pub fn result_button_style ( theme : & ConfigTheme ) -> button:: Style {
5850 button:: Style {
5951 text_color : theme. text_color ( 1. ) ,
6052 background : Some ( Background :: Color ( theme. bg_color ( ) ) ) ,
6153 ..Default :: default ( )
6254 }
6355}
64-
6556pub fn result_row_container_style ( tile : & ConfigTheme , focused : bool ) -> container:: Style {
66- let base = tile. bg_color ( ) ;
67- let row_bg = if focused {
68- with_alpha ( tint ( base, 0.10 ) , 1.0 )
69- } else {
70- with_alpha ( tint ( base, 0.04 ) , 1.0 )
71- } ;
72-
7357 container:: Style {
74- background : Some ( Background :: Color ( row_bg ) ) ,
58+ background : Some ( Background :: Color ( glass_surface ( tile . bg_color ( ) , focused ) ) ) ,
7559 border : Border {
76- color : tile. text_color ( 1. ) ,
77- width : 0 .,
78- radius : Radius :: new ( 0. ) ,
60+ color : glass_border ( tile. text_color ( 1. ) , focused ) ,
61+ width : 1 .,
62+ radius : Radius :: new ( 0.0 ) ,
7963 } ,
64+ text_color : Some ( tile. text_color ( 1.0 ) ) ,
8065 ..Default :: default ( )
8166 }
8267}
83-
8468pub fn emoji_button_container_style ( tile_theme : & ConfigTheme , focused : bool ) -> container:: Style {
85- let base = tile_theme. bg_color ( ) ;
86- let row_bg = if focused {
87- with_alpha ( tint ( base, 0.10 ) , 1.0 )
88- } else {
89- with_alpha ( tint ( base, 0.04 ) , 1.0 )
90- } ;
9169 container:: Style {
92- background : Some ( Background :: Color ( row_bg) ) ,
93- text_color : Some ( tile_theme. text_color ( 1. ) ) ,
70+ background : Some ( Background :: Color ( glass_surface (
71+ tile_theme. bg_color ( ) ,
72+ focused,
73+ ) ) ) ,
74+ text_color : Some ( tile_theme. text_color ( 1.0 ) ) ,
9475 border : Border {
95- color : tile_theme. text_color ( 0.8 ) ,
96- width : 0. ,
97- radius : Radius :: new ( 10 ) ,
76+ color : glass_border ( tile_theme. text_color ( 1.0 ) , focused ) ,
77+ width : 1.0 ,
78+ radius : Radius :: new ( 10.0 ) ,
9879 } ,
9980 ..Default :: default ( )
10081 }
10182}
102-
10383pub fn emoji_button_style ( tile_theme : & ConfigTheme ) -> button:: Style {
84+ let base = tile_theme. bg_color ( ) ;
85+ let bg = with_alpha ( tint ( base, 0.10 ) , 0.28 ) ;
10486 button:: Style {
105- background : Some ( Background :: Color ( tint ( tile_theme . bg_color ( ) , 0.02 ) ) ) ,
106- text_color : tile_theme. text_color ( 1. ) ,
87+ background : Some ( Background :: Color ( bg ) ) ,
88+ text_color : tile_theme. text_color ( 1.0 ) ,
10789 border : Border {
108- color : tile_theme. text_color ( 0.8 ) ,
109- width : 0.1 ,
110- radius : Radius :: new ( 10 ) ,
90+ color : glass_border ( tile_theme. text_color ( 1.0 ) , false ) ,
91+ width : 1.0 ,
92+ radius : Radius :: new ( 10.0 ) ,
11193 } ,
11294 ..Default :: default ( )
11395 }
11496}
97+
98+ pub fn glass_surface ( base : Color , focused : bool ) -> Color {
99+ let t = if focused { 0.5 } else { 0.06 } ;
100+ let a = if focused { 0.5 } else { 0.22 } ;
101+ with_alpha ( tint ( base, t) , a)
102+ }
103+
104+ pub fn glass_border ( base_text : Color , focused : bool ) -> Color {
105+ let a = if focused { 0.35 } else { 0.22 } ;
106+ with_alpha ( base_text, a)
107+ }
0 commit comments