Skip to content

Commit

Permalink
Feature: Redesigned the left-hand sidebar (files-community#13052)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelwgn authored Aug 13, 2023
1 parent 3d88463 commit 9c34c31
Show file tree
Hide file tree
Showing 42 changed files with 3,004 additions and 2,620 deletions.
50 changes: 0 additions & 50 deletions src/Files.App/Actions/Show/ToggleSidebarAction.cs

This file was deleted.

6 changes: 1 addition & 5 deletions src/Files.App/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<!-- Default list view item margin -->
<x:Double x:Key="ListItemMargin">0</x:Double>

<!-- Default nav menu item height -->
<x:Double x:Key="NavigationViewItemOnLeftMinHeight">32</x:Double>

<!-- Fix caption buttons background -->
<SolidColorBrush x:Key="WindowCaptionBackground" Color="Transparent" />
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Transparent" />
Expand All @@ -34,9 +31,8 @@

<!-- Styles for the custom icons -->
<ResourceDictionary Source="/ResourceDictionaries/PathIcons.xaml" />

<ResourceDictionary Source="/ResourceDictionaries/SidebarResources.xaml" />
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/App.Theme.TextBlockStyles.xaml" />

<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Data/Commands/CommandCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public enum CommandCodes
ToggleShowHiddenItems,
ToggleShowFileExtensions,
TogglePreviewPane,
ToggleSidebar,

// File System
CopyItem,
Expand Down
2 changes: 0 additions & 2 deletions src/Files.App/Data/Commands/Manager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public IRichCommand this[HotKey hotKey]
public IRichCommand ToggleShowHiddenItems => commands[CommandCodes.ToggleShowHiddenItems];
public IRichCommand ToggleShowFileExtensions => commands[CommandCodes.ToggleShowFileExtensions];
public IRichCommand TogglePreviewPane => commands[CommandCodes.TogglePreviewPane];
public IRichCommand ToggleSidebar => commands[CommandCodes.ToggleSidebar];
public IRichCommand SelectAll => commands[CommandCodes.SelectAll];
public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection];
public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection];
Expand Down Expand Up @@ -213,7 +212,6 @@ public CommandManager()
[CommandCodes.ToggleShowHiddenItems] = new ToggleShowHiddenItemsAction(),
[CommandCodes.ToggleShowFileExtensions] = new ToggleShowFileExtensionsAction(),
[CommandCodes.TogglePreviewPane] = new TogglePreviewPaneAction(),
[CommandCodes.ToggleSidebar] = new ToggleSidebarAction(),
[CommandCodes.SelectAll] = new SelectAllAction(),
[CommandCodes.InvertSelection] = new InvertSelectionAction(),
[CommandCodes.ClearSelection] = new ClearSelectionAction(),
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Data/Commands/Manager/ICommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public interface ICommandManager : IEnumerable<IRichCommand>
IRichCommand ToggleShowHiddenItems { get; }
IRichCommand ToggleShowFileExtensions { get; }
IRichCommand TogglePreviewPane { get; }
IRichCommand ToggleSidebar { get; }

IRichCommand CopyItem { get; }
IRichCommand CopyPath { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Contexts/Tags/TagsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sealed class TagsContext : ITagsContext
public TagsContext()
{
FileTagsContainerViewModel.SelectedTagChanged += SelectedTagsChanged;
SidebarControl.SelectedTagChanged += SelectedTagsChanged;
SidebarViewModel.SelectedTagChanged += SelectedTagsChanged;
}

private void SelectedTagsChanged(object _, SelectedTagChangedEventArgs e)
Expand Down
60 changes: 53 additions & 7 deletions src/Files.App/Data/Items/DriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
using Files.Core.Storage.Enums;
using Files.Core.Storage.LocatableStorage;
using Files.Core.Storage.NestedStorage;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
using Windows.Storage;
using Windows.Storage.Streams;
Expand All @@ -20,7 +22,11 @@ public class DriveItem : ObservableObject, INavigationControlItem, ILocatableFol
public BitmapImage Icon
{
get => icon;
set => SetProperty(ref icon, value);
set
{
SetProperty(ref icon, value, nameof(Icon));
OnPropertyChanged(nameof(IconSource));
}
}

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

public string ToolTipText { get; private set; }

public string DeviceID { get; set; }

public StorageFolder Root { get; set; }
Expand Down Expand Up @@ -68,7 +72,10 @@ public ByteSize MaxSpace
{
if (SetProperty(ref maxSpace, value))
{
ToolTipText = GetSizeString();
if (Type != DriveType.CloudDrive)
{
ToolTip = GetSizeString();
}

OnPropertyChanged(nameof(MaxSpaceText));
OnPropertyChanged(nameof(ShowDriveDetails));
Expand All @@ -84,7 +91,10 @@ public ByteSize FreeSpace
{
if (SetProperty(ref freeSpace, value))
{
ToolTipText = GetSizeString();
if (Type != DriveType.CloudDrive)
{
ToolTip = GetSizeString();
}

OnPropertyChanged(nameof(FreeSpaceText));
}
Expand All @@ -107,7 +117,22 @@ public ByteSize SpaceUsed
public bool ShowDriveDetails
=> MaxSpace.Bytes > 0d;

public DriveType Type { get; set; }
private DriveType type;
public DriveType Type
{
get => type; set
{
type = value;
if (value == DriveType.Network)
{
ToolTip = "Network".GetLocalizedResource();
}
else if (value == DriveType.CloudDrive)
{
ToolTip = Text;
}
}
}

private string text;
public string Text
Expand Down Expand Up @@ -152,6 +177,28 @@ public bool ShowStorageSense

public string Name => Root.DisplayName;

public object? Children => null;

private object toolTip = "";
public object ToolTip
{
get => toolTip;
set
{
SetProperty(ref toolTip, value);
}
}

public bool IsExpanded { get => false; set { } }

public IconSource? IconSource
{
get => new ImageIconSource()
{
ImageSource = Icon
};
}

public static async Task<DriveItem> CreateFromPropertiesAsync(StorageFolder root, string deviceId, string label, DriveType type, IRandomAccessStream imageStream = null)
{
var item = new DriveItem();
Expand Down Expand Up @@ -255,7 +302,6 @@ public async Task LoadThumbnailAsync(bool isSidebar = false)
}
IconData ??= UIHelpers.GetSidebarIconResourceInfo(Constants.ImageRes.Folder).IconData;
}

Icon ??= await IconData.ToBitmapAsync();
}

Expand Down
26 changes: 24 additions & 2 deletions src/Files.App/Data/Items/FileTagItem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI.Helpers;
using Files.App.Converters;
using Files.Core.ViewModels.FileTags;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using Microsoft.UI.Xaml.Media;

namespace Files.App.Data.Items
{
public class FileTagItem : INavigationControlItem
public class FileTagItem : ObservableObject, INavigationControlItem
{
public string Text { get; set; }

Expand All @@ -16,7 +22,8 @@ public string Path
set
{
path = value;
ToolTipText = Text;
OnPropertyChanged(nameof(IconSource));
OnPropertyChanged(nameof(ToolTip));
}
}

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

public TagViewModel FileTag { get; set; }

public object? Children => null;

public IconSource? IconSource
{
get => new PathIconSource()
{
Data = (Geometry)XamlBindingHelper.ConvertValue(typeof(Geometry), (string)Application.Current.Resources["ColorIconFilledTag"]),
Foreground = new SolidColorBrush(FileTag.Color.ToColor())
};
}

public object ToolTip => Text;

public bool IsExpanded { get => false; set { } }
}
}
10 changes: 6 additions & 4 deletions src/Files.App/Data/Items/INavigationControlItem.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.UserControls.Sidebar;
using Microsoft.UI.Xaml.Controls;

namespace Files.App.Data.Items
{
public interface INavigationControlItem : IComparable<INavigationControlItem>

public interface INavigationControlItem : IComparable<INavigationControlItem>, INotifyPropertyChanged, ISidebarItemModel
{
public string Text { get; }
public new string Text { get; }

public string Path { get; }

public SectionType Section { get; }

public string ToolTipText { get; }

public NavigationControlItemType ItemType { get; }

public ContextMenuOptions MenuOptions { get; }
Expand Down
Loading

0 comments on commit 9c34c31

Please sign in to comment.