Skip to content

Commit ba4fb0f

Browse files
authoredApr 22, 2025··
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
}

‎src/Files.App/Views/MainPage.xaml

+85
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@
3131
<ResourceDictionary Source="ms-appx:///Styles/DefaultGridSplitterStyle.xaml" />
3232
</ResourceDictionary.MergedDictionaries>
3333

34+
<ResourceDictionary.ThemeDictionaries>
35+
<ResourceDictionary x:Key="Light">
36+
<ImageSource x:Key="EmptySidebar.48">ms-appx:///Assets/Sidebar/EmptySidebar_48_ThemeLight.svg</ImageSource>
37+
<ImageSource x:Key="EmptySidebar.100">ms-appx:///Assets/Sidebar/EmptySidebar_100_ThemeLight.svg</ImageSource>
38+
<ImageSource x:Key="EmptySidebar.200">ms-appx:///Assets/Sidebar/EmptySidebar_200_ThemeLight.svg</ImageSource>
39+
</ResourceDictionary>
40+
<ResourceDictionary x:Key="Dark">
41+
<ImageSource x:Key="EmptySidebar.48">ms-appx:///Assets/Sidebar/EmptySidebar_48_ThemeDark.svg</ImageSource>
42+
<ImageSource x:Key="EmptySidebar.100">ms-appx:///Assets/Sidebar/EmptySidebar_100_ThemeDark.svg</ImageSource>
43+
<ImageSource x:Key="EmptySidebar.200">ms-appx:///Assets/Sidebar/EmptySidebar_200_ThemeDark.svg</ImageSource>
44+
</ResourceDictionary>
45+
<ResourceDictionary x:Key="HighContrast">
46+
<ImageSource x:Key="EmptySidebar.48">ms-appx:///Assets/Sidebar/EmptySidebar_48_ThemeDark.svg</ImageSource>
47+
<ImageSource x:Key="EmptySidebar.100">ms-appx:///Assets/Sidebar/EmptySidebar_100_ThemeDark.svg</ImageSource>
48+
<ImageSource x:Key="EmptySidebar.200">ms-appx:///Assets/Sidebar/EmptySidebar_200_ThemeDark.svg</ImageSource>
49+
</ResourceDictionary>
50+
</ResourceDictionary.ThemeDictionaries>
51+
3452
<x:Boolean x:Key="True">True</x:Boolean>
3553
<x:Boolean x:Key="False">False</x:Boolean>
3654

@@ -259,6 +277,32 @@
259277
</Grid>
260278
</controls:SidebarView.InnerContent>
261279

280+
<!-- Sidebar Content -->
281+
<controls:SidebarView.SidebarContent>
282+
<StackPanel
283+
x:Name="SidebarContent"
284+
Padding="16,0,16,0"
285+
VerticalAlignment="Center"
286+
Orientation="Vertical"
287+
Spacing="16"
288+
Visibility="{x:Bind SidebarAdaptiveViewModel.AreSectionsHidden, Mode=OneWay}">
289+
290+
<Image
291+
x:Name="EmptySidebarImage"
292+
MaxHeight="48"
293+
Source="{ThemeResource EmptySidebar.48}" />
294+
295+
<TextBlock
296+
MaxWidth="240"
297+
Foreground="{ThemeResource TextFillColorTertiaryBrush}"
298+
Style="{StaticResource App.Theme.CaptionTextBlockStyle}"
299+
Text="{helpers:ResourceString Name=SectionsHiddenMessage}"
300+
TextAlignment="Center" />
301+
302+
</StackPanel>
303+
</controls:SidebarView.SidebarContent>
304+
305+
<!-- Footer -->
262306
<controls:SidebarView.Footer>
263307
<StackPanel Padding="4" Spacing="4">
264308
<Border
@@ -322,6 +366,46 @@
322366
</controls:SidebarView>
323367

