Skip to content

Commit 9c34c31

Browse files
authored
Feature: Redesigned the left-hand sidebar (#13052)
1 parent 3d88463 commit 9c34c31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3004
-2620
lines changed

src/Files.App/Actions/Show/ToggleSidebarAction.cs

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

src/Files.App/App.xaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
<!-- Default list view item margin -->
1414
<x:Double x:Key="ListItemMargin">0</x:Double>
1515

16-
<!-- Default nav menu item height -->
17-
<x:Double x:Key="NavigationViewItemOnLeftMinHeight">32</x:Double>
18-
1916
<!-- Fix caption buttons background -->
2017
<SolidColorBrush x:Key="WindowCaptionBackground" Color="Transparent" />
2118
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Transparent" />
@@ -34,9 +31,8 @@
3431

3532
<!-- Styles for the custom icons -->
3633
<ResourceDictionary Source="/ResourceDictionaries/PathIcons.xaml" />
37-
34+
<ResourceDictionary Source="/ResourceDictionaries/SidebarResources.xaml" />
3835
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/App.Theme.TextBlockStyles.xaml" />
39-
4036
<ResourceDictionary>
4137
<ResourceDictionary.ThemeDictionaries>
4238
<ResourceDictionary x:Key="Light">

src/Files.App/Data/Commands/CommandCodes.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public enum CommandCodes
2323
ToggleShowHiddenItems,
2424
ToggleShowFileExtensions,
2525
TogglePreviewPane,
26-
ToggleSidebar,
2726

2827
// File System
2928
CopyItem,

src/Files.App/Data/Commands/Manager/CommandManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public IRichCommand this[HotKey hotKey]
5151
public IRichCommand ToggleShowHiddenItems => commands[CommandCodes.ToggleShowHiddenItems];
5252
public IRichCommand ToggleShowFileExtensions => commands[CommandCodes.ToggleShowFileExtensions];
5353
public IRichCommand TogglePreviewPane => commands[CommandCodes.TogglePreviewPane];
54-
public IRichCommand ToggleSidebar => commands[CommandCodes.ToggleSidebar];
5554
public IRichCommand SelectAll => commands[CommandCodes.SelectAll];
5655
public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection];
5756
public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection];
@@ -213,7 +212,6 @@ public CommandManager()
213212
[CommandCodes.ToggleShowHiddenItems] = new ToggleShowHiddenItemsAction(),
214213
[CommandCodes.ToggleShowFileExtensions] = new ToggleShowFileExtensionsAction(),
215214
[CommandCodes.TogglePreviewPane] = new TogglePreviewPaneAction(),
216-
[CommandCodes.ToggleSidebar] = new ToggleSidebarAction(),
217215
[CommandCodes.SelectAll] = new SelectAllAction(),
218216
[CommandCodes.InvertSelection] = new InvertSelectionAction(),
219217
[CommandCodes.ClearSelection] = new ClearSelectionAction(),

src/Files.App/Data/Commands/Manager/ICommandManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public interface ICommandManager : IEnumerable<IRichCommand>
2525
IRichCommand ToggleShowHiddenItems { get; }
2626
IRichCommand ToggleShowFileExtensions { get; }
2727
IRichCommand TogglePreviewPane { get; }
28-
IRichCommand ToggleSidebar { get; }
2928

3029
IRichCommand CopyItem { get; }
3130
IRichCommand CopyPath { get; }

src/Files.App/Data/Contexts/Tags/TagsContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ sealed class TagsContext : ITagsContext
3030
public TagsContext()
3131
{
3232
FileTagsContainerViewModel.SelectedTagChanged += SelectedTagsChanged;
33-
SidebarControl.SelectedTagChanged += SelectedTagsChanged;
33+
SidebarViewModel.SelectedTagChanged += SelectedTagsChanged;
3434
}
3535

3636
private void SelectedTagsChanged(object _, SelectedTagChangedEventArgs e)

src/Files.App/Data/Items/DriveItem.cs

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using Files.Core.Storage.Enums;
77
using Files.Core.Storage.LocatableStorage;
88
using Files.Core.Storage.NestedStorage;
9+
using Microsoft.UI.Dispatching;
910
using Microsoft.UI.Xaml;
11+
using Microsoft.UI.Xaml.Controls;
1012
using Microsoft.UI.Xaml.Media.Imaging;
1113
using Windows.Storage;
1214
using Windows.Storage.Streams;
@@ -20,7 +22,11 @@ public class DriveItem : ObservableObject, INavigationControlItem, ILocatableFol
2022
public BitmapImage Icon
2123
{
2224
get => icon;
23-
set => SetProperty(ref icon, value);
25+
set
26+
{
27+
SetProperty(ref icon, value, nameof(Icon));
28+
OnPropertyChanged(nameof(IconSource));
29+
}
2430
}
2531

2632
public byte[] IconData { get; set; }
@@ -32,8 +38,6 @@ public string Path
3238
set => path = value;
3339
}
3440

35-
public string ToolTipText { get; private set; }
36-
3741
public string DeviceID { get; set; }
3842

3943
public StorageFolder Root { get; set; }
@@ -68,7 +72,10 @@ public ByteSize MaxSpace
6872
{
6973
if (SetProperty(ref maxSpace, value))
7074
{
71-
ToolTipText = GetSizeString();
75+
if (Type != DriveType.CloudDrive)
76+
{
77+
ToolTip = GetSizeString();
78+
}
7279

7380
OnPropertyChanged(nameof(MaxSpaceText));
7481
OnPropertyChanged(nameof(ShowDriveDetails));
@@ -84,7 +91,10 @@ public ByteSize FreeSpace
8491
{
8592
if (SetProperty(ref freeSpace, value))
8693
{
87-
ToolTipText = GetSizeString();
94+
if (Type != DriveType.CloudDrive)
95+
{
96+
ToolTip = GetSizeString();
97+
}
8898

8999
OnPropertyChanged(nameof(FreeSpaceText));
90100
}
@@ -107,7 +117,22 @@ public ByteSize SpaceUsed
107117
public bool ShowDriveDetails
108118
=> MaxSpace.Bytes > 0d;
109119

110-
public DriveType Type { get; set; }
120+
private DriveType type;
121+
public DriveType Type
122+
{
123+
get => type; set
124+
{
125+
type = value;
126+
if (value == DriveType.Network)
127+
{
128+
ToolTip = "Network".GetLocalizedResource();
129+
}
130+
else if (value == DriveType.CloudDrive)
131+
{
132+
ToolTip = Text;
133+
}
134+
}
135+
}
111136

112137
private string text;
113138
public string Text
@@ -152,6 +177,28 @@ public bool ShowStorageSense
152177

153178
public string Name => Root.DisplayName;
154179

180+
public object? Children => null;
181+
182+
private object toolTip = "";
183+
public object ToolTip
184+
{
185+
get => toolTip;
186+
set
187+
{
188+
SetProperty(ref toolTip, value);
189+
}
190+
}
191+
192+
public bool IsExpanded { get => false; set { } }
193+
194+
public IconSource? IconSource
195+
{
196+
get => new ImageIconSource()
197+
{
198+
ImageSource = Icon
199+
};
200+
}
201+
155202
public static async Task<DriveItem> CreateFromPropertiesAsync(StorageFolder root, string deviceId, string label, DriveType type, IRandomAccessStream imageStream = null)
156203
{
157204
var item = new DriveItem();
@@ -255,7 +302,6 @@ public async Task LoadThumbnailAsync(bool isSidebar = false)
255302
}
256303
IconData ??= UIHelpers.GetSidebarIconResourceInfo(Constants.ImageRes.Folder).IconData;
257304
}
258-
259305
Icon ??= await IconData.ToBitmapAsync();
260306
}
261307

src/Files.App/Data/Items/FileTagItem.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4+
using CommunityToolkit.WinUI.Helpers;
5+
using Files.App.Converters;
46
using Files.Core.ViewModels.FileTags;
7+
using Microsoft.UI.Xaml;
8+
using Microsoft.UI.Xaml.Controls;
9+
using Microsoft.UI.Xaml.Markup;
10+
using Microsoft.UI.Xaml.Media;
511

612
namespace Files.App.Data.Items
713
{
8-
public class FileTagItem : INavigationControlItem
14+
public class FileTagItem : ObservableObject, INavigationControlItem
915
{
1016
public string Text { get; set; }
1117

@@ -16,7 +22,8 @@ public string Path
1622
set
1723
{
1824
path = value;
19-
ToolTipText = Text;
25+
OnPropertyChanged(nameof(IconSource));
26+
OnPropertyChanged(nameof(ToolTip));
2027
}
2128
}
2229

@@ -33,5 +40,20 @@ public int CompareTo(INavigationControlItem other)
3340
=> Text.CompareTo(other.Text);
3441

3542
public TagViewModel FileTag { get; set; }
43+
44+
public object? Children => null;
45+
46+
public IconSource? IconSource
47+
{
48+
get => new PathIconSource()
49+
{
50+
Data = (Geometry)XamlBindingHelper.ConvertValue(typeof(Geometry), (string)Application.Current.Resources["ColorIconFilledTag"]),
51+
Foreground = new SolidColorBrush(FileTag.Color.ToColor())
52+
};
53+
}
54+
55+
public object ToolTip => Text;
56+
57+
public bool IsExpanded { get => false; set { } }
3658
}
3759
}

src/Files.App/Data/Items/INavigationControlItem.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4+
using Files.App.UserControls.Sidebar;
5+
using Microsoft.UI.Xaml.Controls;
6+
47
namespace Files.App.Data.Items
58
{
6-
public interface INavigationControlItem : IComparable<INavigationControlItem>
9+
10+
public interface INavigationControlItem : IComparable<INavigationControlItem>, INotifyPropertyChanged, ISidebarItemModel
711
{
8-
public string Text { get; }
12+
public new string Text { get; }
913

1014
public string Path { get; }
1115

1216
public SectionType Section { get; }
1317

14-
public string ToolTipText { get; }
15-
1618
public NavigationControlItemType ItemType { get; }
1719

1820
public ContextMenuOptions MenuOptions { get; }

0 commit comments

Comments
 (0)