mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add theming and a Windows 3.11 inspired theme.
This commit is contained in:
@@ -2,7 +2,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Marechai.App.Services;
|
||||
using Uno.Extensions.Navigation;
|
||||
using Uno.Extensions.Toolkit;
|
||||
|
||||
namespace Marechai.App.Presentation.ViewModels;
|
||||
|
||||
@@ -25,7 +27,7 @@ public partial class MainViewModel : ObservableObject
|
||||
private bool _sidebarContentVisible = true;
|
||||
|
||||
public MainViewModel(IStringLocalizer localizer, IOptions<AppConfig> appInfo, INavigator navigator,
|
||||
NewsViewModel newsViewModel)
|
||||
NewsViewModel newsViewModel, IColorThemeService colorThemeService, IThemeService themeService)
|
||||
{
|
||||
_navigator = navigator;
|
||||
_localizer = localizer;
|
||||
@@ -36,6 +38,9 @@ public partial class MainViewModel : ObservableObject
|
||||
|
||||
GoToSecond = new AsyncRelayCommand(GoToSecondView);
|
||||
|
||||
// Initialize color theme service with theme service
|
||||
_ = InitializeThemeServicesAsync(colorThemeService, themeService);
|
||||
|
||||
// Initialize localized strings
|
||||
InitializeLocalizedStrings();
|
||||
|
||||
@@ -81,6 +86,22 @@ public partial class MainViewModel : ObservableObject
|
||||
public ICommand LoginLogoutCommand { get; }
|
||||
public ICommand ToggleSidebarCommand { get; }
|
||||
|
||||
private async Task InitializeThemeServicesAsync(IColorThemeService colorThemeService, IThemeService themeService)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Wait for theme service to be ready
|
||||
await themeService.InitializeAsync();
|
||||
|
||||
// Set the theme service reference and reapply the saved theme
|
||||
colorThemeService.SetThemeService(themeService);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Silently fail - theme will work but without refresh on startup
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeLocalizedStrings()
|
||||
{
|
||||
LocalizedStrings = new Dictionary<string, string>
|
||||
|
||||
Reference in New Issue
Block a user