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

namespace Files.App.Actions
{
internal sealed class ToggleSidebarAction : IToggleAction
{
private IAppearanceSettingsService AppearanceSettingsService { get; } = Ioc.Default.GetRequiredService<IAppearanceSettingsService>();

public string Label
=> "ToggleSidebar".GetLocalizedResource();

public string Description
=> "ToggleSidebarDescription".GetLocalizedResource();

public HotKey HotKey
=> new(Keys.S, KeyModifiers.CtrlAlt);

public bool IsOn
=> AppearanceSettingsService.IsSidebarOpen;

public ToggleSidebarAction()
{
AppearanceSettingsService.PropertyChanged += ViewModel_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
AppearanceSettingsService.IsSidebarOpen = !IsOn;

return Task.CompletedTask;
}

private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(AppearanceSettingsService.IsSidebarOpen))
OnPropertyChanged(nameof(IsOn));

Check failure on line 37 in src/Files.App/Actions/Show/ToggleSidebarAction.cs

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

The name 'OnPropertyChanged' does not exist in the current context

Check failure on line 37 in src/Files.App/Actions/Show/ToggleSidebarAction.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

The name 'OnPropertyChanged' does not exist in the current context

Check failure on line 37 in src/Files.App/Actions/Show/ToggleSidebarAction.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

The name 'OnPropertyChanged' does not exist in the current context

Check failure on line 37 in src/Files.App/Actions/Show/ToggleSidebarAction.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

The name 'OnPropertyChanged' does not exist in the current context
}
}
}
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,
ToggleSidebar,

// 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 ToggleSidebar => commands[CommandCodes.ToggleSidebar];
public IRichCommand SelectAll => commands[CommandCodes.SelectAll];
public IRichCommand InvertSelection => commands[CommandCodes.InvertSelection];
public IRichCommand ClearSelection => commands[CommandCodes.ClearSelection];
Expand Down Expand Up @@ -253,6 +254,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
[CommandCodes.ToggleDetailsPane] = new ToggleDetailsPaneAction(),
[CommandCodes.ToggleInfoPane] = new ToggleInfoPaneAction(),
[CommandCodes.ToggleToolbar] = new ToggleToolbarAction(),
[CommandCodes.ToggleSidebar] = new ToggleSidebarAction(),
[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 ToggleSidebar { get; }

IRichCommand CopyItem { get; }
IRichCommand CopyItemPath { get; }
Expand Down
Loading