Couple aot fixes.

This commit is contained in:
Burak Kaan Köse
2025-10-03 21:13:26 +02:00
parent 229006c51d
commit 1c49b69332
8 changed files with 27 additions and 568 deletions
+5 -6
View File
@@ -6,6 +6,7 @@ using Serilog;
using Wino.Core.Domain;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Navigation;
namespace Wino.Core.ViewModels;
@@ -47,19 +48,17 @@ public partial class AboutPageViewModel : CoreBaseViewModel
PreferencesService = preferencesService;
}
[RequiresDynamicCode("AOT")]
[RequiresUnreferencedCode("AOT")]
protected override void OnActivated()
public override void OnNavigatedTo(NavigationMode mode, object parameters)
{
base.OnActivated();
base.OnNavigatedTo(mode, parameters);
PreferencesService.PreferenceChanged -= PreferencesChanged;
PreferencesService.PreferenceChanged += PreferencesChanged;
}
protected override void OnDeactivated()
public override void OnNavigatedFrom(NavigationMode mode, object parameters)
{
base.OnDeactivated();
base.OnNavigatedFrom(mode, parameters);
PreferencesService.PreferenceChanged -= PreferencesChanged;
}
@@ -9,6 +9,7 @@ using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Navigation;
using Wino.Core.Domain.Models.Personalization;
using Wino.Core.ViewModels.Data;
@@ -20,7 +21,6 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
public IPreferencesService PreferencesService { get; }
private readonly IDialogServiceBase _dialogService;
private readonly IThemeService _themeService;
private readonly INewThemeService _newThemeService;
private bool isPropChangeDisabled = false;
@@ -147,12 +147,10 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
public AsyncRelayCommand CreateCustomThemeCommand { get; set; }
public PersonalizationPageViewModel(IDialogServiceBase dialogService,
IStatePersistanceService statePersistanceService,
IThemeService themeService,
INewThemeService newThemeService,
IPreferencesService preferencesService)
{
_dialogService = dialogService;
_themeService = themeService;
_newThemeService = newThemeService;
StatePersistenceService = statePersistanceService;
@@ -193,7 +191,7 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
// Add system accent color as last item.
Colors.Add(new AppColorViewModel(_themeService.GetSystemAccentColorHex(), true));
Colors.Add(new AppColorViewModel(_newThemeService.GetSystemAccentColorHex(), true));
}
/// <summary>
@@ -201,10 +199,10 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
/// </summary>
private void SetInitialValues()
{
SelectedElementTheme = ElementThemes.Find(a => a.NativeTheme == _themeService.RootTheme);
SelectedElementTheme = ElementThemes.Find(a => a.NativeTheme == _newThemeService.RootTheme);
SelectedInfoDisplayMode = PreferencesService.MailItemDisplayMode;
var currentAccentColor = _themeService.AccentColor;
var currentAccentColor = _newThemeService.AccentColor;
bool isWindowsColor = string.IsNullOrEmpty(currentAccentColor);
@@ -228,11 +226,9 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
SelectedBackdropType = AvailableBackdropTypes?.FirstOrDefault(x => x.BackdropType == targetBackdropType);
}
[RequiresDynamicCode("AOT")]
[RequiresUnreferencedCode("AOT")]
protected override async void OnActivated()
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
{
base.OnActivated();
base.OnNavigatedTo(mode, parameters);
await InitializeSettingsAsync();
}
@@ -241,7 +237,7 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
{
Deactivate();
AppThemes = await _themeService.GetAvailableThemesAsync();
AppThemes = await _newThemeService.GetAvailableThemesAsync();
OnPropertyChanged(nameof(AppThemes));
@@ -254,11 +250,11 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
PropertyChanged -= PersonalizationSettingsUpdated;
PropertyChanged += PersonalizationSettingsUpdated;
_themeService.AccentColorChanged -= AccentColorChanged;
_themeService.ElementThemeChanged -= ElementThemeChanged;
_newThemeService.AccentColorChanged -= AccentColorChanged;
_newThemeService.ElementThemeChanged -= ElementThemeChanged;
_themeService.AccentColorChanged += AccentColorChanged;
_themeService.ElementThemeChanged += ElementThemeChanged;
_newThemeService.AccentColorChanged += AccentColorChanged;
_newThemeService.ElementThemeChanged += ElementThemeChanged;
}
private void AccentColorChanged(object sender, string e)
@@ -290,8 +286,8 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
{
PropertyChanged -= PersonalizationSettingsUpdated;
_themeService.AccentColorChanged -= AccentColorChanged;
_themeService.ElementThemeChanged -= ElementThemeChanged;
_newThemeService.AccentColorChanged -= AccentColorChanged;
_newThemeService.ElementThemeChanged -= ElementThemeChanged;
if (AppThemes != null)
{
@@ -307,7 +303,7 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
if (e.PropertyName == nameof(SelectedElementTheme) && SelectedElementTheme != null)
{
_themeService.RootTheme = SelectedElementTheme.NativeTheme;
_newThemeService.RootTheme = SelectedElementTheme.NativeTheme;
}
else if (e.PropertyName == nameof(SelectedAppTheme))
{
@@ -328,7 +324,7 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
if (e.PropertyName == nameof(SelectedInfoDisplayMode))
PreferencesService.MailItemDisplayMode = SelectedInfoDisplayMode;
else if (e.PropertyName == nameof(SelectedAppColor))
_themeService.AccentColor = SelectedAppColor.Hex;
_newThemeService.AccentColor = SelectedAppColor.Hex;
}
}
}