Skip to content

Commit 8e1b9a2

Browse files
committed
Update
1 parent 15b70a5 commit 8e1b9a2

File tree

3 files changed

+76
-79
lines changed

3 files changed

+76
-79
lines changed

src/Files.App/UserControls/NavigationToolbar.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
xmlns:ucs="using:Files.App.UserControls.StatusCenter"
2222
xmlns:vm="using:Files.App.ViewModels.UserControls"
2323
x:Name="NavToolbar"
24-
Loading="NavToolbar_Loading"
2524
mc:Ignorable="d">
2625

2726
<UserControl.Resources>
@@ -352,7 +351,11 @@
352351
SuggestionItemsSource="{x:Bind ViewModel.PathModeSuggestionItems, Mode=OneWay}"
353352
Text="{x:Bind ViewModel.OmnibarPathModeText, Mode=OneWay}">
354353
<controls:OmnibarMode.ContentOnInactive>
355-
<controls:BreadcrumbBar x:Name="NewBreadcrumbBar" ItemsSource="{x:Bind ViewModel.PathComponents, Mode=OneWay}">
354+
<controls:BreadcrumbBar
355+
x:Name="NewBreadcrumbBar"
356+
ItemDropDownFlyoutClosed="NewBreadcrumbBar_ItemDropDownFlyoutClosed"
357+
ItemDropDownFlyoutOpening="NewBreadcrumbBar_ItemDropDownFlyoutOpening"
358+
ItemsSource="{x:Bind ViewModel.PathComponents, Mode=OneWay}">
356359
<controls:BreadcrumbBar.RootItem>
357360
<Image
358361
Width="16"
@@ -548,7 +551,7 @@
548551
<TeachingTip
549552
x:Name="StatusCenterTeachingTip"
550553
Title="{helpers:ResourceString Name=OngoingTasksTeachingTip/Title}"
551-
IsOpen="False"
554+
IsOpen="{x:Bind OngoingTasksViewModel.ShowStatusCenterTeachingTip, Mode=OneWay}"
552555
Subtitle="{helpers:ResourceString Name=OngoingTasksTeachingTip/Subtitle}"
553556
Target="{x:Bind ShowStatusCenterButton}" />
554557

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

Lines changed: 56 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
using Microsoft.UI.Xaml.Input;
1010
using Microsoft.UI.Xaml.Media;
1111
using Microsoft.UI.Xaml.Navigation;
12-
using System.Windows.Input;
1312
using Windows.System;
14-
using FocusManager = Microsoft.UI.Xaml.Input.FocusManager;
1513

1614
namespace Files.App.UserControls
1715
{
@@ -41,26 +39,16 @@ public sealed partial class NavigationToolbar : UserControl
4139
[GeneratedDependencyProperty]
4240
public partial NavigationToolbarViewModel ViewModel { get; set; }
4341

44-
// Commands
45-
46-
private readonly ICommand historyItemClickedCommand;
47-
4842
// Constructor
4943

5044
public NavigationToolbar()
5145
{
5246
InitializeComponent();
53-
54-
historyItemClickedCommand = new RelayCommand<ToolbarHistoryItemModel?>(HistoryItemClicked);
5547
}
5648

57-
private void NavToolbar_Loading(FrameworkElement _, object e)
58-
{
59-
Loading -= NavToolbar_Loading;
60-
if (OngoingTasksViewModel is not null)
61-
OngoingTasksViewModel.NewItemAdded += OngoingTasksActions_ProgressBannerPosted;
62-
}
49+
// Methods
6350

51+
#region Legacy navigation box impl
6452
private void VisiblePath_Loaded(object _, RoutedEventArgs e)
6553
{
6654
// AutoSuggestBox won't receive focus unless it's fully loaded
@@ -135,17 +123,25 @@ private void SearchRegion_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEve
135123
private void VisiblePath_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
136124
=> ViewModel.VisiblePath_QuerySubmitted(sender, args);
137125

138-
private void OngoingTasksActions_ProgressBannerPosted(object? _, StatusCenterItem e)
126+
private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args)
127+
{
128+
if (args.InputDevice != FocusInputDeviceKind.Keyboard)
129+
return;
130+
131+
var previousControl = args.OldFocusedElement as FrameworkElement;
132+
if (previousControl?.Name == nameof(HomeButton) || previousControl?.Name == nameof(Refresh))
133+
ViewModel.IsEditModeEnabled = true;
134+
}
135+
#endregion
136+
137+
private void NewBreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e)
138+
{
139+
140+
}
141+
142+
private void NewBreadcrumbBar_ItemDropDownFlyoutClosed(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e)
139143
{
140-
if (OngoingTasksViewModel is not null)
141-
OngoingTasksViewModel.NewItemAdded -= OngoingTasksActions_ProgressBannerPosted;
142144

143-
// Displays a teaching tip the first time a banner is posted
144-
if (userSettingsService.AppSettingsService.ShowStatusCenterTeachingTip)
145-
{
146-
StatusCenterTeachingTip.IsOpen = true;
147-
userSettingsService.AppSettingsService.ShowStatusCenterTeachingTip = false;
148-
}
149145
}
150146

