Skip to content

Commit 6573831

Browse files
authored
Code Quality: Added feature flag to developer environment to enable 'Shelf Pane' (#16667)
1 parent 84a35eb commit 6573831

File tree

9 files changed

+104
-2
lines changed

9 files changed

+104
-2
lines changed

src/Files.App/Data/Contracts/IGeneralSettingsService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,10 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
289289
/// Gets or sets a value indicating the default arrangement for Dual Pane.
290290
/// </summary>
291291
ShellPaneArrangement ShellPaneArrangementOption { get; set; }
292+
293+
/// <summary>
294+
/// Gets or sets a value indicating whether or not to show the shelf pane.
295+
/// </summary>
296+
bool ShowShelfPane { get; set; }
292297
}
293298
}

src/Files.App/Services/Settings/GeneralSettingsService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ public ShellPaneArrangement ShellPaneArrangementOption
357357
set => Set((long)value);
358358
}
359359

360+
public bool ShowShelfPane
361+
{
362+
get => Get(false);
363+
set => Set(value);
364+
}
365+
360366
protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
361367
{
362368
base.RaiseOnSettingChangedEvent(sender, e);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4019,4 +4019,7 @@
40194019
<data name="AlwaysSwitchToNewlyOpenedTab" xml:space="preserve">
40204020
<value>Always switch focus to newly created tab</value>
40214021
</data>
4022+
<data name="ShowShelfPane" xml:space="preserve">
4023+
<value>Show Shelf Pane</value>
4024+
</data>
40224025
</root>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
2+
<UserControl
3+
x:Class="Files.App.UserControls.ShelfPane"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:controls="using:Files.App.Controls"
7+
xmlns:converters="using:Files.App.Converters"
8+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
9+
xmlns:data="using:Files.App.Data.Items"
10+
xmlns:helpers="using:Files.App.Helpers"
11+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
12+
xmlns:usercontrols="using:Files.App.UserControls"
13+
mc:Ignorable="d">
14+
15+
<Grid
16+
Width="240"
17+
Background="{ThemeResource App.Theme.InfoPane.BackgroundBrush}"
18+
BackgroundSizing="InnerBorderEdge"
19+
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
20+
BorderThickness="1"
21+
CornerRadius="8" />
22+
</UserControl>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.UI.Xaml.Controls;
5+
6+
namespace Files.App.UserControls
7+
{
8+
public sealed partial class ShelfPane : UserControl
9+
{
10+
public ShelfPane()
11+
{
12+
InitializeComponent();
13+
}
14+
}
15+
}

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public sealed class MainPageViewModel : ObservableObject
2020
// Dependency injections
2121

2222
private IAppearanceSettingsService AppearanceSettingsService { get; } = Ioc.Default.GetRequiredService<IAppearanceSettingsService>();
23+
private IGeneralSettingsService GeneralSettingsService { get; } = Ioc.Default.GetRequiredService<IGeneralSettingsService>();
2324
private INetworkService NetworkService { get; } = Ioc.Default.GetRequiredService<INetworkService>();
2425
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
2526
private IResourcesService ResourcesService { get; } = Ioc.Default.GetRequiredService<IResourcesService>();
@@ -75,6 +76,9 @@ public bool ShouldPreviewPaneBeDisplayed
7576
set => SetProperty(ref shouldPreviewPaneBeDisplayed, value);
7677
}
7778

79+
public bool ShowShelfPane
80+
=> GeneralSettingsService.ShowShelfPane && AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;
81+
7882
public Stretch AppThemeBackgroundImageFit
7983
=> AppearanceSettingsService.AppThemeBackgroundImageFit;
8084

@@ -130,6 +134,16 @@ public MainPageViewModel()
130134
break;
131135
}
132136
};
137+
138+
GeneralSettingsService.PropertyChanged += (s, e) =>
139+
{
140+
switch (e.PropertyName)
141+
{
142+
case nameof(GeneralSettingsService.ShowShelfPane):
143+
OnPropertyChanged(nameof(ShowShelfPane));
144+
break;
145+
}
146+
};
133147
}
134148

