Skip to content

Commit 53ba1a8

Browse files
lukeblevinsyaira2
andauthored
Fix bug with Status Bar control not displaying information through multiple tabs (#1109)
Co-authored-by: Yair Aichenbaum <[email protected]>
1 parent 517e407 commit 53ba1a8

29 files changed

+203
-167
lines changed

Files/App.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<Application
22
x:Class="Files.App"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:converters="using:Files.Helpers">
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
65
<Application.Resources>
76
<ResourceDictionary>
7+
<FontFamily x:Key="CustomLayoutModeIcon">/Assets/Custom Glyphs/layout-mode-custom-icon.ttf#layout-mode-custom-icon</FontFamily>
8+
<FontFamily x:Key="RecycleBinIcons">/Assets/Custom Glyphs/recyclebin-fabric-glyph.ttf#Fabric MDL2 Assets</FontFamily>
89
<ResourceDictionary.MergedDictionaries>
910
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
1011
<ResourceDictionary Source="/ResourceDictionaries/ToolbarButtonStyle.xaml" />
@@ -51,7 +52,6 @@
5152
</ResourceDictionary.ThemeDictionaries>
5253
</ResourceDictionary>
5354
</ResourceDictionary.MergedDictionaries>
54-
<FontFamily x:Key="CustomLayoutModeIcon">/Assets/Custom Glyphs/layout-mode-custom-icon.ttf#layout-mode-custom-icon</FontFamily>
5555
</ResourceDictionary>
5656
</Application.Resources>
5757
</Application>

Files/App.xaml.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Windows.ApplicationModel;
1818
using Windows.ApplicationModel.Activation;
1919
using Windows.ApplicationModel.AppService;
20+
using Windows.ApplicationModel.Core;
2021
using Windows.ApplicationModel.DataTransfer;
2122
using Windows.Storage;
2223
using Windows.UI.Core;
@@ -56,8 +57,6 @@ public static IShellPage CurrentInstance
5657
public static ObservableCollection<WSLDistroItem> linuxDistroItems = new ObservableCollection<WSLDistroItem>();
5758
public static SettingsViewModel AppSettings { get; set; }
5859
public static InteractionViewModel InteractionViewModel { get; set; }
59-
public static SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; set; }
60-
public static DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; set; }
6160
public static SidebarPinnedModel SidebarPinned { get; set; }
6261

6362
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@@ -78,16 +77,9 @@ public App()
7877
LayoutDialogDisplay = new Dialogs.LayoutDialog();
7978
AddItemDialogDisplay = new Dialogs.AddItemDialog();
8079
ExceptionDialogDisplay = new Dialogs.ExceptionDialog();
81-
// this.UnhandledException += App_UnhandledException;
8280
Clipboard.ContentChanged += Clipboard_ContentChanged;
8381
Clipboard_ContentChanged(null, null);
8482
AppCenter.Start("682666d1-51d3-4e4a-93d0-d028d43baaa0", typeof(Analytics), typeof(Crashes));
85-
86-
SidebarPinned = new SidebarPinnedModel();
87-
AppSettings = new SettingsViewModel();
88-
InteractionViewModel = new InteractionViewModel();
89-
SelectedItemsPropertiesViewModel = new SelectedItemsPropertiesViewModel(null);
90-
DirectoryPropertiesViewModel = new DirectoryPropertiesViewModel();
9183
}
9284

9385
private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)
@@ -134,13 +126,13 @@ private async void Connection_RequestReceived(AppServiceConnection sender, AppSe
134126
{
135127
var path = (string)args.Request.Message["FileSystem"];
136128
Debug.WriteLine("{0}: {1}", path, args.Request.Message["Type"]);
137-
if (App.CurrentInstance.ViewModel.CurrentFolder?.ItemPath == path)
129+
if (App.CurrentInstance.FilesystemViewModel.CurrentFolder?.ItemPath == path)
138130
{
139131
// If we are currently displaying the reycle bin lets refresh the items
140132
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
141133
() =>
142134
{
143-
App.CurrentInstance.ViewModel.RefreshItems();
135+
App.CurrentInstance.FilesystemViewModel.RefreshItems();
144136
});
145137
}
146138
}
@@ -186,7 +178,7 @@ public static void Clipboard_ContentChanged(object sender, object e)
186178
DataPackageView packageView = Clipboard.GetContent();
187179
if (packageView.Contains(StandardDataFormats.StorageItems)
188180
&& App.CurrentInstance.CurrentPageType != typeof(YourHome)
189-
&& !App.CurrentInstance.ViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath))
181+
&& !App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath))
190182
{
191183
App.PS.IsEnabled = true;
192184
}
Binary file not shown.

