Files icon indicating copy to clipboard operation
Files copied to clipboard

Code Quality: Broader SidebarView control usage

Open 0x5bfa opened this issue 1 year ago • 2 comments

Description

We're planning to use Sidebar control for consistency and simplicity in properties window and settings window. I already confirmed this can reduce 200 lines.

Concerned code

  • Around SidebarView class

Gains

Consistency and simplicity

Requirements

This work appears to be huge, so I suggest to break down to a few phases below:

  1. Rename sidebar item classes such as DriveItem to be StandardDriveItem. In the future those items will also be used in widgets and even layout pages.
  2. Separation
    • Separate view-unique values such as ExpandedWidthThreshold, IsPaneOpen and ViewModel. Note that we probably need to separate almost all dependency properties in SidebarView.
    • Separate view-unique events such as ItemInvokedAsync.
  3. Add generation method for each Sidebar type: Default, Properties, Settings.
  4. Create FrameworkElement property to hold icon element for both BitmapImage and OpacityIcon

Comments

My prototype: https://github.com/files-community/Files/compare/main...0x5bfa:Files:5bfa/CQ-RefactorSidebarViewModel

0x5bfa avatar May 01 '24 19:05 0x5bfa

@yaira2 Can I work on refactoring SidebarViewModel? It has been unchanged from UWP.

0x5bfa avatar May 04 '24 21:05 0x5bfa

https://discord.com/channels/725513575971684472/958783217941487616/1236699756265214052

At the end of quick discussion, we settled on the idea to generalize usage of SidebarView, moving view-specific properties, such as item collection, pane mode, pane width. This also enables us to bind values to user settings to make them keep up with the latest info all the time. The new usage will be almost the same as the one of NavigationView, such as invoking an event to notify item invocation, using two-way binding for selected item.

In this issue, I guess we also might as well discuss the idea to make items larger to the height probably based on a user setting - EnableCompactModeInSidebar.

0x5bfa avatar May 15 '24 06:05 0x5bfa