Skip to content

Commit 7c96be6

Browse files
authored
Code Quality: Updated existing pane toggles to prepare for upcoming Shelf feature (#16686)
1 parent ed29071 commit 7c96be6

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/Files.App/Actions/Show/ToggleDetailsPaneAction.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,33 @@
33

44
namespace Files.App.Actions
55
{
6-
internal sealed class ToggleDetailsPaneAction : ObservableObject, IToggleAction
6+
internal sealed class ToggleDetailsPaneAction : ObservableObject, IAction
77
{
8-
private readonly InfoPaneViewModel viewModel;
8+
private readonly InfoPaneViewModel infoPaneViewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
99
private readonly IInfoPaneSettingsService infoPaneSettingsService = Ioc.Default.GetRequiredService<IInfoPaneSettingsService>();
1010

1111
public string Label
12-
=> "ToggleDetailsPane".GetLocalizedResource();
12+
=> Strings.ToggleDetailsPane.GetLocalizedResource();
1313

1414
public string Description
15-
=> "ToggleDetailsPaneDescription".GetLocalizedResource();
15+
=> Strings.ToggleDetailsPaneDescription.GetLocalizedResource();
1616

1717
public RichGlyph Glyph
1818
=> new(themedIconStyle: "App.ThemedIcons.PanelRight");
1919

20-
public HotKey HotKey
21-
=> new(Keys.D, KeyModifiers.CtrlAlt);
20+
public bool IsAccessibleGlobally
21+
=> false;
2222

23-
public bool IsOn
24-
=> viewModel.IsEnabled;
23+
public bool IsExecutable
24+
=> infoPaneViewModel.IsEnabled;
2525

2626
public ToggleDetailsPaneAction()
2727
{
28-
viewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
29-
viewModel.PropertyChanged += ViewModel_PropertyChanged;
28+
infoPaneViewModel.PropertyChanged += ViewModel_PropertyChanged;
3029
}
3130

3231
public Task ExecuteAsync(object? parameter = null)
3332
{
34-
viewModel.IsEnabled = true;
3533
infoPaneSettingsService.SelectedTab = InfoPaneTabs.Details;
3634

3735
return Task.CompletedTask;
@@ -40,7 +38,7 @@ public Task ExecuteAsync(object? parameter = null)
4038
private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
4139
{
4240
if (e.PropertyName is nameof(InfoPaneViewModel.IsEnabled))
43-
OnPropertyChanged(nameof(IsOn));
41+
OnPropertyChanged(nameof(IsExecutable));
4442
}
4543
}
4644
}

src/Files.App/Actions/Show/TogglePreviewPaneAction.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,33 @@
33

44
namespace Files.App.Actions
55
{
6-
internal sealed class TogglePreviewPaneAction : ObservableObject, IToggleAction
6+
internal sealed class TogglePreviewPaneAction : ObservableObject, IAction
77
{
8-
private readonly InfoPaneViewModel viewModel;
8+
private readonly InfoPaneViewModel infoPaneViewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
99
private readonly IInfoPaneSettingsService infoPaneSettingsService = Ioc.Default.GetRequiredService<IInfoPaneSettingsService>();
1010

1111
public string Label
12-
=> "TogglePreviewPane".GetLocalizedResource();
12+
=> Strings.TogglePreviewPane.GetLocalizedResource();
1313

1414
public string Description
15-
=> "TogglePreviewPaneDescription".GetLocalizedResource();
15+
=> Strings.TogglePreviewPaneDescription.GetLocalizedResource();
1616

1717
public RichGlyph Glyph
1818
=> new(themedIconStyle: "App.ThemedIcons.PanelRight");
1919

20-
public HotKey HotKey
21-
=> new(Keys.P, KeyModifiers.CtrlAlt);
20+
public bool IsAccessibleGlobally
21+
=> false;
2222

23-
public bool IsOn
24-
=> viewModel.IsEnabled;
23+
public bool IsExecutable
24+
=> infoPaneViewModel.IsEnabled;
2525

2626
public TogglePreviewPaneAction()
2727
{
28-
viewModel = Ioc.Default.GetRequiredService<InfoPaneViewModel>();
29-
viewModel.PropertyChanged += ViewModel_PropertyChanged;
28+
infoPaneViewModel.PropertyChanged += ViewModel_PropertyChanged;
3029
}
3130

3231
public Task ExecuteAsync(object? parameter = null)
3332
{
34-
viewModel.IsEnabled = true;
3533
infoPaneSettingsService.SelectedTab = InfoPaneTabs.Preview;
3634

3735
return Task.CompletedTask;
@@ -40,7 +38,7 @@ public Task ExecuteAsync(object? parameter = null)
4038
private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
4139
{
4240
if (e.PropertyName is nameof(InfoPaneViewModel.IsEnabled))
43-
OnPropertyChanged(nameof(IsOn));
41+
OnPropertyChanged(nameof(IsExecutable));
4442
}
4543
}
4644
}

0 commit comments

Comments
 (0)