Skip to content

Commit

Permalink
Fix: Fixed issue where the adaptive layout toggle was always disabled (
Browse files Browse the repository at this point in the history
  • Loading branch information
gave92 authored Apr 14, 2023
1 parent eb9f89b commit e61ffa2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/Files.App/Contexts/DisplayPage/DisplayPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ internal class DisplayPageContext : ObservableObject, IDisplayPageContext
private readonly IPageContext context = Ioc.Default.GetRequiredService<IPageContext>();
private readonly IFoldersSettingsService settings = Ioc.Default.GetRequiredService<IFoldersSettingsService>();

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
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Contexts/DisplayPage/IDisplayPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit e61ffa2

Please sign in to comment.