Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
SettingsViewModel.cs
1using System.Windows.Input;
2using CommunityToolkit.Mvvm.ComponentModel;
3using CommunityToolkit.Mvvm.Input;
7
9
13public partial class SettingsViewModel : ObservableObject, INavigationAware
14{
18 [ObservableProperty]
20
21 private ICommand _setThemeCommand;
25 public ICommand SetThemeCommand => _setThemeCommand ?? (_setThemeCommand = new RelayCommand<string>(OnSetTheme));
26
27 private readonly IThemeSelectorService _themeSelectorService;
28
33 public SettingsViewModel(IThemeSelectorService themeSelectorService)
34 {
35 _themeSelectorService = themeSelectorService;
36 }
37
39 public void OnNavigatedTo(object parameter)
40 {
41 Theme = _themeSelectorService.GetCurrentTheme();
42 }
43
45 public void OnNavigatedFrom()
46 {
47 }
48
49 private void OnSetTheme(string themeName)
50 {
51 var theme = (AppTheme)Enum.Parse(typeof(AppTheme), themeName);
52 _themeSelectorService.SetTheme(theme);
53 }
54}
SettingsViewModel(IThemeSelectorService themeSelectorService)
Constructor of the settings view model.
void OnNavigatedTo(object parameter)
OnNavigatedTo method to handle navigation to this object.
ICommand SetThemeCommand
Command to change the app theme.
void OnNavigatedFrom()
OnNavigatedFrom method to handle navigation away from this object.
Interface for a service to manage the application theme selection.
Interface for objects that need to handle navigation events.
AppTheme
Enumeration for the application theme.
Definition AppTheme.cs:7