New theme service that supports window backdrop.
This commit is contained in:
@@ -21,6 +21,7 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
|
||||
private readonly IDialogServiceBase _dialogService;
|
||||
private readonly IThemeService _themeService;
|
||||
private readonly INewThemeService _newThemeService;
|
||||
|
||||
private bool isPropChangeDisabled = false;
|
||||
|
||||
@@ -119,6 +120,21 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
}
|
||||
}
|
||||
|
||||
// Backdrop selection properties
|
||||
[ObservableProperty]
|
||||
public partial List<BackdropTypeWrapper> AvailableBackdropTypes { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial BackdropTypeWrapper SelectedBackdropType { get; set; }
|
||||
|
||||
partial void OnSelectedBackdropTypeChanged(BackdropTypeWrapper value)
|
||||
{
|
||||
if (!isPropChangeDisabled && value != null)
|
||||
{
|
||||
_newThemeService.CurrentBackdropType = value.BackdropType;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[RelayCommand]
|
||||
@@ -132,10 +148,12 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
public PersonalizationPageViewModel(IDialogServiceBase dialogService,
|
||||
IStatePersistanceService statePersistanceService,
|
||||
IThemeService themeService,
|
||||
INewThemeService newThemeService,
|
||||
IPreferencesService preferencesService)
|
||||
{
|
||||
_dialogService = dialogService;
|
||||
_themeService = themeService;
|
||||
_newThemeService = newThemeService;
|
||||
|
||||
StatePersistenceService = statePersistanceService;
|
||||
PreferencesService = preferencesService;
|
||||
@@ -198,7 +216,16 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
else
|
||||
SelectedAppColor = Colors.FirstOrDefault(a => a.Hex == currentAccentColor);
|
||||
|
||||
SelectedAppTheme = AppThemes.Find(a => a.Id == _themeService.CurrentApplicationThemeId);
|
||||
// Find selected theme, handling backward compatibility where theme ID might not exist
|
||||
var currentThemeId = _newThemeService.CurrentApplicationThemeId;
|
||||
SelectedAppTheme = currentThemeId.HasValue ? AppThemes.Find(a => a.Id == currentThemeId.Value) : null;
|
||||
|
||||
// Set the current backdrop, default to Mica if theme selected, None if custom theme
|
||||
var targetBackdropType = SelectedAppTheme != null && SelectedAppTheme.AppThemeType != AppThemeType.Custom
|
||||
? _newThemeService.CurrentBackdropType
|
||||
: WindowBackdropType.None;
|
||||
|
||||
SelectedBackdropType = AvailableBackdropTypes?.FirstOrDefault(x => x.BackdropType == targetBackdropType);
|
||||
}
|
||||
|
||||
[RequiresDynamicCode("AOT")]
|
||||
@@ -218,6 +245,9 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
|
||||
OnPropertyChanged(nameof(AppThemes));
|
||||
|
||||
// Initialize backdrop types
|
||||
AvailableBackdropTypes = _newThemeService.GetAvailableBackdropTypes();
|
||||
|
||||
InitializeColors();
|
||||
SetInitialValues();
|
||||
|
||||
@@ -281,7 +311,17 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
}
|
||||
else if (e.PropertyName == nameof(SelectedAppTheme))
|
||||
{
|
||||
_themeService.CurrentApplicationThemeId = SelectedAppTheme.Id;
|
||||
// Set the theme ID, can be null if no theme is selected
|
||||
_newThemeService.CurrentApplicationThemeId = SelectedAppTheme?.Id;
|
||||
|
||||
// When a custom/predefined theme is selected, set backdrop to None
|
||||
// When no theme is selected (system theme), keep current backdrop
|
||||
if (SelectedAppTheme != null)
|
||||
{
|
||||
isPropChangeDisabled = true;
|
||||
SelectedBackdropType = AvailableBackdropTypes?.FirstOrDefault(x => x.BackdropType == WindowBackdropType.None);
|
||||
isPropChangeDisabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user