Skip to content

Commit 867949b

Browse files
committed
Feature: Replaced settings dialog with page
1 parent af76f0b commit 867949b

25 files changed

+244
-249
lines changed

src/Files.App/Actions/Open/OpenSettingsAction.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
namespace Files.App.Actions
77
{
8-
internal sealed partial class OpenSettingsAction : BaseUIAction, IAction
8+
internal sealed partial class OpenSettingsAction : ObservableObject, IAction
99
{
10-
private readonly IDialogService dialogService = Ioc.Default.GetRequiredService<IDialogService>();
11-
12-
private readonly SettingsDialogViewModel viewModel = new();
10+
private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>();
1311

1412
public string Label
1513
=> Strings.Settings.GetLocalizedResource();
@@ -22,11 +20,20 @@ public HotKey HotKey
2220

2321
public Task ExecuteAsync(object? parameter = null)
2422
{
25-
var dialog = dialogService.GetDialog(viewModel);
26-
if (parameter is not null && parameter is SettingsNavigationParams navParams)
27-
((SettingsDialog)dialog).NavigateTo(navParams);
28-
29-
return dialog.TryShowAsync();
23+
// Find index of existing Settings tab or open new one
24+
var existingTabIndex = MainPageViewModel.AppInstances
25+
.Select((tabItem, index) => new { TabItem = tabItem, Index = index })
26+
.FirstOrDefault(item =>
27+
item.TabItem.NavigationParameter.NavigationParameter is PaneNavigationArguments paneArgs &&
28+
(paneArgs.LeftPaneNavPathParam == "Settings" || paneArgs.RightPaneNavPathParam == "Settings"))
29+
?.Index ?? -1;
30+
31+
if (existingTabIndex >= 0)
32+
App.AppModel.TabStripSelectedIndex = existingTabIndex;
33+
else
34+
NavigationHelpers.OpenPathInNewTab("Settings", true);
35+
36+
return Task.CompletedTask;
3037
}
3138
}
32-
}
39+
}

src/Files.App/Data/Contracts/IShellPage.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public interface IShellPage : ITabBarItemContent, IMultiPaneInfo, IDisposable, I
7070
/// Navigates to the release notes page
7171
/// </summary>
7272
public void NavigateToReleaseNotes();
73+
74+
/// <summary>
75+
/// Navigates to the settings page
76+
/// </summary>
77+
public void NavigateToSettings();
7378

7479
void NavigateWithArguments(Type sourcePageType, NavigationArguments navArgs);
7580

src/Files.App/Dialogs/SettingsDialog.xaml.cs

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public static IHost ConfigureHost()
246246
.AddSingleton<NetworkLocationsWidgetViewModel>()
247247
.AddSingleton<FileTagsWidgetViewModel>()
248248
.AddSingleton<RecentFilesWidgetViewModel>()
249-
.AddSingleton<ReleaseNotesViewModel>()
249+
.AddSingleton<SettingsViewModel>()
250250
// Utilities
251251
.AddSingleton<QuickAccessManager>()
252252
.AddSingleton<StorageHistoryWrapper>()

