1+ use crate :: context:: AppContext ;
12use crate :: ui:: dpns_contested_names_screen:: DPNSSubscreen ;
2- use crate :: { app:: AppAction , ui:: RootScreenType } ;
3- use egui:: { Context , Frame , Margin , SidePanel } ;
3+ use crate :: ui:: RootScreenType ;
4+ use crate :: { app:: AppAction , ui} ;
5+ use egui:: { Color32 , Context , Frame , Margin , RichText , SidePanel } ;
46
5- pub fn add_dpns_subscreen_chooser_panel ( ctx : & Context ) -> AppAction {
7+ pub fn add_dpns_subscreen_chooser_panel ( ctx : & Context , app_context : & AppContext ) -> AppAction {
68 let mut action = AppAction :: None ;
79
810 let subscreens = vec ! [
@@ -11,6 +13,16 @@ pub fn add_dpns_subscreen_chooser_panel(ctx: &Context) -> AppAction {
1113 DPNSSubscreen :: Owned ,
1214 ] ;
1315
16+ let active_screen = match app_context. get_settings ( ) {
17+ Ok ( Some ( settings) ) => match settings. 1 {
18+ ui:: RootScreenType :: RootScreenDPNSActiveContests => DPNSSubscreen :: Active ,
19+ ui:: RootScreenType :: RootScreenDPNSPastContests => DPNSSubscreen :: Past ,
20+ ui:: RootScreenType :: RootScreenDPNSOwnedNames => DPNSSubscreen :: Owned ,
21+ _ => DPNSSubscreen :: Active ,
22+ } ,
23+ _ => DPNSSubscreen :: Active , // Fallback to Active screen if settings unavailable
24+ } ;
25+
1426 SidePanel :: left ( "dpns_subscreen_chooser_panel" )
1527 . default_width ( 250.0 )
1628 . frame (
@@ -25,8 +37,18 @@ pub fn add_dpns_subscreen_chooser_panel(ctx: &Context) -> AppAction {
2537 ui. add_space ( 10.0 ) ;
2638
2739 for subscreen in subscreens {
40+ let is_active = active_screen == subscreen;
41+ let ( button_color, text_color) = if is_active {
42+ ( Color32 :: from_rgb ( 0 , 128 , 255 ) , Color32 :: WHITE )
43+ } else {
44+ ( Color32 :: GRAY , Color32 :: WHITE )
45+ } ;
46+ let button = egui:: Button :: new (
47+ RichText :: new ( subscreen. display_name ( ) ) . color ( text_color) ,
48+ )
49+ . fill ( button_color) ;
2850 // Show the subscreen name as a clickable option
29- if ui. button ( subscreen . display_name ( ) ) . clicked ( ) {
51+ if ui. add ( button ) . clicked ( ) {
3052 // Handle navigation based on which subscreen is selected
3153 match subscreen {
3254 DPNSSubscreen :: Active => {
0 commit comments