Skip to content
Merged
Show file tree
Hide file tree
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
48 changes: 48 additions & 0 deletions src/Files.App/Actions/Show/ToggleShelfPaneAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

namespace Files.App.Actions
{
internal sealed class ToggleShelfPaneAction : ObservableObject, IToggleAction
{
private readonly IGeneralSettingsService generalSettingsService = Ioc.Default.GetRequiredService<IGeneralSettingsService>();

public string Label
=> Strings.ToggleShelfPane.GetLocalizedResource();

public string Description
=> Strings.ToggleShelfPaneDescription.GetLocalizedResource();

public RichGlyph Glyph
=> new(themedIconStyle: "App.ThemedIcons.Shelf");

// TODO Remove IsAccessibleGlobally when shelf feature is ready
public bool IsAccessibleGlobally
=> AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;

// TODO Remove IsExecutable when shelf feature is ready
public bool IsExecutable
=> AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;

public bool IsOn
=> generalSettingsService.ShowShelfPane;

public ToggleShelfPaneAction()
{
generalSettingsService.PropertyChanged += GeneralSettingsService_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
generalSettingsService.ShowShelfPane = !IsOn;

return Task.CompletedTask;
}

private void GeneralSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(GeneralSettingsService.ShowShelfPane))
OnPropertyChanged(nameof(IsOn));
}
}
}
1 change: 1 addition & 0 deletions src/Files.App/Data/Commands/Manager/CommandCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum CommandCodes
ToggleDetailsPane,
ToggleInfoPane,
ToggleToolbar,
ToggleShelfPane,

// File System
CopyItem,
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Data/Commands/Manager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public IRichCommand this[HotKey hotKey]
public IRichCommand ToggleDetailsPane => commands[CommandCodes.ToggleDetailsPane];
public IRichCommand ToggleInfoPane => commands[CommandCodes.ToggleInfoPane];
public IRichCommand ToggleToolbar => commands[CommandCodes.ToggleToolbar];
public IRichCommand ToggleShelfPane => commands[CommandCodes.ToggleShelfPane];
public IRichCommand SelectAll => commands[CommandCodes.SelectAll];
public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection];
public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection];
Expand Down Expand Up @@ -260,6 +261,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
[CommandCodes.ToggleDetailsPane] = new ToggleDetailsPaneAction(),
[CommandCodes.ToggleInfoPane] = new ToggleInfoPaneAction(),
[CommandCodes.ToggleToolbar] = new ToggleToolbarAction(),
[CommandCodes.ToggleShelfPane] = new ToggleShelfPaneAction(),
[CommandCodes.SelectAll] = new SelectAllAction(),
[CommandCodes.InvertSelection] = new InvertSelectionAction(),
[CommandCodes.ClearSelection] = new ClearSelectionAction(),
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Data/Commands/Manager/ICommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
IRichCommand ToggleDetailsPane { get; }
IRichCommand ToggleInfoPane { get; }
IRichCommand ToggleToolbar { get; }
IRichCommand ToggleShelfPane { get; }

IRichCommand CopyItem { get; }
IRichCommand CopyItemPath { get; }
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/Data/Items/ShelfItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Files.Shared.Utils;
// Copyright (c) Files Community
// Licensed under the MIT License.

using Files.Shared.Utils;

namespace Files.App.Data.Items
{
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -4022,6 +4022,9 @@
<data name="ToggleShelfPane" xml:space="preserve">
<value>Toggle the shelf pane</value>
</data>
<data name="ToggleShelfPaneDescription" xml:space="preserve">
<value>Toggle the shelf pane visibility</value>
</data>
<data name="ShowShelfPaneButtonInAddressBar" xml:space="preserve">
<value>Show shelf pane toggle in address bar</value>
</data>
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/UserControls/AddressToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,17 @@

<!-- Shelf Pane -->
<ToggleButton
x:Name="OpenShelfPaneButton"
x:Name="ShelfPaneToggleButton"
Width="36"
Height="32"
Padding="0"
x:Load="{x:Bind ViewModel.ShowShelfPaneToggleButton, Mode=OneWay}"
AccessKeyInvoked="Button_AccessKeyInvoked"
AutomationProperties.Name="{helpers:ResourceString Name=ToggleShelfPane}"
AutomationProperties.Name="{x:Bind ViewModel.Commands.ToggleShelfPane.Label}"
Background="Transparent"
BorderBrush="Transparent"
IsChecked="{x:Bind ViewModel.ShowShelfPane, Mode=TwoWay}"
ToolTipService.ToolTip="{helpers:ResourceString Name=ToggleShelfPane}">
IsChecked="{x:Bind Commands.ToggleShelfPane.IsOn, Mode=TwoWay}"
ToolTipService.ToolTip="{x:Bind ViewModel.Commands.ToggleShelfPane.LabelWithHotKey, Mode=OneWay}">
<controls:ThemedIcon
Width="20"
Height="20"
Expand Down
24 changes: 0 additions & 24 deletions src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,6 @@ public bool ShowHomeButton
public bool ShowShelfPaneToggleButton
=> AppearanceSettingsService.ShowShelfPaneToggleButton && AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;


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

GeneralSettingsService.ShowShelfPane = value;
}
}

public ObservableCollection<NavigationBarSuggestionItem> NavigationBarSuggestions = [];

private CurrentInstanceViewModel instanceViewModel;
Expand Down Expand Up @@ -236,16 +222,6 @@ public AddressToolbarViewModel()
break;
}
};

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

private async void UpdateService_OnPropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
5 changes: 4 additions & 1 deletion src/Files.Shared/Utils/IAsyncInitialize.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Threading;
// Copyright (c) Files Community
// Licensed under the MIT License.

using System.Threading;
using System.Threading.Tasks;

namespace Files.Shared.Utils
Expand Down
5 changes: 4 additions & 1 deletion src/Files.Shared/Utils/IWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Files.Shared.Utils
// Copyright (c) Files Community
// Licensed under the MIT License.

namespace Files.Shared.Utils
{
/// <summary>
/// Wraps and exposes <typeparamref name="T"/> implementation for access.
Expand Down
Loading