135149
// Methods

src/Files.App/ViewModels/Settings/AdvancedViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public bool IsSetAsOpenFileDialog
292292
set => SetProperty(ref isSetAsOpenFileDialog, value);
293293
}
294294

295-
public bool CanShowSetAsOpenFileDialog
295+
public bool IsAppEnvironmentDev
296296
{
297297
get => AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;
298298
}
@@ -366,6 +366,20 @@ public bool ShowFlattenOptions
366366
OnPropertyChanged();
367367
}
368368
}
369+
370+
// TODO remove when feature is marked as stable
371+
public bool ShowShelfPane
372+
{
373+
get => UserSettingsService.GeneralSettingsService.ShowShelfPane;
374+
set
375+
{
376+
if (value == UserSettingsService.GeneralSettingsService.ShowShelfPane)
377+
return;
378+
379+
UserSettingsService.GeneralSettingsService.ShowShelfPane = value;
380+
OnPropertyChanged();
381+
}
382+
}
369383

370384
public async Task OpenFilesOnWindowsStartupAsync()
371385
{

src/Files.App/Views/MainPage.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
MinWidth="208" />
194194
<ColumnDefinition Width="Auto" />
195195
<ColumnDefinition x:Name="PaneColumn" Width="Auto" />
196+
<ColumnDefinition x:Name="ShelfPaneColumn" Width="Auto" />
196197
</Grid.ColumnDefinitions>
197198

198199
<!-- File Navigation Toolbar -->
@@ -247,6 +248,13 @@
247248
ShowInfoText="{x:Bind SidebarAdaptiveViewModel.PaneHolder.ActivePaneOrColumn.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
248249
Visibility="{x:Bind SidebarAdaptiveViewModel.PaneHolder.ActivePaneOrColumn.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}" />
249250

251+
<uc:ShelfPane
252+
x:Name="ShelfPane"
253+
Grid.Row="0"
254+
Grid.RowSpan="2"
255+
Grid.Column="3"
256+
Margin="4,0,0,0"
257+
x:Load="{x:Bind ViewModel.ShowShelfPane, Mode=OneWay}" />
250258
</Grid>
251259
</sidebar:SidebarView.InnerContent>
252260
</sidebar:SidebarView>

src/Files.App/Views/Settings/AdvancedPage.xaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
x:Name="ReplaceOpenFileDialogSetting"
170170
Title="{helpers:ResourceString Name=SettingsSetAsOpenDialog}"
171171
HorizontalAlignment="Stretch"
172-
x:Load="{x:Bind ViewModel.CanShowSetAsOpenFileDialog}">
172+
x:Load="{x:Bind ViewModel.IsAppEnvironmentDev}">
173173
<local:SettingsBlockControl.Icon>
174174
<FontIcon Glyph="&#xE8E5;" />
175175
</local:SettingsBlockControl.Icon>
@@ -185,6 +185,21 @@
185185
</ToggleSwitch>
186186
</local:SettingsBlockControl>
187187

188+
<!-- Show Shelf Pane -->
189+
<local:SettingsBlockControl
190+
x:Name="ShowShelfPane"
191+
Title="{helpers:ResourceString Name=ShowShelfPane}"
192+
HorizontalAlignment="Stretch"
193+
x:Load="{x:Bind ViewModel.IsAppEnvironmentDev}">
194+
<local:SettingsBlockControl.Icon>
195+
<FontIcon Glyph="&#xE90D;" />
196+
</local:SettingsBlockControl.Icon>
197+
<ToggleSwitch
198+
AutomationProperties.Name="{helpers:ResourceString Name=ShowShelfPane}"
199+
IsOn="{x:Bind ViewModel.ShowShelfPane, Mode=TwoWay}"
200+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
201+
</local:SettingsBlockControl>
202+
188203
<!-- Flatten options -->
189204
<local:SettingsBlockControl
190205
Title="{helpers:ResourceString Name=ShowFlattenOptions}"

0 commit comments

Comments
 (0)