Skip to content

Commit e4c6ec1

Browse files
0x5bfayaira2
andcommitted
Wrap up
Co-Authored-By: Yair <[email protected]>
1 parent 6a80bcd commit e4c6ec1

File tree

6 files changed

+55
-41
lines changed

6 files changed

+55
-41
lines changed

src/Files.App.Controls/Omnibar/Omnibar.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void ChangeMode(OmnibarMode modeToExpand, bool shouldFocus = false, bool
188188

189189
public bool TryToggleIsSuggestionsPopupOpen(bool wantToOpen)
190190
{
191-
if (wantToOpen && (!IsFocused || CurrentSelectedMode?.SuggestionItemsSource is null))
191+
if (wantToOpen && (!IsFocused || CurrentSelectedMode?.SuggestionItemsSource is null || (CurrentSelectedMode?.SuggestionItemsSource is IList collection && collection.Count is 0)))
192192
return false;
193193

194194
_textBoxSuggestionsPopup.IsOpen = wantToOpen;

src/Files.App/Strings/en-US/Resources.resw

+9
Original file line numberDiff line numberDiff line change
@@ -4202,7 +4202,16 @@
42024202
<data name="EmptyShelfText" xml:space="preserve">
42034203
<value>Drag files or folders here to interact with them across different tabs</value>
42044204
</data>
4205+
<data name="CommandPalette" xml:space="preserve">
4206+
<value>Command palette</value>
4207+
</data>
42054208
<data name="OmnibarPathModeTextPlaceholder" xml:space="preserve">
42064209
<value>Enter a path to navigate to...</value>
42074210
</data>
4211+
<data name="OmnibarCommandPaletteModeTextPlaceholder" xml:space="preserve">
4212+
<value>Find features and commands...</value>
4213+
</data>
4214+
<data name="OmnibarSearchModeTextPlaceholder" xml:space="preserve">
4215+
<value>Search for files and folders...</value>
4216+
</data>
42084217
</root>

src/Files.App/UserControls/NavigationToolbar.xaml

+6-11
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
AutomationProperties.FullDescription="{x:Bind Commands.NavigateBack.Description, Mode=OneWay}"
113113
AutomationProperties.Name="{x:Bind Commands.NavigateBack.Label, Mode=OneWay}"
114114
Command="{x:Bind Commands.NavigateBack, Mode=OneWay}"
115-
IsEnabled="{x:Bind Commands.NavigateBack.IsExecutable, Mode=OneWay}"
116115
Style="{StaticResource AddressToolbarButtonStyle}"
117116
ToolTipService.ToolTip="{x:Bind Commands.NavigateBack.LabelWithHotKey, Mode=OneWay}">
118117
<FontIcon FontSize="14" Glyph="{x:Bind Commands.NavigateBack.Glyph.BaseGlyph, Mode=OneTime}" />
@@ -142,7 +141,6 @@
142141
AutomationProperties.FullDescription="{x:Bind Commands.NavigateForward.Description, Mode=OneWay}"
143142
AutomationProperties.Name="{x:Bind Commands.NavigateForward.Label, Mode=OneWay}"
144143
Command="{x:Bind Commands.NavigateForward, Mode=OneWay}"
145-
IsEnabled="{x:Bind Commands.NavigateForward.IsExecutable, Mode=OneWay}"
146144
Style="{StaticResource AddressToolbarButtonStyle}"
147145
ToolTipService.ToolTip="{x:Bind Commands.NavigateForward.LabelWithHotKey, Mode=OneWay}">
148146
<FontIcon FontSize="14" Glyph="{x:Bind Commands.NavigateForward.Glyph.BaseGlyph, Mode=OneTime}" />
@@ -172,7 +170,6 @@
172170
AutomationProperties.FullDescription="{x:Bind Commands.NavigateUp.Description, Mode=OneWay}"
173171
AutomationProperties.Name="{x:Bind Commands.NavigateUp.Label, Mode=OneWay}"
174172
Command="{x:Bind Commands.NavigateUp, Mode=OneWay}"
175-
IsEnabled="{x:Bind Commands.NavigateUp.IsExecutable, Mode=OneWay}"
176173
Style="{StaticResource AddressToolbarButtonStyle}"
177174
ToolTipService.ToolTip="{x:Bind Commands.NavigateUp.LabelWithHotKey, Mode=OneWay}">
178175
<FontIcon FontSize="14" Glyph="{x:Bind Commands.NavigateUp.Glyph.BaseGlyph, Mode=OneTime}" />
@@ -184,7 +181,6 @@
184181
AccessKeyInvoked="Button_AccessKeyInvoked"
185182
AutomationProperties.Name="{x:Bind Commands.RefreshItems.Label, Mode=OneWay}"
186183
Command="{x:Bind Commands.RefreshItems, Mode=OneWay}"
187-
IsEnabled="{x:Bind Commands.RefreshItems.IsExecutable, Mode=OneWay}"
188184
Style="{StaticResource AddressToolbarButtonStyle}"
189185
ToolTipService.ToolTip="{x:Bind Commands.RefreshItems.LabelWithHotKey, Mode=OneWay}">
190186
<FontIcon FontSize="14" Glyph="{x:Bind Commands.RefreshItems.Glyph.BaseGlyph, Mode=OneTime}" />
@@ -197,7 +193,6 @@
197193
AccessKeyInvoked="Button_AccessKeyInvoked"
198194
AutomationProperties.Name="{x:Bind Commands.NavigateHome.Label, Mode=OneWay}"
199195
Command="{x:Bind Commands.NavigateHome, Mode=OneWay}"
200-
IsEnabled="{x:Bind Commands.NavigateHome.IsExecutable, Mode=OneWay}"
201196
Style="{StaticResource AddressToolbarButtonStyle}"
202197
ToolTipService.ToolTip="{x:Bind Commands.NavigateHome.LabelWithHotKey, Mode=OneWay}">
203198
<FontIcon FontSize="14" Glyph="{x:Bind Commands.NavigateHome.Glyph.BaseGlyph, Mode=OneTime}" />
@@ -350,10 +345,10 @@
350345
IconOnActive="{controls:ThemedIconMarkup Style={StaticResource App.ThemedIcons.Omnibar.Path}, IsFilled=True}"
351346
IconOnInactive="{controls:ThemedIconMarkup Style={StaticResource App.ThemedIcons.Omnibar.Path}, IconType=Outline}"
352347
IsDefault="True"
353-
ModeName="Path"
348+
ModeName="{helpers:ResourceString Name=Path}"
354349
PlaceholderText="{helpers:ResourceString Name=OmnibarPathModeTextPlaceholder}"
355350
SuggestionItemsSource="{x:Bind ViewModel.PathModeSuggestionItems, Mode=OneWay}"
356-
Text="{x:Bind ViewModel.OmnibarPathModeText, Mode=TwoWay}"
351+
Text="{x:Bind ViewModel.PathText, Mode=TwoWay}"
357352
TextMemberPath="Path">
358353
<controls:OmnibarMode.ContentOnInactive>
359354
<controls:BreadcrumbBar
@@ -385,8 +380,8 @@
385380
<controls:OmnibarMode
386381
IconOnActive="{controls:ThemedIconMarkup Style={StaticResource App.ThemedIcons.Omnibar.Commands}, IsFilled=True}"
387382
IconOnInactive="{controls:ThemedIconMarkup Style={StaticResource App.ThemedIcons.Omnibar.Commands}, IconType=Outline}"
388-
ModeName="Palette"
389-
PlaceholderText="Enter a palette command...">
383+
ModeName="{helpers:ResourceString Name=CommandPalette}"
384+
PlaceholderText="{helpers:ResourceString Name=OmnibarCommandPaletteModeTextPlaceholder}">
390385
<!--<controls:OmnibarMode.SuggestionItemTemplate>
391386
<DataTemplate x:DataType="data:OmnibarPaletteSuggestionItem">
392387
<Grid Height="48" ColumnSpacing="12">
@@ -427,8 +422,8 @@
427422
<controls:OmnibarMode
428423
IconOnActive="{controls:ThemedIconMarkup Style={StaticResource App.ThemedIcons.Omnibar.Search}, IsFilled=True}"
429424
IconOnInactive="{controls:ThemedIconMarkup Style={StaticResource App.ThemedIcons.Omnibar.Search}, IconType=Outline}"
430-
ModeName="Search"
431-
PlaceholderText="Enter a search query..." />
425+
ModeName="{helpers:ResourceString Name=Search}"
426+
PlaceholderText="{helpers:ResourceString Name=OmnibarSearchModeTextPlaceholder}" />
432427

433428
</controls:Omnibar>
434429

src/Files.App/UserControls/NavigationToolbar.xaml.cs

+24-9
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,17 @@ private async void Omnibar_TextChanged(Omnibar sender, OmnibarTextChangedEventAr
273273

274274
private async void BreadcrumbBar_ItemClicked(Controls.BreadcrumbBar sender, Controls.BreadcrumbBarItemClickedEventArgs args)
275275
{
276-
// Navigation to the current folder should not happen
277-
if (args.Index == ViewModel.PathComponents.Count - 1 ||
278-
ViewModel.PathComponents[args.Index].Path is not { } path)
279-
return;
280-
281276
if (args.IsRootItem)
282277
{
283278
await ViewModel.HandleItemNavigationAsync("Home");
284279
return;
285280
}
286281

282+
// Navigation to the current folder should not happen
283+
if (args.Index == ViewModel.PathComponents.Count - 1 ||
284+
ViewModel.PathComponents[args.Index].Path is not { } path)
285+
return;
286+
287287
await ViewModel.HandleFolderNavigationAsync(path);
288288
}
289289

@@ -292,8 +292,9 @@ private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Breadc
292292
if (e.IsRootItem)
293293
{
294294
IHomeFolder homeFolder = new HomeFolder();
295+
IContentPageContext contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
295296

296-
e.Flyout.Items.Add(new MenuFlyoutHeaderItem() { Text = "Quick access" });
297+
e.Flyout.Items.Add(new MenuFlyoutHeaderItem() { Text = Strings.QuickAccess.GetLocalizedResource() });
297298

298299
await foreach (var storable in homeFolder.GetQuickAccessFolderAsync())
299300
{
@@ -303,7 +304,8 @@ private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Breadc
303304
var flyoutItem = new MenuFlyoutItem()
304305
{
305306
Text = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_PARENTRELATIVEFORUI),
306-
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
307+
DataContext = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_DESKTOPABSOLUTEPARSING),
308+
Icon = new FontIcon() { Glyph = "\uE8B7" }, // As a placeholder
307309
};
308310

309311
e.Flyout.Items.Add(flyoutItem);
@@ -312,9 +314,15 @@ private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Breadc
312314
flyoutItem.Icon = new ImageIcon() { Source = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => thumbnailData.ToBitmapAsync(), Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal) };
313315

314316
windowsStorable.Dispose();
317+
318+
flyoutItem.Click += (sender, args) =>
319+
{
320+
// NOTE: We should not pass a path string but pass the storable object itself in the future.
321+
contentPageContext.ShellPage!.NavigateToPath((string)flyoutItem.DataContext);
322+
};
315323
}
316324

317-
e.Flyout.Items.Add(new MenuFlyoutHeaderItem() { Text = "Drives" });
325+
e.Flyout.Items.Add(new MenuFlyoutHeaderItem() { Text = Strings.Drives.GetLocalizedResource() });
318326

319327
await foreach (var storable in homeFolder.GetLogicalDrivesAsync())
320328
{
@@ -324,7 +332,8 @@ private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Breadc
324332
var flyoutItem = new MenuFlyoutItem()
325333
{
326334
Text = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_PARENTRELATIVEFORUI),
327-
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
335+
DataContext = windowsStorable.GetDisplayName(Windows.Win32.UI.Shell.SIGDN.SIGDN_DESKTOPABSOLUTEPARSING),
336+
Icon = new FontIcon() { Glyph = "\uE8B7" }, // As a placeholder
328337
};
329338

330339
e.Flyout.Items.Add(flyoutItem);
@@ -333,6 +342,12 @@ private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Breadc
333342
flyoutItem.Icon = new ImageIcon() { Source = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => thumbnailData.ToBitmapAsync(), Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal) };
334343

