From 5a069cb25487791fe849e4b9b69c811486790bf2 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:22:17 -0400 Subject: [PATCH 01/15] Code Quality: Removed legacy SettingsViewModel --- .../Data/Contracts/IGeneralSettingsService.cs | 35 ++++++ .../Helpers/Application/AppLifecycleHelper.cs | 1 - .../Settings/GeneralSettingsService.cs | 42 ++++++++ src/Files.App/ViewModels/SettingsViewModel.cs | 100 ------------------ .../UserControls/SidebarViewModel.cs | 38 ++++++- 5 files changed, 113 insertions(+), 103 deletions(-) delete mode 100644 src/Files.App/ViewModels/SettingsViewModel.cs diff --git a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs index 275819589cbd..f1c4370d6fbd 100644 --- a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs +++ b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs @@ -114,37 +114,72 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty /// Gets or sets a value indicating if the favorites section should be visible. /// bool ShowPinnedSection { get; set; } + + /// + /// Gets or sets a value indicating if the favorites section should be expanded. + /// + bool IsPinnedSectionExpanded { get; set; } /// /// Gets or sets a value indicating if the library section should be visible. /// bool ShowLibrarySection { get; set; } + /// + /// Gets or sets a value indicating if the library section should be expanded. + /// + bool IsLibrarySectionExpanded { get; set; } + /// /// Gets or sets a value indicating if the drive section should be visible. /// bool ShowDrivesSection { get; set; } + /// + /// Gets or sets a value indicating if the drive section should be expanded. + /// + bool IsDriveSectionExpanded { get; set; } + /// /// Gets or sets a value indicating if the cloud drive section should be visible. /// bool ShowCloudDrivesSection { get; set; } + /// + /// Gets or sets a value indicating if the cloud drive section should be expanded. + /// + bool IsCloudDriveSectionExpanded { get; set; } + /// /// Gets or sets a value indicating if the network section should be visible. /// bool ShowNetworkSection { get; set; } + /// + /// Gets or sets a value indicating if the network section should be expanded. + /// + bool IsNetworkSectionExpanded { get; set; } + /// /// Gets or sets a value indicating if the wsl section should be visible. /// bool ShowWslSection { get; set; } + /// + /// Gets or sets a value indicating if the wsl section should be expanded. + /// + bool IsWslSectionExpanded { get; set; } + /// /// Gets or sets a value indicating if the tags section should be visible. /// bool ShowFileTagsSection { get; set; } + /// + /// Gets or sets a value indicating if the file tags section should be expanded. + /// + bool IsFileTagsSectionExpanded { get; set; } + /// /// Gets or sets a value indicating whether or not to move shell extensions into a sub menu. /// diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs index 84c4979b5385..59af809138c7 100644 --- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs +++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs @@ -205,7 +205,6 @@ public static IHost ConfigureHost() .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index bb5067887556..cfb6fb64c28d 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -143,42 +143,84 @@ public bool ShowPinnedSection set => Set(value); } + public bool IsPinnedSectionExpanded + { + get => Get(true); + set => Set(value); + } + public bool ShowLibrarySection { get => Get(false); set => Set(value); } + public bool IsLibrarySectionExpanded + { + get => Get(true); + set => Set(value); + } + public bool ShowDrivesSection { get => Get(true); set => Set(value); } + public bool IsDriveSectionExpanded + { + get => Get(true); + set => Set(value); + } + public bool ShowCloudDrivesSection { get => Get(true); set => Set(value); } + public bool IsCloudDriveSectionExpanded + { + get => Get(true); + set => Set(value); + } + public bool ShowNetworkSection { get => Get(true); set => Set(value); } + public bool IsNetworkSectionExpanded + { + get => Get(true); + set => Set(value); + } + public bool ShowWslSection { get => Get(true); set => Set(value); } + public bool IsWslSectionExpanded + { + get => Get(true); + set => Set(value); + + } public bool ShowFileTagsSection { get => Get(true); set => Set(value); } + public bool IsFileTagsSectionExpanded + { + get => Get(true); + set => Set(value); + } + public bool MoveShellExtensionsToSubMenu { get => Get(true); diff --git a/src/Files.App/ViewModels/SettingsViewModel.cs b/src/Files.App/ViewModels/SettingsViewModel.cs deleted file mode 100644 index 916fc9f92ab5..000000000000 --- a/src/Files.App/ViewModels/SettingsViewModel.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2024 Files Community -// Licensed under the MIT License. See the LICENSE. - -using System.Diagnostics.CodeAnalysis; -using System.Reflection; -using System.Runtime.CompilerServices; -using Windows.Storage; - -namespace Files.App.ViewModels -{ - [Obsolete("Do not use this class as Settings store anymore, settings have been merged to IUserSettingsService.")] - public sealed class SettingsViewModel : ObservableObject - { - private readonly ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; - - #region ReadAndSaveSettings - - public bool Set(TValue value, [CallerMemberName] string propertyName = null) - { - propertyName = - propertyName is not null && propertyName.StartsWith("set_", StringComparison.OrdinalIgnoreCase) ? - propertyName.Substring(4) : - propertyName; - - TValue originalValue = default; - - if (localSettings.Values.ContainsKey(propertyName)) - { - originalValue = Get(originalValue, propertyName); - - localSettings.Values[propertyName] = value; - if (!SetProperty(ref originalValue, value, propertyName)) - { - return false; - } - } - else - { - localSettings.Values[propertyName] = value; - } - - return true; - } - - public TValue Get<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] TValue>(TValue defaultValue, [CallerMemberName] string propertyName = null) - { - var name = propertyName ?? throw new ArgumentNullException(nameof(propertyName), "Cannot store property of unnamed."); - - name = - name.StartsWith("get_", StringComparison.OrdinalIgnoreCase) ? - propertyName.Substring(4) : - propertyName; - - if (localSettings.Values.ContainsKey(name)) - { - var value = localSettings.Values[name]; - - if (value is not TValue tValue) - { - if (value is IConvertible) - { - tValue = (TValue)Convert.ChangeType(value, typeof(TValue)); - } - else - { - var valueType = value.GetType(); - var tryParse = typeof(TValue).GetMethod("TryParse", BindingFlags.Instance | BindingFlags.Public); - - if (tryParse is null) - { - return default; - } - - var stringValue = value.ToString(); - tValue = default; - - var tryParseDelegate = - (TryParseDelegate)Delegate.CreateDelegate(valueType, tryParse, false); - - tValue = (tryParseDelegate?.Invoke(stringValue, out tValue) ?? false) ? tValue : default; - } - - // Put the corrected value in settings - Set(tValue, propertyName); - - return tValue; - } - return tValue; - } - - localSettings.Values[propertyName] = defaultValue; - - return defaultValue; - } - - private delegate bool TryParseDelegate(string inValue, out TValue parsedValue); - - #endregion ReadAndSaveSettings - } -} diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 815b2d5119c8..238840572ce9 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -397,7 +397,18 @@ await lib.CheckDefaultSaveFolderAccess() && } } - section.IsExpanded = Ioc.Default.GetRequiredService().Get(section.Text == "Pinned".GetLocalizedResource(), $"section:{section.Text.Replace('\\', '_')}"); + section.IsExpanded = section.Text switch + { + var text when text == "Pinned".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsPinnedSectionExpanded, + var text when text == "SidebarLibraries".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsLibrarySectionExpanded, + var text when text == "Drives".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsDriveSectionExpanded, + var text when text == "SidebarCloudDrives".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsCloudDriveSectionExpanded, + var text when text == "Network".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsNetworkSectionExpanded, + var text when text == "WSL".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsWslSectionExpanded, + var text when text == "FileTags".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded, + _ => false + }; + section.PropertyChanged += Section_PropertyChanged; } @@ -405,7 +416,30 @@ private void Section_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (sender is LocationItem section && e.PropertyName == nameof(section.IsExpanded)) { - Ioc.Default.GetRequiredService().Set(section.IsExpanded, $"section:{section.Text.Replace('\\', '_')}"); + switch (section.Text) + { + case var text when text == "Pinned".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsPinnedSectionExpanded = section.IsExpanded; + break; + case var text when text == "SidebarLibraries".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsLibrarySectionExpanded = section.IsExpanded; + break; + case var text when text == "Drives".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsDriveSectionExpanded = section.IsExpanded; + break; + case var text when text == "SidebarCloudDrives".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsCloudDriveSectionExpanded = section.IsExpanded; + break; + case var text when text == "Network".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsNetworkSectionExpanded = section.IsExpanded; + break; + case var text when text == "WSL".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsWslSectionExpanded = section.IsExpanded; + break; + case var text when text == "FileTags".GetLocalizedResource(): + UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded = section.IsExpanded; + break; + } } } From 112173f9eb70a969453574b89fbed1fad91e02bd Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 16:28:02 -0400 Subject: [PATCH 02/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index cfb6fb64c28d..c8e620cde591 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -193,7 +193,7 @@ public bool ShowNetworkSection public bool IsNetworkSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } From 47260f37676a8e3e5f94d559c9507b8512bf8291 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 16:41:24 -0400 Subject: [PATCH 03/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index c8e620cde591..9d33bbecc60a 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -175,7 +175,7 @@ public bool IsDriveSectionExpanded public bool ShowCloudDrivesSection { - get => Get(true); + get => Get(false); set => Set(value); } From a5ca9996d38ca411a58aeaec0a534c03a50f98c6 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 16:53:39 -0400 Subject: [PATCH 04/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 9d33bbecc60a..6b5a827b91b0 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -175,13 +175,13 @@ public bool IsDriveSectionExpanded public bool ShowCloudDrivesSection { - get => Get(false); + get => Get(true); set => Set(value); } public bool IsCloudDriveSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } From 18fce940607398ef3a9bdcf1d9d02f758e796b91 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:10:28 -0400 Subject: [PATCH 05/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 6b5a827b91b0..e35beecf93f1 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -157,7 +157,7 @@ public bool ShowLibrarySection public bool IsLibrarySectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -205,13 +205,13 @@ public bool ShowWslSection public bool IsWslSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } public bool ShowFileTagsSection { - get => Get(true); + get => Get(false); set => Set(value); } From d9f376e0147f9095614424478b754a584a085c85 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:26:25 -0400 Subject: [PATCH 06/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index e35beecf93f1..8f4335ce9778 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -169,7 +169,7 @@ public bool ShowDrivesSection public bool IsDriveSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -217,7 +217,7 @@ public bool ShowFileTagsSection public bool IsFileTagsSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } From 3d5187e88a3c61545690e6a33a638cb949bb83c7 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:40:27 -0400 Subject: [PATCH 07/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 8f4335ce9778..058b68ec669f 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -217,7 +217,7 @@ public bool ShowFileTagsSection public bool IsFileTagsSectionExpanded { - get => Get(false); + get => Get(true); set => Set(value); } From 24611c58bd0d1c70a80c42037e0f3885eb991b1e Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:55:12 -0400 Subject: [PATCH 08/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 058b68ec669f..bc3227ab0aef 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -181,7 +181,7 @@ public bool ShowCloudDrivesSection public bool IsCloudDriveSectionExpanded { - get => Get(false); + get => Get(true); set => Set(value); } From 95b781d9856e96c2afd7293ca0ec87acbc305641 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:11:28 -0400 Subject: [PATCH 09/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index bc3227ab0aef..7fe75fa5a73a 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -193,7 +193,7 @@ public bool ShowNetworkSection public bool IsNetworkSectionExpanded { - get => Get(false); + get => Get(true); set => Set(value); } From 4088513f2918d106c2e980efbd953f6061b4600a Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:24:15 -0400 Subject: [PATCH 10/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 7fe75fa5a73a..1609f13fdff9 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -205,7 +205,7 @@ public bool ShowWslSection public bool IsWslSectionExpanded { - get => Get(false); + get => Get(true); set => Set(value); } From 215e940f02138975d1e2d4af76b25ee21c4b95af Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:39:11 -0400 Subject: [PATCH 11/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 1609f13fdff9..b9c14bf7e286 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -157,7 +157,7 @@ public bool ShowLibrarySection public bool IsLibrarySectionExpanded { - get => Get(false); + get => Get(true); set => Set(value); } From fe560548ee96ce1965fb36848164d42e771ca6b4 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:59:01 -0400 Subject: [PATCH 12/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index b9c14bf7e286..8e501d88c5e6 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -211,7 +211,7 @@ public bool IsWslSectionExpanded } public bool ShowFileTagsSection { - get => Get(false); + get => Get(true); set => Set(value); } From c140181cfaf1ab523626a8a6cff3d6270415b0f4 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:16:09 -0400 Subject: [PATCH 13/15] Update GeneralSettingsService.cs --- src/Files.App/Services/Settings/GeneralSettingsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 8e501d88c5e6..cfb6fb64c28d 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -169,7 +169,7 @@ public bool ShowDrivesSection public bool IsDriveSectionExpanded { - get => Get(false); + get => Get(true); set => Set(value); } From f97c70de5fd9cf1fe65d8f5b72c570b465c83a97 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:31:04 -0400 Subject: [PATCH 14/15] Update SidebarViewModel.cs --- .../UserControls/SidebarViewModel.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 238840572ce9..39cf627be4d8 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -397,18 +397,6 @@ await lib.CheckDefaultSaveFolderAccess() && } } - section.IsExpanded = section.Text switch - { - var text when text == "Pinned".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsPinnedSectionExpanded, - var text when text == "SidebarLibraries".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsLibrarySectionExpanded, - var text when text == "Drives".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsDriveSectionExpanded, - var text when text == "SidebarCloudDrives".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsCloudDriveSectionExpanded, - var text when text == "Network".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsNetworkSectionExpanded, - var text when text == "WSL".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsWslSectionExpanded, - var text when text == "FileTags".GetLocalizedResource() => UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded, - _ => false - }; - section.PropertyChanged += Section_PropertyChanged; } @@ -482,6 +470,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("Pinned".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false); icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.StarIcon)); section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsPinnedSectionExpanded; break; } @@ -495,6 +484,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("SidebarLibraries".GetLocalizedResource(), sectionType, new ContextMenuOptions { IsLibrariesHeader = true, ShowHideSection = true }, false); iconIdex = Constants.ImageRes.Libraries; section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsLibrarySectionExpanded; break; } @@ -508,6 +498,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("Drives".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false); iconIdex = Constants.ImageRes.ThisPC; section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsDriveSectionExpanded; break; } @@ -521,6 +512,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("SidebarCloudDrives".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false); icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.CloudDriveIcon)); section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsCloudDriveSectionExpanded; break; } @@ -534,6 +526,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("Network".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false); iconIdex = Constants.ImageRes.Network; section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsNetworkSectionExpanded; break; } @@ -547,6 +540,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("WSL".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false); icon = new BitmapImage(new Uri(Constants.WslIconsPaths.GenericIcon)); section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsWslSectionExpanded; break; } @@ -560,6 +554,7 @@ private async Task CreateSectionAsync(SectionType sectionType) section = BuildSection("FileTags".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false); icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.FileTagsIcon)); section.IsHeader = true; + section.IsExpanded = UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded; break; } From 3c59651582f0e2164644994d8ff4d764c88c081f Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:35:15 -0400 Subject: [PATCH 15/15] Update GeneralSettingsService.cs --- .../Services/Settings/GeneralSettingsService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index cfb6fb64c28d..62febf805697 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -157,7 +157,7 @@ public bool ShowLibrarySection public bool IsLibrarySectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -169,7 +169,7 @@ public bool ShowDrivesSection public bool IsDriveSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -181,7 +181,7 @@ public bool ShowCloudDrivesSection public bool IsCloudDriveSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -193,7 +193,7 @@ public bool ShowNetworkSection public bool IsNetworkSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -205,7 +205,7 @@ public bool ShowWslSection public bool IsWslSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); } @@ -217,7 +217,7 @@ public bool ShowFileTagsSection public bool IsFileTagsSectionExpanded { - get => Get(true); + get => Get(false); set => Set(value); }