src/Files.App/Helpers/Navigation/NavigationHelpers.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ private static async Task UpdateTabInfoAsync(TabBarItem tabItem, object navigati
159159
imageSource = new BitmapImage(new Uri(Constants.FluentIconsPaths.HomeIcon));
160160
else if (path == "ReleaseNotes")
161161
imageSource = new BitmapImage(new Uri(AppLifecycleHelper.AppIconPath));
162-
// TODO add settings page
163-
//else if (path == "Settings")
164-
// imageSource = new BitmapImage(new Uri(AppLifecycleHelper.AppIconPath));
162+
else if (path == "Settings")
163+
imageSource = new BitmapImage(new Uri(AppLifecycleHelper.AppIconPath));
165164
else if (WSLDistroManager.TryGetDistro(path, out WslDistroItem? wslDistro) && path.Equals(wslDistro.Path))
166165
imageSource = new BitmapImage(wslDistro.Icon);
167166
else
@@ -202,12 +201,11 @@ private static async Task UpdateTabInfoAsync(TabBarItem tabItem, object navigati
202201
tabLocationHeader = Strings.ReleaseNotes.GetLocalizedResource();
203202
iconSource.ImageSource = new BitmapImage(new Uri(AppLifecycleHelper.AppIconPath));
204203
}
205-
// TODO add settings page
206-
//else if (currentPath == "Settings")
207-
//{
208-
// tabLocationHeader = Strings.Settings.GetLocalizedResource();
209-
// iconSource.ImageSource = new BitmapImage(new Uri(AppLifecycleHelper.AppIconPath));
210-
//}
204+
else if (currentPath == "Settings")
205+
{
206+
tabLocationHeader = Strings.Settings.GetLocalizedResource();
207+
iconSource.ImageSource = new BitmapImage(new Uri(AppLifecycleHelper.AppIconPath));
208+
}
211209
else if (currentPath.Equals(Constants.UserEnvironmentPaths.DesktopPath, StringComparison.OrdinalIgnoreCase))
212210
tabLocationHeader = Strings.Desktop.GetLocalizedResource();
213211
else if (currentPath.Equals(Constants.UserEnvironmentPaths.DownloadsPath, StringComparison.OrdinalIgnoreCase))

src/Files.App/Services/App/AppDialogService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public DialogService()
2828
{ typeof(ElevateConfirmDialogViewModel), () => new ElevateConfirmDialog() },
2929
{ typeof(FileSystemDialogViewModel), () => new FilesystemOperationDialog() },
3030
{ typeof(DecompressArchiveDialogViewModel), () => new DecompressArchiveDialog() },
31-
{ typeof(SettingsDialogViewModel), () => new SettingsDialog() },
3231
{ typeof(CreateShortcutDialogViewModel), () => new CreateShortcutDialog() },
3332
{ typeof(ReorderSidebarItemsDialogViewModel), () => new ReorderSidebarItemsDialog() },
3433
{ typeof(AddBranchDialogViewModel), () => new AddBranchDialog() },

src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ public static async Task<List<PathBoxItem>> GetDirectoryPathComponentsWithDispla
142142
item.Title = Strings.Home.GetLocalizedResource();
143143
if (item.Path == "ReleaseNotes")
144144
item.Title = Strings.ReleaseNotes.GetLocalizedResource();
145-
// TODO add settings page
146-
//if (item.Path == "Settings")
147-
// item.Title = Strings.Settings.GetLocalizedResource();
145+
if (item.Path == "Settings")
146+
item.Title = Strings.Settings.GetLocalizedResource();
148147
else
149148
{
150149
BaseStorageFolder folder = await FilesystemTasks.Wrap(() => DangerousGetFolderFromPathAsync(item.Path));

src/Files.App/ViewModels/Dialogs/SettingsDialogViewModel.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace Files.App.ViewModels
5+
{
6+
public sealed partial class SettingsViewModel : ObservableObject
7+
{
8+
}
9+
}

src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -779,12 +779,11 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocali
779779
SavePathToHistory("ReleaseNotes");
780780
shellPage.NavigateToReleaseNotes();
781781
}
782-
// TODO add settings page
783-
//else if (normalizedInput.Equals("Settings", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals(Strings.Settings.GetLocalizedResource(), StringComparison.OrdinalIgnoreCase))
784-
//{
785-
// SavePathToHistory("Settings");
786-
// shellPage.NavigateToReleaseNotes();
787-
//}
782+
else if (normalizedInput.Equals("Settings", StringComparison.OrdinalIgnoreCase) || normalizedInput.Equals(Strings.Settings.GetLocalizedResource(), StringComparison.OrdinalIgnoreCase))
783+
{
784+
SavePathToHistory("Settings");
785+
shellPage.NavigateToReleaseNotes();
786+
}
788787
else
789788
{
790789
normalizedInput = StorageFileExtensions.GetResolvedPath(normalizedInput, isFtp);

0 commit comments

Comments
 (0)