151147
private void Button_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEventArgs args)
@@ -195,68 +191,58 @@ private async Task AddHistoryItemsAsync(IEnumerable<PageStackEntry> items, IList
195191

196192
var flyoutItem = new MenuFlyoutItem
197193
{
198-
Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder
194+
Icon = new FontIcon() { Glyph = "\uE8B7" }, // Placeholder icon
199195
Text = fileName,
200-
Command = historyItemClickedCommand,
196+
Command = new RelayCommand<ToolbarHistoryItemModel?>(HistoryItemClicked),
201197
CommandParameter = new ToolbarHistoryItemModel(item, isBackMode)
202198
};
203199

204200
flyoutItems?.Add(flyoutItem);
205201

206202
// Start loading the thumbnail in the background
207203
_ = LoadFlyoutItemIconAsync(flyoutItem, args.NavPathParam);
208-
}
209-
}
210-
211-
private async Task LoadFlyoutItemIconAsync(MenuFlyoutItem flyoutItem, string path)
212-
{
213-
var imageSource = await NavigationHelpers.GetIconForPathAsync(path);
214204

215-
if (imageSource is not null)
216-
flyoutItem.Icon = new ImageIcon { Source = imageSource };
217-
}
218-
219-
private void HistoryItemClicked(ToolbarHistoryItemModel? itemModel)
220-
{
221-
if (itemModel is null)
222-
return;
223-
224-
var shellPage = Ioc.Default.GetRequiredService<IContentPageContext>().ShellPage;
225-
if (shellPage is null)
226-
return;
227-
228-
if (itemModel.IsBackMode)
229-
{
230-
// Remove all entries after the target entry in the BackwardStack
231-
while (shellPage.BackwardStack.Last() != itemModel.PageStackEntry)
205+
void HistoryItemClicked(ToolbarHistoryItemModel? itemModel)
232206
{
233-
shellPage.BackwardStack.RemoveAt(shellPage.BackwardStack.Count - 1);
207+
if (itemModel is null)
208+
return;
209+
210+
var shellPage = Ioc.Default.GetRequiredService<IContentPageContext>().ShellPage;
211+
if (shellPage is null)
212+
return;
213+
214+
if (itemModel.IsBackMode)
215+
{
216+
// Remove all entries after the target entry in the BackwardStack
217+
while (shellPage.BackwardStack.Last() != itemModel.PageStackEntry)
218+
{
219+
shellPage.BackwardStack.RemoveAt(shellPage.BackwardStack.Count - 1);
220+
}
221+
222+
// Navigate back
223+
shellPage.Back_Click();
224+
}
225+
else
226+
{
227+
// Remove all entries before the target entry in the ForwardStack
228+
while (shellPage.ForwardStack.First() != itemModel.PageStackEntry)
229+
{
230+
shellPage.ForwardStack.RemoveAt(0);
231+
}
232+
233+
// Navigate forward
234+
shellPage.Forward_Click();
235+
}
234236
}
235237

236-
// Navigate back
237-
shellPage.Back_Click();
238-
}
239-
else
240-
{
241-
// Remove all entries before the target entry in the ForwardStack
242-
while (shellPage.ForwardStack.First() != itemModel.PageStackEntry)
238+
async Task LoadFlyoutItemIconAsync(MenuFlyoutItem flyoutItem, string path)
243239
{
244-
shellPage.ForwardStack.RemoveAt(0);
245-
}
240+
var imageSource = await NavigationHelpers.GetIconForPathAsync(path);
246241

247-
// Navigate forward
248-
shellPage.Forward_Click();
242+
if (imageSource is not null)
243+
flyoutItem.Icon = new ImageIcon() { Source = imageSource };
244+
}
249245
}
250246
}
251-
252-
private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args)
253-
{
254-
if (args.InputDevice != FocusInputDeviceKind.Keyboard)
255-
return;
256-
257-
var previousControl = args.OldFocusedElement as FrameworkElement;
258-
if (previousControl?.Name == nameof(HomeButton) || previousControl?.Name == nameof(Refresh))
259-
ViewModel.IsEditModeEnabled = true;
260-
}
261247
}
262248
}

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ namespace Files.App.ViewModels.UserControls
55
{
66
public sealed partial class StatusCenterViewModel : ObservableObject
77
{
8+
private readonly IAppSettingsService AppSettingsService = Ioc.Default.GetRequiredService<IAppSettingsService>();
9+
810
public ObservableCollection<StatusCenterItem> StatusCenterItems { get; } = [];
911

1012
private int _AverageOperationProgressValue = 0;
11-
public int AverageOperationProgressValue
12-
{
13-
get => _AverageOperationProgressValue;
14-
private set => SetProperty(ref _AverageOperationProgressValue, value);
15-
}
13+
public int AverageOperationProgressValue { get => _AverageOperationProgressValue; private set => SetProperty(ref _AverageOperationProgressValue, value); }
14+
15+
private bool _ShowStatusCenterTeachingTip;
16+
public bool ShowStatusCenterTeachingTip { get => _ShowStatusCenterTeachingTip; private set => SetProperty(ref _ShowStatusCenterTeachingTip, value); }
1617

1718
public int InProgressItemCount
1819
{
@@ -89,7 +90,14 @@ public StatusCenterItem AddItem(
8990
cancellationTokenSource);
9091

9192
StatusCenterItems.Insert(0, banner);
92-
NewItemAdded?.Invoke(this, banner);
93+
94+
// Displays a teaching tip the first time a banner is posted
95+
if (AppSettingsService.ShowStatusCenterTeachingTip)
96+
{
97+
ShowStatusCenterTeachingTip = true;
98+
AppSettingsService.ShowStatusCenterTeachingTip = false;
99+
}
100+
93101

94102
NotifyChanges();
95103

0 commit comments

Comments
 (0)