Skip to content

Commit ba4fb0f

Browse files
authored
Feature: Display placeholder when sidebar sections are all hidden (#17039)
1 parent e7fbf05 commit ba4fb0f

12 files changed

+310
-2
lines changed

src/Files.App.Controls/Sidebar/SidebarView.Properties.cs

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public UIElement InnerContent
2121
public static readonly DependencyProperty InnerContentProperty =
2222
DependencyProperty.Register(nameof(InnerContent), typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null));
2323

24+
public UIElement SidebarContent
25+
{
26+
get { return (UIElement)GetValue(SidebarContentProperty); }
27+
set { SetValue(SidebarContentProperty, value); }
28+
}
29+
public static readonly DependencyProperty SidebarContentProperty =
30+
DependencyProperty.Register("SidebarContent", typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null));
31+
2432
public UIElement Footer
2533
{
2634
get { return (UIElement)GetValue(FooterProperty); }

src/Files.App.Controls/Sidebar/SidebarView.xaml

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@
5757
<CompositeTransform x:Name="PaneColumnGridTransform" />
5858
</Grid.RenderTransform>
5959

60+
<!-- Content -->
61+
<ContentPresenter
62+
Grid.RowSpan="2"
63+
HorizontalAlignment="Stretch"
64+
VerticalAlignment="Stretch"
65+
HorizontalContentAlignment="Stretch"
66+
VerticalContentAlignment="Stretch"
67+
Content="{x:Bind SidebarContent, Mode=OneWay}" />
68+
6069
<!-- Menu Items -->
6170
<ItemsRepeaterScrollHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
6271
<ScrollViewer
Loading
Loading
Loading
Loading
Loading
Loading

src/Files.App/Strings/en-US/Resources.resw

+5-2
Original file line numberDiff line numberDiff line change
@@ -3508,7 +3508,7 @@
35083508
<data name="StatusCenter_GitCloneInProgress_SubHeader" xml:space="preserve">
35093509
<value>Cloning {0} from "{1}" to "{2}"</value>
35103510
<comment>Shown in a StatusCenter card.</comment>
3511-
</data>
3511+
</data>
35123512
<data name="StatusCenter_InstallFontCanceled_Header" xml:space="preserve">
35133513
<value>Canceled installing {0} fonts</value>
35143514
<comment>Shown in a StatusCenter card.</comment>
@@ -3540,7 +3540,7 @@
35403540
<data name="StatusCenter_InstallFontInProgress_SubHeader" xml:space="preserve">
35413541
<value>Installing {0} font(s) from "{1}"</value>
35423542
<comment>Shown in a StatusCenter card.</comment>
3543-
</data>
3543+
</data>
35443544
<data name="StatusCenter_CopyCanceled_Header" xml:space="preserve">
35453545
<value>Canceled copying {0} item(s) to "{1}"</value>
35463546
<comment>Shown in a StatusCenter card.</comment>
@@ -4193,4 +4193,7 @@
41934193
<data name="EnableOmnibar" xml:space="preserve">
41944194
<value>Enable Omnibar</value>
41954195
</data>
4196+
<data name="SectionsHiddenMessage" xml:space="preserve">
4197+
<value>You can add sections to the sidebar by right-clicking and selecting the sections you want to add.</value>
4198+
</data>
41964199
</root>

src/Files.App/ViewModels/UserControls/SidebarViewModel.cs

+18
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public SidebarDisplayMode SidebarDisplayMode
5959
if (SetProperty(ref sidebarDisplayMode, value))
6060
{
6161
OnPropertyChanged(nameof(IsSidebarCompactSize));
62+
OnPropertyChanged(nameof(AreSectionsHidden));
6263
IsSidebarOpen = sidebarDisplayMode == SidebarDisplayMode.Expanded;
6364
UpdateTabControlMargin();
6465
}
@@ -134,6 +135,16 @@ public bool IsSidebarOpen
134135
}
135136
}
136137

138+
public bool AreSectionsHidden =>
139+
!ShowPinnedFoldersSection &&
140+
!ShowLibrarySection &&
141+
!ShowDrivesSection &&
142+
!ShowCloudDrivesSection &&
143+
!ShowNetworkSection &&
144+
(!ShowWslSection || WSLDistroManager.Distros.Any() == false) &&
145+
!ShowFileTagsSection &&
146+
SidebarDisplayMode is not SidebarDisplayMode.Compact;
147+
137148
public bool ShowPinnedFoldersSection
138149
{
139150
get => UserSettingsService.GeneralSettingsService.ShowPinnedSection;
@@ -635,30 +646,37 @@ private async void UserSettingsService_OnSettingChangedEvent(object sender, Sett
635646
case nameof(UserSettingsService.GeneralSettingsService.ShowPinnedSection):
636647
await UpdateSectionVisibilityAsync(SectionType.Pinned, ShowPinnedFoldersSection);
637648
OnPropertyChanged(nameof(ShowPinnedFoldersSection));
649+
OnPropertyChanged(nameof(AreSectionsHidden));
638650
break;
639651
case nameof(UserSettingsService.GeneralSettingsService.ShowLibrarySection):
640652
await UpdateSectionVisibilityAsync(SectionType.Library, ShowLibrarySection);
641653
OnPropertyChanged(nameof(ShowLibrarySection));
654+
OnPropertyChanged(nameof(AreSectionsHidden));
642655
break;
643656
case nameof(UserSettingsService.GeneralSettingsService.ShowCloudDrivesSection):
644657
await UpdateSectionVisibilityAsync(SectionType.CloudDrives, ShowCloudDrivesSection);
645658
OnPropertyChanged(nameof(ShowCloudDrivesSection));
659+
OnPropertyChanged(nameof(AreSectionsHidden));
646660
break;
647661
case nameof(UserSettingsService.GeneralSettingsService.ShowDrivesSection):
648662
await UpdateSectionVisibilityAsync(SectionType.Drives, ShowDrivesSection);
649663
OnPropertyChanged(nameof(ShowDrivesSection));
664+
OnPropertyChanged(nameof(AreSectionsHidden));
650665
break;
651666
case nameof(UserSettingsService.GeneralSettingsService.ShowNetworkSection):
652667
await UpdateSectionVisibilityAsync(SectionType.Network, ShowNetworkSection);
653668
OnPropertyChanged(nameof(ShowNetworkSection));
669+
OnPropertyChanged(nameof(AreSectionsHidden));
654670
break;
655671
case nameof(UserSettingsService.GeneralSettingsService.ShowWslSection):
656672
await UpdateSectionVisibilityAsync(SectionType.WSL, ShowWslSection);
657673
OnPropertyChanged(nameof(ShowWslSection));
674+
OnPropertyChanged(nameof(AreSectionsHidden));
658675
break;
659676
case nameof(UserSettingsService.GeneralSettingsService.ShowFileTagsSection):
660677
await UpdateSectionVisibilityAsync(SectionType.FileTag, ShowFileTagsSection);
661678
OnPropertyChanged(nameof(ShowFileTagsSection));
679+
OnPropertyChanged(nameof(AreSectionsHidden));
662680
break;
663681
}
664682
}

0 commit comments

Comments
 (0)