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

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

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

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

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

public bool IsOn =>
SidebarViewModel.SidebarDisplayMode is SidebarDisplayMode.Expanded

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

The type or namespace name 'SidebarDisplayMode' could not be found (are you missing a using directive or an assembly reference?)

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

The type or namespace name 'SidebarDisplayMode' could not be found (are you missing a using directive or an assembly reference?)

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

The type or namespace name 'SidebarDisplayMode' could not be found (are you missing a using directive or an assembly reference?)

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

The type or namespace name 'SidebarDisplayMode' could not be found (are you missing a using directive or an assembly reference?)
? true
: false;

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

public Task ExecuteAsync(object? parameter = null)
{
SidebarViewModel.SidebarDisplayMode = IsOn
? SidebarDisplayMode.Expanded

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

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

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

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

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

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

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

The name 'SidebarDisplayMode' does not exist in the current context
: SidebarDisplayMode.Compact;

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

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

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

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

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

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

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

The name 'SidebarDisplayMode' does not exist in the current context
return Task.CompletedTask;
}

private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(SidebarViewModel.SidebarDisplayMode))
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,
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