|
| 1 | +// Copyright (c) Files Community |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +namespace Files.App.Actions |
| 5 | +{ |
| 6 | + internal sealed class ToggleShelfPaneAction : ObservableObject, IToggleAction |
| 7 | + { |
| 8 | + private readonly IGeneralSettingsService generalSettingsService = Ioc.Default.GetRequiredService<IGeneralSettingsService>(); |
| 9 | + |
| 10 | + public string Label |
| 11 | + => Strings.ToggleShelfPane.GetLocalizedResource(); |
| 12 | + |
| 13 | + public string Description |
| 14 | + => Strings.ToggleShelfPaneDescription.GetLocalizedResource(); |
| 15 | + |
| 16 | + public RichGlyph Glyph |
| 17 | + => new(themedIconStyle: "App.ThemedIcons.Shelf"); |
| 18 | + |
| 19 | + // TODO Remove IsAccessibleGlobally when shelf feature is ready |
| 20 | + public bool IsAccessibleGlobally |
| 21 | + => AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev; |
| 22 | + |
| 23 | + // TODO Remove IsExecutable when shelf feature is ready |
| 24 | + public bool IsExecutable |
| 25 | + => AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev; |
| 26 | + |
| 27 | + public bool IsOn |
| 28 | + => generalSettingsService.ShowShelfPane; |
| 29 | + |
| 30 | + public ToggleShelfPaneAction() |
| 31 | + { |
| 32 | + generalSettingsService.PropertyChanged += GeneralSettingsService_PropertyChanged; |
| 33 | + } |
| 34 | + |
| 35 | + public Task ExecuteAsync(object? parameter = null) |
| 36 | + { |
| 37 | + generalSettingsService.ShowShelfPane = !IsOn; |
| 38 | + |
| 39 | + return Task.CompletedTask; |
| 40 | + } |
| 41 | + |
| 42 | + private void GeneralSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e) |
| 43 | + { |
| 44 | + if (e.PropertyName is nameof(GeneralSettingsService.ShowShelfPane)) |
| 45 | + OnPropertyChanged(nameof(IsOn)); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments