-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Code Quality: Replaced manual DP definitions in the Sidebar controls with the Toolkit's source generator #17865
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
Open
0x5bfa
wants to merge
1
commit into
files-community:main
Choose a base branch
from
0x5bfa:5bfa/CQ-QuickAccess
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−252
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 31 additions & 88 deletions
119
src/Files.App.Controls/Sidebar/SidebarView.Properties.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,113 +1,56 @@ | ||
| // Copyright (c) Files Community | ||
| // Licensed under the MIT License. | ||
|
|
||
| using CommunityToolkit.WinUI; | ||
|
|
||
| namespace Files.App.Controls | ||
| { | ||
| public sealed partial class SidebarView | ||
| { | ||
| public SidebarDisplayMode DisplayMode | ||
| { | ||
| get { return (SidebarDisplayMode)GetValue(DisplayModeProperty); } | ||
| set { SetValue(DisplayModeProperty, value); } | ||
| } | ||
| public static readonly DependencyProperty DisplayModeProperty = | ||
| DependencyProperty.Register(nameof(DisplayMode), typeof(SidebarDisplayMode), typeof(SidebarView), new PropertyMetadata(SidebarDisplayMode.Expanded, OnPropertyChanged)); | ||
| [GeneratedDependencyProperty(DefaultValue = SidebarDisplayMode.Expanded)] | ||
| public partial SidebarDisplayMode DisplayMode { get; set; } | ||
|
|
||
| public UIElement InnerContent | ||
| { | ||
| get { return (UIElement)GetValue(InnerContentProperty); } | ||
| set { SetValue(InnerContentProperty, value); } | ||
| } | ||
| public static readonly DependencyProperty InnerContentProperty = | ||
| DependencyProperty.Register(nameof(InnerContent), typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null)); | ||
| [GeneratedDependencyProperty] | ||
| public partial UIElement? InnerContent { get; set; } | ||
|
|
||
| public UIElement SidebarContent | ||
| { | ||
| get { return (UIElement)GetValue(SidebarContentProperty); } | ||
| set { SetValue(SidebarContentProperty, value); } | ||
| } | ||
| public static readonly DependencyProperty SidebarContentProperty = | ||
| DependencyProperty.Register("SidebarContent", typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null)); | ||
| [GeneratedDependencyProperty] | ||
| public partial UIElement? SidebarContent { get; set; } | ||
|
|
||
| public UIElement Footer | ||
| { | ||
| get { return (UIElement)GetValue(FooterProperty); } | ||
| set { SetValue(FooterProperty, value); } | ||
| } | ||
| public static readonly DependencyProperty FooterProperty = | ||
| DependencyProperty.Register("Footer", typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null)); | ||
| [GeneratedDependencyProperty] | ||
| public partial UIElement? Footer { get; set; } | ||
|
|
||
| public bool IsPaneOpen | ||
| { | ||
| get { return (bool)GetValue(IsPaneOpenProperty); } | ||
| set { SetValue(IsPaneOpenProperty, value); } | ||
| } | ||
| public static readonly DependencyProperty IsPaneOpenProperty = | ||
| DependencyProperty.Register(nameof(IsPaneOpen), typeof(bool), typeof(SidebarView), new PropertyMetadata(false, OnPropertyChanged)); | ||
| [GeneratedDependencyProperty] | ||
| public partial bool IsPaneOpen { get; set; } | ||
|
|
||
| public double OpenPaneLength | ||
| { | ||
| get { return (double)GetValue(OpenPaneLengthProperty); } | ||
| set | ||
| { | ||
| SetValue(OpenPaneLengthProperty, value); | ||
| NegativeOpenPaneLength = -value; | ||
| } | ||
| } | ||
| public static readonly DependencyProperty OpenPaneLengthProperty = | ||
| DependencyProperty.Register(nameof(OpenPaneLength), typeof(double), typeof(SidebarView), new PropertyMetadata(240d, OnPropertyChanged)); | ||
| [GeneratedDependencyProperty(DefaultValue = 240D)] | ||
| public partial double OpenPaneLength { get; set; } | ||
|
|
||
| public double NegativeOpenPaneLength | ||
| { | ||
| get { return (double)GetValue(NegativeOpenPaneLengthProperty); } | ||
| set { SetValue(NegativeOpenPaneLengthProperty, value); } | ||
| } | ||
| public static readonly DependencyProperty NegativeOpenPaneLengthProperty = | ||
| DependencyProperty.Register(nameof(NegativeOpenPaneLength), typeof(double), typeof(SidebarView), new PropertyMetadata(null)); | ||
| [GeneratedDependencyProperty] | ||
| public partial double NegativeOpenPaneLength { get; set; } | ||
|
|
||
| public ISidebarViewModel ViewModel | ||
| { | ||
| get => (ISidebarViewModel)GetValue(ViewModelProperty); | ||
| set => SetValue(ViewModelProperty, value); | ||
| } | ||
| public static readonly DependencyProperty ViewModelProperty = | ||
| DependencyProperty.Register(nameof(ViewModel), typeof(ISidebarViewModel), typeof(SidebarView), new PropertyMetadata(null)); | ||
| [GeneratedDependencyProperty] | ||
| public partial ISidebarViewModel? ViewModel { get; set; } | ||
|
|
||
| [GeneratedDependencyProperty] | ||
| public partial ISidebarItemModel? SelectedItem { get; set; } | ||
|
|
||
| public ISidebarItemModel SelectedItem | ||
| [GeneratedDependencyProperty] | ||
| public partial object? MenuItemsSource { get; set; } | ||
|
|
||
| partial void OnDisplayModePropertyChanged(DependencyPropertyChangedEventArgs e) | ||
| { | ||
| get => (ISidebarItemModel)GetValue(SelectedItemProperty); | ||
| set | ||
| { | ||
| SetValue(SelectedItemProperty, value); | ||
| } | ||
| UpdateDisplayMode(); | ||
| } | ||
| public static readonly DependencyProperty SelectedItemProperty = | ||
| DependencyProperty.Register(nameof(SelectedItem), typeof(ISidebarItemModel), typeof(SidebarView), new PropertyMetadata(null)); | ||
|
|
||
| public object MenuItemsSource | ||
| partial void OnIsPaneOpenPropertyChanged(DependencyPropertyChangedEventArgs e) | ||
| { | ||
| get => (object)GetValue(MenuItemsSourceProperty); | ||
| set => SetValue(MenuItemsSourceProperty, value); | ||
| UpdateMinimalMode(); | ||
| } | ||
| public static readonly DependencyProperty MenuItemsSourceProperty = | ||
| DependencyProperty.Register(nameof(MenuItemsSource), typeof(object), typeof(SidebarView), new PropertyMetadata(null)); | ||
|
|
||
| public static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) | ||
| partial void OnOpenPaneLengthPropertyChanged(DependencyPropertyChangedEventArgs e) | ||
| { | ||
| if (sender is not SidebarView control) return; | ||
|
|
||
| if (e.Property == OpenPaneLengthProperty) | ||
| { | ||
| control.UpdateOpenPaneLengthColumn(); | ||
| } | ||
| else if (e.Property == DisplayModeProperty) | ||
| { | ||
| control.UpdateDisplayMode(); | ||
| } | ||
| else if (e.Property == IsPaneOpenProperty) | ||
| { | ||
| control.UpdateMinimalMode(); | ||
| } | ||
| NegativeOpenPaneLength = -(double)(e.NewValue); | ||
| UpdateOpenPaneLengthColumn(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.