Files/BaseLayout.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ namespace Files
2525
/// </summary>
2626
public abstract class BaseLayout : Page, INotifyPropertyChanged
2727
{
28+
public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
29+
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
2830
public bool IsQuickLookEnabled { get; set; } = false;
2931

3032
public ItemViewModel AssociatedViewModel = null;
@@ -49,8 +51,6 @@ internal set
4951
}
5052
}
5153

52-
public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel => App.SelectedItemsPropertiesViewModel;
53-
5454
private List<ListedItem> _SelectedItems = new List<ListedItem>();
5555

5656
public List<ListedItem> SelectedItems
@@ -99,7 +99,8 @@ public BaseLayout()
9999
{
100100
this.Loaded += Page_Loaded;
101101
Page_Loaded(null, null);
102-
102+
SelectedItemsPropertiesViewModel = new SelectedItemsPropertiesViewModel(null);
103+
DirectoryPropertiesViewModel = new DirectoryPropertiesViewModel();
103104
// QuickLook Integration
104105
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
105106
var isQuickLookIntegrationEnabled = localSettings.Values["quicklook_enabled"];
@@ -140,11 +141,11 @@ private void AppSettings_LayoutModeChangeRequested(object sender, EventArgs e)
140141
{
141142
if (App.CurrentInstance.ContentPage != null)
142143
{
143-
App.CurrentInstance.ViewModel.CancelLoadAndClearFiles();
144-
App.CurrentInstance.ViewModel.IsLoadingItems = true;
145-
App.CurrentInstance.ViewModel.IsLoadingItems = false;
144+
App.CurrentInstance.FilesystemViewModel.CancelLoadAndClearFiles();
145+
App.CurrentInstance.FilesystemViewModel.IsLoadingItems = true;
146+
App.CurrentInstance.FilesystemViewModel.IsLoadingItems = false;
146147

147-
App.CurrentInstance.ContentFrame.Navigate(App.AppSettings.GetLayoutType(), App.CurrentInstance.ViewModel.WorkingDirectory, null);
148+
App.CurrentInstance.ContentFrame.Navigate(App.AppSettings.GetLayoutType(), App.CurrentInstance.FilesystemViewModel.WorkingDirectory, null);
148149
}
149150
}
150151

@@ -171,23 +172,23 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
171172
App.CurrentInstance.NavigationToolbar.CanRefresh = true;
172173
IsItemSelected = false;
173174
AssociatedViewModel.IsFolderEmptyTextDisplayed = false;
174-
App.CurrentInstance.ViewModel.WorkingDirectory = parameters;
175+
App.CurrentInstance.FilesystemViewModel.WorkingDirectory = parameters;
175176

176177
// pathRoot will be empty on recycle bin path
177-
string pathRoot = Path.GetPathRoot(App.CurrentInstance.ViewModel.WorkingDirectory);
178-
if (string.IsNullOrEmpty(pathRoot) || App.CurrentInstance.ViewModel.WorkingDirectory == pathRoot)
178+
string pathRoot = Path.GetPathRoot(App.CurrentInstance.FilesystemViewModel.WorkingDirectory);
179+
if (string.IsNullOrEmpty(pathRoot) || App.CurrentInstance.FilesystemViewModel.WorkingDirectory == pathRoot)
179180
{
180181
App.CurrentInstance.NavigationToolbar.CanNavigateToParent = false;
181182
}
182183
else
183184
{
184185
App.CurrentInstance.NavigationToolbar.CanNavigateToParent = true;
185186
}
186-
App.InteractionViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page
187-
App.InteractionViewModel.IsPageTypeNotRecycleBin =
188-
!App.CurrentInstance.ViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath);
187+
App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page
188+
App.CurrentInstance.InstanceViewModel.IsPageTypeNotRecycleBin =
189+
!App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath);
189190

190-
App.CurrentInstance.ViewModel.RefreshItems();
191+
App.CurrentInstance.FilesystemViewModel.RefreshItems();
191192

192193
App.Clipboard_ContentChanged(null, null);
193194
App.CurrentInstance.NavigationToolbar.PathControlDisplayText = parameters;
@@ -210,7 +211,7 @@ private void UnloadMenuFlyoutItemByName(string nameToUnload)
210211

