1010using CommunityToolkit . Mvvm . Input ;
1111using Google . Protobuf ;
1212using Microsoft . Extensions . DependencyInjection ;
13+ using Microsoft . UI ;
1314using Microsoft . UI . Dispatching ;
1415using Microsoft . UI . Xaml ;
1516using Microsoft . UI . Xaml . Controls ;
17+ using Microsoft . UI . Xaml . Media ;
18+ using Windows . UI ;
1619using Exception = System . Exception ;
1720
1821namespace Coder . Desktop . App . ViewModels ;
@@ -35,6 +38,8 @@ public partial class TrayWindowViewModel : ObservableObject
3538 [ NotifyPropertyChangedFor ( nameof ( ShowWorkspacesHeader ) ) ]
3639 [ NotifyPropertyChangedFor ( nameof ( ShowNoAgentsSection ) ) ]
3740 [ NotifyPropertyChangedFor ( nameof ( ShowAgentsSection ) ) ]
41+ [ NotifyPropertyChangedFor ( nameof ( SignOutButtonForeground ) ) ]
42+ [ NotifyPropertyChangedFor ( nameof ( SignOutButtonTooltip ) ) ]
3843 public partial VpnLifecycle VpnLifecycle { get ; set ; } = VpnLifecycle . Unknown ;
3944
4045 // This is a separate property because we need the switch to be 2-way.
@@ -78,12 +83,49 @@ public partial class TrayWindowViewModel : ObservableObject
7883
7984 [ ObservableProperty ] public partial string DashboardUrl { get ; set ; } = "https://coder.com" ;
8085
86+ public string SignOutButtonTooltip
87+ {
88+ get
89+ {
90+ return VpnLifecycle switch
91+ {
92+ VpnLifecycle . Stopped or VpnLifecycle . Unknown => "Sign out" ,
93+ _ => "Sign out (VPN must be stopped first)" ,
94+ } ;
95+ }
96+ }
97+
98+ private Brush ? _enabledForegroud ;
99+ private Brush ? _disabledForeground ;
100+
101+ public Brush SignOutButtonForeground
102+ {
103+ get {
104+ return VpnLifecycle switch
105+ {
106+ VpnLifecycle . Stopped or VpnLifecycle . Unknown => _enabledForegroud ?? new SolidColorBrush ( Colors . White ) ,
107+ _ => _disabledForeground ?? new SolidColorBrush ( Color . FromArgb ( 153 , 255 , 255 , 255 ) ) ,
108+ } ;
109+ }
110+ }
111+ public static Brush ? FindBrushByName ( string brushName )
112+ {
113+ if ( Application . Current . Resources . TryGetValue ( brushName , out var resource ) && resource is Brush brush )
114+ {
115+ return brush ;
116+ }
117+
118+ return null ; // Return null if the brush is not found
119+ }
120+
81121 public TrayWindowViewModel ( IServiceProvider services , IRpcController rpcController ,
82122 ICredentialManager credentialManager )
83123 {
84124 _services = services ;
85125 _rpcController = rpcController ;
86126 _credentialManager = credentialManager ;
127+ _disabledForeground = FindBrushByName ( "SystemControlForegroundBaseMediumBrush" ) ;
128+ _enabledForegroud = FindBrushByName ( "DefaultTextForegroundThemeBrush" ) ;
87129 }
88130
89131 public void Initialize ( DispatcherQueue dispatcherQueue )
0 commit comments