Skip to content

Commit 1bd4265

Browse files
Implement theme switcher and fix some bugs
1 parent a499107 commit 1bd4265

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

src/InvLock/DataContexts/MainWindowDataContext.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using System.ComponentModel;
2-
using System.Reflection;
1+
using System.Reflection;
32

43
namespace InvLock.DataContexts;
54

6-
internal class MainWindowDataContext : INotifyPropertyChanged
5+
internal class MainWindowDataContext
76
{
87
#if DEBUG
98
public string Title => $"{App.AppName} - Dev {AppVersion}";

src/InvLock/MainWindow.xaml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</ui:HyperlinkButton>
7777
</Grid>
7878
</ui:CardControl.Header>
79-
<ComboBox Grid.Column="1" MinWidth="200" SelectedIndex="0">
79+
<ComboBox Grid.Column="1" MinWidth="200" SelectedIndex="0" SelectedValue="{Binding Settings.Theme}" SelectedValuePath="Content">
8080
<ComboBoxItem Content="Windows default" />
8181
<ComboBoxItem Content="Light" />
8282
<ComboBoxItem Content="Dark" />
@@ -129,7 +129,26 @@
129129
<ColumnDefinition Width="Auto" />
130130
</Grid.ColumnDefinitions>
131131
<TextBlock Grid.Column="0" Text="Report an issue or request a feature" />
132-
<ui:SymbolIcon Grid.Column="1" Symbol="Link24" />
132+
<StackPanel Grid.Column="1" Orientation="Horizontal">
133+
<ui:SymbolIcon Margin="0 0 6 0" Symbol="Link24" />
134+
<TextBlock Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="https://github.com/Stone-Red-Code/InvLock/issues"/>
135+
</StackPanel>
136+
</Grid>
137+
</ui:Anchor>
138+
139+
<Separator />
140+
141+
<ui:Anchor Margin="0" Padding="16" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="Transparent" CornerRadius="0" BorderThickness="0" NavigateUri="https://github.com/Stone-Red-Code/InvLock">
142+
<Grid>
143+
<Grid.ColumnDefinitions>
144+
<ColumnDefinition Width="*" />
145+
<ColumnDefinition Width="Auto" />
146+
</Grid.ColumnDefinitions>
147+
<TextBlock Grid.Column="0" Text="GitHub" />
148+
<StackPanel Grid.Column="1" Orientation="Horizontal">
149+
<ui:SymbolIcon Margin="0 0 6 0" Symbol="Link24" />
150+
<TextBlock Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="https://github.com/Stone-Red-Code/InvLock"/>
151+
</StackPanel>
133152
</Grid>
134153
</ui:Anchor>
135154

@@ -140,13 +159,9 @@
140159
<ColumnDefinition Width="*" />
141160
<ColumnDefinition Width="Auto" />
142161
</Grid.ColumnDefinitions>
143-
<TextBlock Grid.Column="0" Text="Clone repository" />
144-
<TextBlock Grid.Column="1" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="git clone https://github.com/Stone-Red-Code/InvLock" />
162+
<TextBlock Grid.Column="0" Text="Version" />
163+
<TextBlock Grid.Column="1" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="{Binding AppVersion}"/>
145164
</Grid>
146-
147-
<Separator />
148-
149-
<TextBlock Margin="16" Text="{Binding AppVersion, StringFormat='Version {0}'}" />
150165
</StackPanel>
151166
</ui:CardExpander>
152167
</StackPanel>

src/InvLock/Settings.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Runtime.CompilerServices;
44
using System.Text.Json;
55

6+
using Wpf.Ui.Appearance;
7+
68
namespace InvLock;
79

810
public class Settings : INotifyPropertyChanged
@@ -12,6 +14,7 @@ public class Settings : INotifyPropertyChanged
1214
private static readonly string settingsPath = Path.Combine(App.ApplicationDataPath, "settings.json");
1315
private bool hideWindows = false;
1416
private string lockText = "Lock Screen Active";
17+
private string theme = "Windows default";
1518

1619
private string unlockText = "Lock Screen Inactive";
1720

@@ -45,6 +48,30 @@ public string UnlockText
4548
}
4649
}
4750

51+
public string Theme
52+
{
53+
get => theme;
54+
set
55+
{
56+
theme = value;
57+
58+
if (value == "Windows default")
59+
{
60+
ApplicationThemeManager.ApplySystemTheme();
61+
}
62+
else if (value == "Light")
63+
{
64+
ApplicationThemeManager.Apply(ApplicationTheme.Light);
65+
}
66+
else if (value == "Dark")
67+
{
68+
ApplicationThemeManager.Apply(ApplicationTheme.Dark);
69+
}
70+
71+
OnPropertyChanged();
72+
}
73+
}
74+
4875
public static Settings Load()
4976
{
5077
if (File.Exists(settingsPath))

0 commit comments

Comments
 (0)