211212
public void RightClickContextMenu_Opening(object sender, object e)
212213
{
213-
if (App.CurrentInstance.ViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath))
214+
if (App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath))
214215
{
215216
(this.FindName("EmptyRecycleBin") as MenuFlyoutItemBase).Visibility = Visibility.Visible;
216217
(this.FindName("OpenTerminal") as MenuFlyoutItemBase).IsEnabled = false;
@@ -298,7 +299,7 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
298299
{
299300
if (AssociatedViewModel == null && AssociatedInteractions == null)
300301
{
301-
AssociatedViewModel = App.CurrentInstance.ViewModel;
302+
AssociatedViewModel = App.CurrentInstance.FilesystemViewModel;
302303
AssociatedInteractions = App.CurrentInstance.InteractionOperations;
303304
if (App.CurrentInstance == null)
304305
{
@@ -319,7 +320,7 @@ protected async void List_DragOver(object sender, DragEventArgs e)
319320
{
320321
IReadOnlyList<IStorageItem> draggedItems = await e.DataView.GetStorageItemsAsync();
321322
// As long as one file doesn't already belong to this folder
322-
if (draggedItems.Any(draggedItem => !Directory.GetParent(draggedItem.Path).FullName.Equals(App.CurrentInstance.ViewModel.WorkingDirectory, StringComparison.OrdinalIgnoreCase)))
323+
if (draggedItems.Any(draggedItem => !Directory.GetParent(draggedItem.Path).FullName.Equals(App.CurrentInstance.FilesystemViewModel.WorkingDirectory, StringComparison.OrdinalIgnoreCase)))
323324
{
324325
e.AcceptedOperation = DataPackageOperation.Copy;
325326
e.Handled = true;
@@ -335,7 +336,7 @@ protected async void List_Drop(object sender, DragEventArgs e)
335336
{
336337
if (e.DataView.Contains(StandardDataFormats.StorageItems))
337338
{
338-
await AssociatedInteractions.PasteItems(e.DataView, App.CurrentInstance.ViewModel.WorkingDirectory, e.AcceptedOperation);
339+
await AssociatedInteractions.PasteItems(e.DataView, App.CurrentInstance.FilesystemViewModel.WorkingDirectory, e.AcceptedOperation);
339340
e.Handled = true;
340341
}
341342
}

Files/Dialogs/AddItemDialog.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static async void CreateFile(AddItemType fileType)
5252
string currentPath = null;
5353
if (TabInstance.ContentPage != null)
5454
{
55-
currentPath = TabInstance.ViewModel.WorkingDirectory;
55+
currentPath = TabInstance.FilesystemViewModel.WorkingDirectory;
5656
}
5757
StorageFolder folderToCreateItem = await StorageFolder.GetFolderFromPathAsync(currentPath);
5858
RenameDialog renameDialog = new RenameDialog();

Files/Files.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
<Compile Include="UserControls\StatusBarControl.xaml.cs">
212212
<DependentUpon>StatusBarControl.xaml</DependentUpon>
213213
</Compile>
214+
<Compile Include="View Models\CurrentInstanceViewModel.cs" />
214215
<Compile Include="View Models\ItemViewModel.cs" />
215216
<Compile Include="Filesystem\ListedItem.cs" />
216217
<Compile Include="Filesystem\INavigationControlItem.cs" />
@@ -283,7 +284,12 @@
283284
<Content Include="Assets\LargeTile.scale-200.png" />
284285
<Content Include="Assets\LargeTile.scale-400.png" />
285286
<Content Include="Assets\logo.bmp" />
286-
<Content Include="Assets\Custom Glyphs\layout-mode-custom-icon.ttf" />
287+
<Content Include="Assets\Custom Glyphs\layout-mode-custom-icon.ttf">
288+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
289+
</Content>
290+
<Content Include="Assets\Custom Glyphs\recyclebin-fabric-glyph.ttf">
291+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
292+
</Content>
287293
<None Include="Assets\terminal\terminal.json">
288294
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
289295
</None>

Files/Filesystem/LocationItem.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
namespace Files.Filesystem
1+
using Windows.UI.Xaml.Media;
2+
3+
namespace Files.Filesystem
24
{
35
public class LocationItem : INavigationControlItem
46
{
57
public string Glyph { get; set; }
68
public string Text { get; set; }
79
public string Path { get; set; }
10+
public FontFamily Font { get; set; } = new FontFamily("Segoe MDL2 Assets");
811
public NavigationControlItemType ItemType => NavigationControlItemType.Location;
912
public bool IsDefaultLocation { get; set; }
1013
}

Files/IShellPage.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
using Files.Filesystem;
22
using Files.Interacts;
33
using Files.UserControls;
4+
using Files.View_Models;
45
using System;
56
using Windows.UI.Xaml.Controls;
67

78
namespace Files
89
{
910
public interface IShellPage
1011
{
12+
public StatusBarControl StatusBarControl { get; }
1113
public Frame ContentFrame { get; }
1214
public Interaction InteractionOperations { get; }
13-
public ItemViewModel ViewModel { get; }
15+
public ItemViewModel FilesystemViewModel { get; }
16+
public CurrentInstanceViewModel InstanceViewModel { get; }
1417
public BaseLayout ContentPage { get; }
1518
public Control OperationsControl { get; }
1619
public Type CurrentPageType { get; }

0 commit comments

Comments
 (0)