Skip to content

Code Quality: Improved SideBar codebase #13520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Files.App/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<!-- Styles for the custom icons -->
<ResourceDictionary Source="/ResourceDictionaries/PathIcons.xaml" />
<ResourceDictionary Source="/UserControls/SideBar/SideBarControls.xaml" />
<ResourceDictionary Source="/UserControls/SideBar/SideBarStyles.xaml" />
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/App.Theme.TextBlockStyles.xaml" />
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private IHost ConfigureHost()
.AddSingleton<INetworkDrivesService, NetworkDrivesService>()
.AddSingleton<MainPageViewModel>()
.AddSingleton<PreviewPaneViewModel>()
.AddSingleton<SidebarViewModel>()
.AddSingleton<SideBarViewModel>()
.AddSingleton<SettingsViewModel>()
.AddSingleton<DrivesViewModel>()
.AddSingleton<NetworkDrivesViewModel>()
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;
SidebarViewModel.SelectedTagChanged += SelectedTagsChanged;
SideBarViewModel.SelectedTagChanged += SelectedTagsChanged;
}

private void SelectedTagsChanged(object _, SelectedTagChangedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Data/Items/INavigationControlItem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

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

namespace Files.App.Data.Items
{

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

Expand Down
25 changes: 18 additions & 7 deletions src/Files.App/UserControls/SideBar/ISideBarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;

namespace Files.App.UserControls.Sidebar
namespace Files.App.UserControls.SideBar
{
public record ItemDroppedEventArgs(object DropTarget, DataPackageView DroppedItem, SidebarItemDropPosition dropPosition, DragEventArgs RawEvent) { }
public record ItemDragOverEventArgs(object DropTarget, DataPackageView DroppedItem, SidebarItemDropPosition dropPosition, DragEventArgs RawEvent) { }
public record ItemContextInvokedArgs(object? Item, Point Position) { }
public record ItemDroppedEventArgs(object DropTarget, DataPackageView DroppedItem, SideBarItemDropPosition dropPosition, DragEventArgs RawEvent)
{
}

public record ItemDragOverEventArgs(object DropTarget, DataPackageView DroppedItem, SideBarItemDropPosition dropPosition, DragEventArgs RawEvent)
{
}

public record ItemContextInvokedArgs(object? Item, Point Position)
{
}

public interface ISidebarViewModel
/// <summary>
/// Represents interface for <see cref="SideBarViewModel"/>.
/// </summary>
public interface ISideBarViewModel
{
/// <summary>
/// The source/list of items that will be rendered in the sidebar
/// Gets the source/list of items that will be rendered in the sidebar
/// </summary>
object SidebarItems { get; }

/// <summary>
/// Gets invoked when the context was requested for an item in the sidebar.
/// Also applies when context was requested for the pane itsself.
/// Also applies when context was requested for the pane itself.
/// </summary>
/// <param name="sender">The sender of this event</param>
/// <param name="args">The <see cref="ItemContextInvokedArgs"/> for this event.</param>
Expand Down
18 changes: 9 additions & 9 deletions src/Files.App/UserControls/SideBar/ISidebarItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Files.App.UserControls.Sidebar
namespace Files.App.UserControls.SideBar
{
public interface ISidebarItemModel : INotifyPropertyChanged
public interface ISideBarItemModel : INotifyPropertyChanged
{
/// <summary>
/// The children of this item that will be rendered as child elements of the SidebarItem
/// Gets the children of this item that will be rendered as child elements of the <see cref="SideBarItem"/>
/// </summary>
object? Children { get; }

/// <summary>
/// The icon source used to generate the icon for the SidebarItem
/// Gets the icon source used to generate the icon for the <see cref="SideBarItem"/>
/// </summary>
IconSource? IconSource { get; }

/// <summary>
/// Item decorator for the given item.
/// Gets the item decorator for the given item.
/// </summary>
FrameworkElement? ItemDecorator { get => null; }

/// <summary>
/// Determines whether the SidebarItem is expanded and the children are visible
/// or if it is collapsed and children are not visible.
/// Gets or sets a value that indicates whether the <see cref="SideBarItem"/> is expanded
/// and the children are visible, or if it is collapsed and children are not visible.
/// </summary>
bool IsExpanded { get; set; }

/// <summary>
/// The text of this item that will be rendered as the label of the SidebarItem
/// Gets the text of this item that will be rendered as the label of the SidebarItem.
/// </summary>
string Text { get; }

/// <summary>
/// The tooltip used when hovering over this item in the sidebar
/// Gets the tooltip used when hovering over this item in the sidebar.
/// </summary>
object ToolTip { get; }
}
Expand Down
24 changes: 0 additions & 24 deletions src/Files.App/UserControls/SideBar/SideBarDisplayMode.cs

This file was deleted.

Loading