-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rich Commands: Toggle sidebar (#11847)
Co-authored-by: Yair <[email protected]>
- Loading branch information
1 parent
443a71e
commit bb138fd
Showing
8 changed files
with
51 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Extensions; | ||
using Files.App.ViewModels; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class ToggleSidebarAction : ObservableObject, IToggleAction | ||
{ | ||
private readonly SidebarViewModel viewModel = Ioc.Default.GetRequiredService<SidebarViewModel>(); | ||
|
||
public string Label { get; } = "ToggleSidebar".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "TODO: Need to be described."; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.B, VirtualKeyModifiers.Control); | ||
|
||
public bool IsOn => viewModel.IsSidebarOpen; | ||
|
||
public ToggleSidebarAction() | ||
{ | ||
viewModel.PropertyChanged += ViewModel_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
viewModel.IsSidebarOpen = !IsOn; | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(SidebarViewModel.IsSidebarOpen)) | ||
OnPropertyChanged(nameof(IsOn)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters