From e61ffa25f49c2f4aefd4add8a5c9d6e2080f0406 Mon Sep 17 00:00:00 2001 From: Marco Gavelli Date: Fri, 14 Apr 2023 03:33:14 +0200 Subject: [PATCH] Fix: Fixed issue where the adaptive layout toggle was always disabled (#12049) --- .../Contexts/DisplayPage/DisplayPageContext.cs | 14 ++++---------- .../Contexts/DisplayPage/IDisplayPageContext.cs | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Files.App/Contexts/DisplayPage/DisplayPageContext.cs b/src/Files.App/Contexts/DisplayPage/DisplayPageContext.cs index 0d9f0c1a1aae..cb6ea328859b 100644 --- a/src/Files.App/Contexts/DisplayPage/DisplayPageContext.cs +++ b/src/Files.App/Contexts/DisplayPage/DisplayPageContext.cs @@ -14,12 +14,7 @@ internal class DisplayPageContext : ObservableObject, IDisplayPageContext private readonly IPageContext context = Ioc.Default.GetRequiredService(); private readonly IFoldersSettingsService settings = Ioc.Default.GetRequiredService(); - private bool isLayoutAdaptiveEnabled = false; - public bool IsLayoutAdaptiveEnabled - { - get => isLayoutAdaptiveEnabled; - set => settings.SyncFolderPreferencesAcrossDirectories = value; - } + public bool IsLayoutAdaptiveEnabled => !settings.SyncFolderPreferencesAcrossDirectories; private LayoutTypes layoutType = LayoutTypes.None; public LayoutTypes LayoutType @@ -182,9 +177,8 @@ private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e { if (e.PropertyName is nameof(IFoldersSettingsService.SyncFolderPreferencesAcrossDirectories)) { - bool isEnabled = settings.SyncFolderPreferencesAcrossDirectories; - if (SetProperty(ref isLayoutAdaptiveEnabled, isEnabled, nameof(IsLayoutAdaptiveEnabled))) - SetProperty(ref layoutType, GetLayoutType(), nameof(LayoutType)); + OnPropertyChanged(nameof(IsLayoutAdaptiveEnabled)); + SetProperty(ref layoutType, GetLayoutType(), nameof(LayoutType)); } } @@ -216,7 +210,7 @@ private LayoutTypes GetLayoutType() if (viewModel is null) return LayoutTypes.None; - bool isAdaptive = isLayoutAdaptiveEnabled && viewModel.IsAdaptiveLayoutEnabled && !viewModel.IsLayoutModeFixed; + bool isAdaptive = IsLayoutAdaptiveEnabled && viewModel.IsAdaptiveLayoutEnabled && !viewModel.IsLayoutModeFixed; if (isAdaptive) return LayoutTypes.Adaptive; diff --git a/src/Files.App/Contexts/DisplayPage/IDisplayPageContext.cs b/src/Files.App/Contexts/DisplayPage/IDisplayPageContext.cs index 0c4a5a19f514..c0d646a91992 100644 --- a/src/Files.App/Contexts/DisplayPage/IDisplayPageContext.cs +++ b/src/Files.App/Contexts/DisplayPage/IDisplayPageContext.cs @@ -5,7 +5,7 @@ namespace Files.App.Contexts { public interface IDisplayPageContext : INotifyPropertyChanging, INotifyPropertyChanged { - bool IsLayoutAdaptiveEnabled { get; set; } + bool IsLayoutAdaptiveEnabled { get; } LayoutTypes LayoutType { get; set; } SortOption SortOption { get; set; }