324368
<VisualStateManager.VisualStateGroups>
369+
<VisualStateGroup x:Name="SidebarWidthStates">
370+
<VisualState x:Name="SmallSidebarWidthState">
371+
<VisualState.Setters>
372+
<Setter Target="EmptySidebarImage.MaxHeight" Value="48" />
373+
<Setter Target="EmptySidebarImage.Source" Value="{ThemeResource EmptySidebar.48}" />
374+
</VisualState.Setters>
375+
</VisualState>
376+
<VisualState x:Name="MediumSidebarWidthState">
377+
<VisualState.Setters>
378+
<Setter Target="EmptySidebarImage.MaxHeight" Value="100" />
379+
<Setter Target="EmptySidebarImage.Source" Value="{ThemeResource EmptySidebar.100}" />
380+
</VisualState.Setters>
381+
</VisualState>
382+
<VisualState x:Name="LargeSidebarWidthState">
383+
<VisualState.Setters>
384+
<Setter Target="EmptySidebarImage.MaxHeight" Value="200" />
385+
<Setter Target="EmptySidebarImage.Source" Value="{ThemeResource EmptySidebar.200}" />
386+
</VisualState.Setters>
387+
</VisualState>
388+
</VisualStateGroup>
389+
390+
<VisualStateGroup x:Name="WindowHeightStates">
391+
<VisualState>
392+
<VisualState.StateTriggers>
393+
<AdaptiveTrigger x:Name="SmallHeightAdaptiveTrigger" MinWindowHeight="440" />
394+
</VisualState.StateTriggers>
395+
<VisualState.Setters>
396+
<Setter Target="EmptySidebarImage.Visibility" Value="Visible" />
397+
</VisualState.Setters>
398+
</VisualState>
399+
<VisualState>
400+
<VisualState.StateTriggers>
401+
<AdaptiveTrigger x:Name="MediumHeightAdaptiveTrigger" MinWindowHeight="0" />
402+
</VisualState.StateTriggers>
403+
<VisualState.Setters>
404+
<Setter Target="EmptySidebarImage.Visibility" Value="Collapsed" />
405+
</VisualState.Setters>
406+
</VisualState>
407+
</VisualStateGroup>
408+
325409
<VisualStateGroup>
326410
<VisualState>
327411
<VisualState.StateTriggers>
@@ -337,6 +421,7 @@
337421
</VisualState.Setters>
338422
</VisualState>
339423
</VisualStateGroup>
424+
340425
<VisualStateGroup>
341426
<VisualState x:Name="NormalSidebarState">
342427
<VisualState.StateTriggers>

‎src/Files.App/Views/MainPage.xaml.cs

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public MainPage()
5555
_updateDateDisplayTimer = DispatcherQueue.CreateTimer();
5656
_updateDateDisplayTimer.Interval = TimeSpan.FromSeconds(1);
5757
_updateDateDisplayTimer.Tick += UpdateDateDisplayTimer_Tick;
58+
59+
ApplySidebarWidthState();
5860
}
5961

6062
private async Task PromptForReviewAsync()
@@ -120,6 +122,9 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh
120122
case nameof(IInfoPaneSettingsService.IsInfoPaneEnabled):
121123
LoadPaneChanged();
122124
break;
125+
case nameof(IAppearanceSettingsService.SidebarWidth):
126+
ApplySidebarWidthState();
127+
break;
123128
}
124129
}
125130

@@ -434,6 +439,16 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl
434439
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
435440
}
436441

442+
private void ApplySidebarWidthState()
443+
{
444+
if (UserSettingsService.AppearanceSettingsService.SidebarWidth > 340)
445+
VisualStateManager.GoToState(this, "LargeSidebarWidthState", true);
446+
else if (UserSettingsService.AppearanceSettingsService.SidebarWidth > 280)
447+
VisualStateManager.GoToState(this, "MediumSidebarWidthState", true);
448+
else
449+
VisualStateManager.GoToState(this, "SmallSidebarWidthState", true);
450+
}
451+
437452
private void LoadPaneChanged()
438453
{
439454
try

0 commit comments

Comments
 (0)
Please sign in to comment.