Fix settings navigation and fix flicker on personalizaton nav.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
@@ -127,14 +126,6 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
[ObservableProperty]
|
||||
public partial BackdropTypeWrapper SelectedBackdropType { get; set; }
|
||||
|
||||
partial void OnSelectedBackdropTypeChanged(BackdropTypeWrapper value)
|
||||
{
|
||||
if (!isPropChangeDisabled && value != null)
|
||||
{
|
||||
_newThemeService.CurrentBackdropType = value.BackdropType;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[RelayCommand]
|
||||
@@ -218,12 +209,9 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
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);
|
||||
// Set the current backdrop from service - backdrop should be independent of theme selection
|
||||
var currentBackdropType = _newThemeService.CurrentBackdropType;
|
||||
SelectedBackdropType = AvailableBackdropTypes?.FirstOrDefault(x => x.BackdropType == currentBackdropType);
|
||||
}
|
||||
|
||||
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||
@@ -310,14 +298,11 @@ public partial class PersonalizationPageViewModel : CoreBaseViewModel
|
||||
// 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;
|
||||
}
|
||||
// Theme selection should not affect backdrop - they are independent settings
|
||||
}
|
||||
else if (e.PropertyName == nameof(SelectedBackdropType) && SelectedBackdropType != null)
|
||||
{
|
||||
_newThemeService.CurrentBackdropType = SelectedBackdropType.BackdropType;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -146,6 +146,9 @@ public class NewThemeService : INewThemeService
|
||||
get { return currentBackdropType; }
|
||||
set
|
||||
{
|
||||
// Only update if the backdrop type has actually changed
|
||||
if (currentBackdropType == value) return;
|
||||
|
||||
currentBackdropType = value;
|
||||
_configurationService.Set(WindowBackdropTypeKey, (int)value);
|
||||
|
||||
@@ -222,11 +225,14 @@ public class NewThemeService : INewThemeService
|
||||
_ => new MicaBackdrop() { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base }
|
||||
};
|
||||
|
||||
windowEx.SystemBackdrop = backdrop;
|
||||
if (windowEx.SystemBackdrop != backdrop)
|
||||
{
|
||||
windowEx.SystemBackdrop = backdrop;
|
||||
|
||||
BackdropChanged?.Invoke(this, backdropType);
|
||||
BackdropChanged?.Invoke(this, backdropType);
|
||||
|
||||
Debug.WriteLine($"Applied backdrop: {backdropType}");
|
||||
Debug.WriteLine($"Applied backdrop: {backdropType}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -284,11 +290,9 @@ public class NewThemeService : INewThemeService
|
||||
bool isDarkTheme = _underlyingThemeService.IsUnderlyingThemeDark();
|
||||
|
||||
// Set button colors based on theme
|
||||
// Background is always transparent for all buttons
|
||||
// Normal and inactive backgrounds are transparent, but hover/pressed have subtle backgrounds
|
||||
titleBar.ButtonBackgroundColor = Color.FromArgb(0, 0, 0, 0); // Transparent
|
||||
titleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 0, 0, 0); // Transparent
|
||||
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(0, 0, 0, 0); // Transparent
|
||||
titleBar.ButtonPressedBackgroundColor = Color.FromArgb(0, 0, 0, 0); // Transparent
|
||||
|
||||
if (isDarkTheme)
|
||||
{
|
||||
@@ -296,7 +300,11 @@ public class NewThemeService : INewThemeService
|
||||
titleBar.ButtonForegroundColor = Color.FromArgb(255, 255, 255, 255); // White
|
||||
titleBar.ButtonInactiveForegroundColor = Color.FromArgb(128, 255, 255, 255); // Semi-transparent white
|
||||
titleBar.ButtonHoverForegroundColor = Color.FromArgb(255, 255, 255, 255); // White
|
||||
titleBar.ButtonPressedForegroundColor = Color.FromArgb(200, 255, 255, 255); // Slightly dimmed white
|
||||
titleBar.ButtonPressedForegroundColor = Color.FromArgb(255, 255, 255, 255); // White
|
||||
|
||||
// Subtle hover and pressed backgrounds for dark theme
|
||||
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(20, 255, 255, 255); // Very subtle white overlay
|
||||
titleBar.ButtonPressedBackgroundColor = Color.FromArgb(40, 255, 255, 255); // Slightly more visible white overlay
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -304,7 +312,11 @@ public class NewThemeService : INewThemeService
|
||||
titleBar.ButtonForegroundColor = Color.FromArgb(255, 0, 0, 0); // Black
|
||||
titleBar.ButtonInactiveForegroundColor = Color.FromArgb(128, 0, 0, 0); // Semi-transparent black
|
||||
titleBar.ButtonHoverForegroundColor = Color.FromArgb(255, 0, 0, 0); // Black
|
||||
titleBar.ButtonPressedForegroundColor = Color.FromArgb(200, 0, 0, 0); // Slightly dimmed black
|
||||
titleBar.ButtonPressedForegroundColor = Color.FromArgb(255, 0, 0, 0); // Black
|
||||
|
||||
// Subtle hover and pressed backgrounds for light theme
|
||||
titleBar.ButtonHoverBackgroundColor = Color.FromArgb(20, 0, 0, 0); // Very subtle black overlay
|
||||
titleBar.ButtonPressedBackgroundColor = Color.FromArgb(40, 0, 0, 0); // Slightly more visible black overlay
|
||||
}
|
||||
|
||||
Debug.WriteLine($"Updated title bar button colors for {(isDarkTheme ? "dark" : "light")} theme");
|
||||
|
||||
@@ -32,6 +32,12 @@ public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract,
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
// Re-register message handlers after base.OnNavigatedTo unregisters all handlers
|
||||
WeakReferenceMessenger.Default.Register<BreadcrumbNavigationRequested>(this);
|
||||
WeakReferenceMessenger.Default.Register<BackBreadcrumNavigationRequested>(this);
|
||||
WeakReferenceMessenger.Default.Register<MergedInboxRenamed>(this);
|
||||
WeakReferenceMessenger.Default.Register<AccountUpdatedMessage>(this);
|
||||
|
||||
var initialRequest = new BreadcrumbNavigationRequested(Translator.MenuManageAccounts, WinoPage.AccountManagementPage);
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(initialRequest, true));
|
||||
|
||||
@@ -40,6 +46,16 @@ public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract,
|
||||
AccountPagesFrame.Navigate(accountManagementPageType, null, new SuppressNavigationTransitionInfo());
|
||||
}
|
||||
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
// Explicitly unregister our message handlers before base.OnNavigatingFrom calls UnregisterAll
|
||||
WeakReferenceMessenger.Default.Unregister<BreadcrumbNavigationRequested>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<BackBreadcrumNavigationRequested>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<MergedInboxRenamed>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<AccountUpdatedMessage>(this);
|
||||
|
||||
base.OnNavigatingFrom(e);
|
||||
}
|
||||
|
||||
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,9 @@ public sealed partial class SettingsPage : SettingsPageAbstract, IRecipient<Brea
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
// Re-register the breadcrumb navigation handler after base.OnNavigatedTo unregisters all handlers
|
||||
WeakReferenceMessenger.Default.Register<BreadcrumbNavigationRequested>(this);
|
||||
|
||||
SettingsFrame.Navigate(typeof(SettingOptionsPage), null, new SuppressNavigationTransitionInfo());
|
||||
|
||||
var initialRequest = new BreadcrumbNavigationRequested(Translator.MenuSettings, WinoPage.SettingOptionsPage);
|
||||
@@ -58,6 +61,14 @@ public sealed partial class SettingsPage : SettingsPageAbstract, IRecipient<Brea
|
||||
settingsHeader.Title = Translator.MenuSettings;
|
||||
}
|
||||
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
// Explicitly unregister our message handlers before base.OnNavigatingFrom calls UnregisterAll
|
||||
WeakReferenceMessenger.Default.Unregister<BreadcrumbNavigationRequested>(this);
|
||||
|
||||
base.OnNavigatingFrom(e);
|
||||
}
|
||||
|
||||
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
||||
{
|
||||
var pageType = ViewModel.NavigationService.GetPageType(message.PageType);
|
||||
|
||||
Reference in New Issue
Block a user