335344
windowsStorable.Dispose();
345+
346+
flyoutItem.Click += (sender, args) =>
347+
{
348+
// NOTE: We should not pass a path string but pass the storable object itself in the future.
349+
contentPageContext.ShellPage!.NavigateToPath((string)flyoutItem.DataContext);
350+
};
336351
}
337352

338353
return;

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

+14-18
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,19 @@ public bool IsSearchBoxVisible
206206
}
207207
}
208208

209+
// SetProperty doesn't seem to properly notify the binding in path bar
209210
private string? _PathText;
210-
[Obsolete("Remove once Omnibar goes out of experimental.")]
211211
public string? PathText
212212
{
213213
get => _PathText;
214214
set
215215
{
216-
if (SetProperty(ref _PathText, value))
217-
OnPropertyChanged(nameof(OmnibarPathModeText));
216+
_PathText = value;
217+
OnPropertyChanged(nameof(PathText));
218218
}
219219
}
220220

221+
221222
private bool _IsOmnibarFocused;
222223
public bool IsOmnibarFocused
223224
{
@@ -231,7 +232,7 @@ public bool IsOmnibarFocused
231232
switch(OmnibarCurrentSelectedModeName)
232233
{
233234
case OmnibarPathModeName:
234-
OmnibarPathModeText =
235+
PathText =
235236
string.IsNullOrEmpty(ContentPageContext.ShellPage?.ShellViewModel?.WorkingDirectory)
236237
? Constants.UserEnvironmentPaths.HomePath
237238
: ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory;
@@ -253,9 +254,6 @@ public bool IsOmnibarFocused
253254
private string _OmnibarCurrentSelectedModeName;
254255
public string OmnibarCurrentSelectedModeName { get => _OmnibarCurrentSelectedModeName; set => SetProperty(ref _OmnibarCurrentSelectedModeName, value); }
255256

256-
private string _OmnibarPathModeText;
257-
public string OmnibarPathModeText { get => _OmnibarPathModeText; set => SetProperty(ref _OmnibarPathModeText, value); }
258-
259257
private CurrentInstanceViewModel _InstanceViewModel;
260258
public CurrentInstanceViewModel InstanceViewModel
261259
{
@@ -694,12 +692,12 @@ public async Task HandleItemNavigationAsync(string path)
694692
? Constants.UserEnvironmentPaths.HomePath
695693
: ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory;
696694

697-
if (await LaunchApplicationFromPath(OmnibarPathModeText, workingDir))
695+
if (await LaunchApplicationFromPath(PathText, workingDir))
698696
return;
699697

700698
try
701699
{
702-
if (!await Windows.System.Launcher.LaunchUriAsync(new Uri(OmnibarPathModeText)))
700+
if (!await Windows.System.Launcher.LaunchUriAsync(new Uri(PathText)))
703701
await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLocalizedResource(),
704702
string.Format(Strings.InvalidItemDialogContent.GetLocalizedResource(), Environment.NewLine, resFolder.ErrorCode.ToString()));
705703
}
@@ -839,7 +837,6 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p
839837
Icon = new FontIcon { Glyph = "\uE7BA" },
840838
Text = Strings.SubDirectoryAccessDenied.GetLocalizedResource(),
841839
//Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlErrorTextForegroundBrush"],
842-
FontSize = 12
843840
};
844841

845842
flyout.Items?.Add(flyoutItem);
@@ -859,7 +856,6 @@ public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem p
859856
{
860857
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
861858
Text = childFolder.Item.Name,
862-
FontSize = 12
863859
};
864860

865861
if (workingPath != childFolder.Path)
@@ -1032,13 +1028,13 @@ private static async Task<bool> LaunchApplicationFromPath(string currentInput, s
10321028

10331029
public async Task PopulateOmnibarSuggestionsForPathMode()
10341030
{
1035-
var result = await SafetyExtensions.IgnoreExceptions(async () =>
1031+
var result = await SafetyExtensions.IgnoreExceptions((Func<Task<bool>>)(async () =>
10361032
{
10371033
List<OmnibarPathModeSuggestionModel>? newSuggestions = [];
1038-
var pathText = OmnibarPathModeText;
1034+
var pathText = this.PathText;
10391035

10401036
// If the current input is special, populate navigation history instead.
1041-
if (string.IsNullOrWhiteSpace(pathText) ||
1037+
if (string.IsNullOrWhiteSpace((string)pathText) ||
10421038
pathText is "Home" or "ReleaseNotes" or "Settings")
10431039
{
10441040
// Load previously entered path
@@ -1049,9 +1045,9 @@ public async Task PopulateOmnibarSuggestionsForPathMode()
10491045
}
10501046
else
10511047
{
1052-
var isFtp = FtpHelpers.IsFtpPath(pathText);
1053-
pathText = NormalizePathInput(pathText, isFtp);
1054-
var expandedPath = StorageFileExtensions.GetResolvedPath(pathText, isFtp);
1048+
var isFtp = FtpHelpers.IsFtpPath((string)pathText);
1049+
pathText = NormalizePathInput((string)pathText, isFtp);
1050+
var expandedPath = StorageFileExtensions.GetResolvedPath((string)pathText, isFtp);
10551051
var folderPath = PathNormalization.GetParentDir(expandedPath) ?? expandedPath;
10561052
StorageFolderWithPath folder = await ContentPageContext.ShellPage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath);
10571053
if (folder is null)
@@ -1114,7 +1110,7 @@ public async Task PopulateOmnibarSuggestionsForPathMode()
11141110
}
11151111

11161112
return true;
1117-
});
1113+
}));
11181114

11191115
if (!result)
11201116
{

src/Files.App/Views/Shells/BaseShellPage.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,9 @@ protected void NavigationToolbar_EditModeEnabled(object sender, EventArgs e)
442442
{
443443
ToolbarViewModel.ManualEntryBoxLoaded = true;
444444
ToolbarViewModel.ClickablePathLoaded = false;
445-
ToolbarViewModel.OmnibarPathModeText = string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory)
445+
ToolbarViewModel.PathText = string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory)
446446
? Constants.UserEnvironmentPaths.HomePath
447447
: ShellViewModel.WorkingDirectory;
448-
ToolbarViewModel.PathText = ToolbarViewModel.OmnibarPathModeText;
449448
}
450449

451450
protected async void DrivesManager_PropertyChanged(object sender, PropertyChangedEventArgs e)

0 commit comments

Comments
 (0)