Skip to content

Code Quality: Added feature flag to developer environment to enable 'Shelf Pane' #16667

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

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Files.App/Data/Contracts/IGeneralSettingsService.cs
Original file line number Diff line number Diff line change
@@ -289,5 +289,10 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
/// Gets or sets a value indicating the default arrangement for Dual Pane.
/// </summary>
ShellPaneArrangement ShellPaneArrangementOption { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to show the shelf pane.
/// </summary>
bool ShowShelfPane { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Files.App/Services/Settings/GeneralSettingsService.cs
Original file line number Diff line number Diff line change
@@ -357,6 +357,12 @@ public ShellPaneArrangement ShellPaneArrangementOption
set => Set((long)value);
}

public bool ShowShelfPane
{
get => Get(false);
set => Set(value);
}

protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
base.RaiseOnSettingChangedEvent(sender, e);
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
@@ -4019,4 +4019,7 @@
<data name="AlwaysSwitchToNewlyOpenedTab" xml:space="preserve">
<value>Always switch focus to newly created tab</value>
</data>
<data name="ShowShelfPane" xml:space="preserve">
<value>Show Shelf Pane</value>
</data>
</root>
22 changes: 22 additions & 0 deletions src/Files.App/UserControls/Pane/ShelfPane.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
<UserControl
x:Class="Files.App.UserControls.ShelfPane"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Files.App.Controls"
xmlns:converters="using:Files.App.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:Files.App.Data.Items"
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:usercontrols="using:Files.App.UserControls"
mc:Ignorable="d">

<Grid
Width="240"
Background="{ThemeResource App.Theme.InfoPane.BackgroundBrush}"
BackgroundSizing="InnerBorderEdge"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8" />
</UserControl>
15 changes: 15 additions & 0 deletions src/Files.App/UserControls/Pane/ShelfPane.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml.Controls;

namespace Files.App.UserControls
{
public sealed partial class ShelfPane : UserControl
{
public ShelfPane()
{
InitializeComponent();
}
}
}
14 changes: 14 additions & 0 deletions src/Files.App/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ public sealed class MainPageViewModel : ObservableObject
// Dependency injections

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

public bool ShowShelfPane
=> GeneralSettingsService.ShowShelfPane && AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;

public Stretch AppThemeBackgroundImageFit
=> AppearanceSettingsService.AppThemeBackgroundImageFit;

@@ -130,6 +134,16 @@ public MainPageViewModel()
break;
}
};

GeneralSettingsService.PropertyChanged += (s, e) =>
{
switch (e.PropertyName)
{
case nameof(GeneralSettingsService.ShowShelfPane):
OnPropertyChanged(nameof(ShowShelfPane));
break;
}
};
}

// Methods
16 changes: 15 additions & 1 deletion src/Files.App/ViewModels/Settings/AdvancedViewModel.cs
Original file line number Diff line number Diff line change
@@ -292,7 +292,7 @@ public bool IsSetAsOpenFileDialog
set => SetProperty(ref isSetAsOpenFileDialog, value);
}

public bool CanShowSetAsOpenFileDialog
public bool IsAppEnvironmentDev
{
get => AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;
}
@@ -366,6 +366,20 @@ public bool ShowFlattenOptions
OnPropertyChanged();
}
}

// TODO remove when feature is marked as stable
public bool ShowShelfPane
{
get => UserSettingsService.GeneralSettingsService.ShowShelfPane;
set
{
if (value == UserSettingsService.GeneralSettingsService.ShowShelfPane)
return;

UserSettingsService.GeneralSettingsService.ShowShelfPane = value;
OnPropertyChanged();
}
}

public async Task OpenFilesOnWindowsStartupAsync()
{
8 changes: 8 additions & 0 deletions src/Files.App/Views/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -193,6 +193,7 @@
MinWidth="208" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition x:Name="PaneColumn" Width="Auto" />
<ColumnDefinition x:Name="ShelfPaneColumn" Width="Auto" />
</Grid.ColumnDefinitions>

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

<uc:ShelfPane
x:Name="ShelfPane"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="3"
Margin="4,0,0,0"
x:Load="{x:Bind ViewModel.ShowShelfPane, Mode=OneWay}" />
</Grid>
</sidebar:SidebarView.InnerContent>
</sidebar:SidebarView>
17 changes: 16 additions & 1 deletion src/Files.App/Views/Settings/AdvancedPage.xaml
Original file line number Diff line number Diff line change
@@ -169,7 +169,7 @@
x:Name="ReplaceOpenFileDialogSetting"
Title="{helpers:ResourceString Name=SettingsSetAsOpenDialog}"
HorizontalAlignment="Stretch"
x:Load="{x:Bind ViewModel.CanShowSetAsOpenFileDialog}">
x:Load="{x:Bind ViewModel.IsAppEnvironmentDev}">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE8E5;" />
</local:SettingsBlockControl.Icon>
@@ -185,6 +185,21 @@
</ToggleSwitch>
</local:SettingsBlockControl>

<!-- Show Shelf Pane -->
<local:SettingsBlockControl
x:Name="ShowShelfPane"
Title="{helpers:ResourceString Name=ShowShelfPane}"
HorizontalAlignment="Stretch"
x:Load="{x:Bind ViewModel.IsAppEnvironmentDev}">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE90D;" />
</local:SettingsBlockControl.Icon>
<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ShowShelfPane}"
IsOn="{x:Bind ViewModel.ShowShelfPane, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Flatten options -->
<local:SettingsBlockControl
Title="{helpers:ResourceString Name=ShowFlattenOptions}"