Skip to content

Code Quality: Removing PaneHolder to solely use PreviewPaneHolder #10979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c9a5ecf
Removed PaneControl
QuaintMako Dec 28, 2022
434e812
Removed unneeded using
QuaintMako Dec 28, 2022
0e12b35
Merge branch 'files-community:main' into ViewsSmallRefactoring
QuaintMako Dec 30, 2022
b25e0f5
Renamed Service To PreviewPaneSettingsService
QuaintMako Dec 31, 2022
4ab50ba
Removed IPane
QuaintMako Dec 31, 2022
18fd0d1
Renamed service
QuaintMako Dec 31, 2022
4be5f16
Merge branch 'files-community:main' into ViewsSmallRefactoring
QuaintMako Jan 3, 2023
328b04a
Merge branch 'ViewsSmallRefactoring' of https://github.com/QuaintMako…
QuaintMako Jan 3, 2023
4da0304
[WIP] Introducing new setting in the PreviewPaneSettings
QuaintMako Jan 3, 2023
def6063
Forgotten unsubscribe event
QuaintMako Jan 3, 2023
4c88ef1
[WIP] Removing PaneViewModel and adapt existing code
QuaintMako Jan 3, 2023
2ebb9fe
Now displaying the preview button correctly
QuaintMako Jan 3, 2023
bf32124
Merge branch 'files-community:main' into ViewsSmallRefactoring
QuaintMako Jan 5, 2023
610f372
Merge branch 'files-community:main' into ViewsSmallRefactoring
QuaintMako Jan 9, 2023
6b79ae2
Now notifying correctly the settings when the preview pane is toggled.
QuaintMako Jan 9, 2023
b85821c
Merge branch 'files-community:main' into ViewsSmallRefactoring
QuaintMako Jan 10, 2023
af792ff
Merge branch 'files-community:main' into ViewsSmallRefactoring
QuaintMako Jan 10, 2023
7cacf6a
Button state is now correctly iniatilized.
QuaintMako Jan 10, 2023
5b1378d
Preview Pane display is correctly evaluated on home page
QuaintMako Jan 10, 2023
72ac222
Added and completed documentation in SDK.
QuaintMako Jan 10, 2023
48272df
Corrected comment
QuaintMako Jan 10, 2023
5b13eab
Renamed enum
QuaintMako Jan 10, 2023
0ddbc07
Merge branch 'main' into ViewsSmallRefactoring
yaira2 Jan 11, 2023
83e2288
Merge branch 'main' into ViewsSmallRefactoring
yaira2 Jan 11, 2023
0bd44f5
Merge branch 'main' into ViewsSmallRefactoring
QuaintMako Jan 11, 2023
b3c38d0
Update src/Files.App/Views/MainPage.xaml
QuaintMako Jan 11, 2023
6177bcd
Merge branch 'main' into ViewsSmallRefactoring
yaira2 Jan 11, 2023
0368242
Fixed wrongly added suggestion from Github
QuaintMako Jan 11, 2023
43b5c8e
Update src/Files.App/Views/MainPage.xaml
yaira2 Jan 11, 2023
8f45a90
Removed AppModel mention for Preview Pane
QuaintMako Jan 11, 2023
3427ca7
Merge branch 'ViewsSmallRefactoring' of https://github.com/QuaintMako…
QuaintMako Jan 11, 2023
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
5 changes: 1 addition & 4 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public partial class App : Application
public static StorageHistoryWrapper HistoryWrapper = new StorageHistoryWrapper();
public static SettingsViewModel AppSettings { get; private set; }
public static AppModel AppModel { get; private set; }
public static PaneViewModel PaneViewModel { get; private set; }
public static PreviewPaneViewModel PreviewPaneViewModel { get; private set; }
public static JumpListManager JumpList { get; private set; }
public static RecentItems RecentItemsManager { get; private set; }
Expand Down Expand Up @@ -109,7 +108,7 @@ private IServiceProvider ConfigureServices()
.AddSingleton<IPreferencesSettingsService, PreferencesSettingsService>((sp) => new PreferencesSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IFoldersSettingsService, FoldersSettingsService>((sp) => new FoldersSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IApplicationSettingsService, ApplicationSettingsService>((sp) => new ApplicationSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IPaneSettingsService, PaneSettingsService>((sp) => new PaneSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IPreviewPaneSettingsService, PreviewPaneSettingsService>((sp) => new PreviewPaneSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<ILayoutSettingsService, LayoutSettingsService>((sp) => new LayoutSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
.AddSingleton<IAppSettingsService, AppSettingsService>((sp) => new AppSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
// Settings not related to IUserSettingsService:
Expand Down Expand Up @@ -149,7 +148,6 @@ private static void EnsureSettingsAndConfigurationAreBootstrapped()
JumpList ??= new JumpListManager();
RecentItemsManager ??= new RecentItems();
AppModel ??= new AppModel();
PaneViewModel ??= new PaneViewModel();
PreviewPaneViewModel ??= new PreviewPaneViewModel();
LibraryManager ??= new LibraryManager();
DrivesManager ??= new DrivesManager();
Expand Down Expand Up @@ -297,7 +295,6 @@ await SafetyExtensions.IgnoreExceptions(async () =>
}

DrivesManager?.Dispose();
PaneViewModel?.Dispose();
PreviewPaneViewModel?.Dispose();

// Try to maintain clipboard data after app close
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class BaseLayout : Page, IBaseLayout, INotifyPropertyChanged

public CurrentInstanceViewModel? InstanceViewModel => ParentShellPageInstance?.InstanceViewModel;

public IPaneViewModel PaneViewModel => App.PaneViewModel;
public PreviewPaneViewModel PreviewPaneViewModel => App.PreviewPaneViewModel;

public AppModel AppModel => App.AppModel;
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
Expand Down Expand Up @@ -205,9 +205,9 @@ internal set
App.PreviewPaneViewModel.SelectedItem = value?.Count == 1 ? value.First() : null;

// check if the preview pane is open before updating the model
if (PaneViewModel.IsPreviewSelected)
if (PreviewPaneViewModel.IsEnabled)
{
bool isPaneEnabled = ((App.Window.Content as Frame)?.Content as MainPage)?.IsPaneEnabled ?? false;
bool isPaneEnabled = ((App.Window.Content as Frame)?.Content as MainPage)?.ShouldPreviewPaneBeActive ?? false;
if (isPaneEnabled)
App.PreviewPaneViewModel.UpdateSelectedItemPreview();
}
Expand Down Expand Up @@ -1039,7 +1039,7 @@ protected void UninitializeDrag(UIElement element)

public virtual void Dispose()
{
PaneViewModel?.Dispose();
PreviewPaneViewModel?.Dispose();
UnhookBaseEvents();
}

Expand Down
3 changes: 0 additions & 3 deletions src/Files.App/DataModels/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace Files.App.DataModels
{
public class AppModel : ObservableObject
{
// todo: refactor PaneViewModel, this doesn't belong here
public IPaneViewModel PaneViewModel { get; } = new PaneViewModel();

public AppModel()
{
Clipboard.ContentChanged += Clipboard_ContentChanged;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/IBaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IBaseLayout : IDisposable

ItemManipulationModel ItemManipulationModel { get; }

IPaneViewModel PaneViewModel { get; }
PreviewPaneViewModel PreviewPaneViewModel { get; }

public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace Files.App.ServicesImplementation.Settings
{
internal sealed class PaneSettingsService : BaseObservableJsonSettings, IPaneSettingsService
internal sealed class PreviewPaneSettingsService : BaseObservableJsonSettings, IPreviewPaneSettingsService
{
public PaneContents Content
public bool IsEnabled
{
get => Get(PaneContents.None);
get => Get(false);
set => Set(value);
}

Expand Down Expand Up @@ -39,7 +39,7 @@ public bool ShowPreviewOnly
set => Set(value);
}

public PaneSettingsService(ISettingsSharingContext settingsSharingContext)
public PreviewPaneSettingsService(ISettingsSharingContext settingsSharingContext)
{
RegisterSettingsContext(settingsSharingContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public IAppearanceSettingsService AppearanceSettingsService
get => GetSettingsService(ref _AppearanceSettingsService);
}

private IPaneSettingsService _PaneSettingsService;
public IPaneSettingsService PaneSettingsService
private IPreviewPaneSettingsService _PreviewPaneSettingsService;
public IPreviewPaneSettingsService PreviewPaneSettingsService
{
get => GetSettingsService(ref _PaneSettingsService);
get => GetSettingsService(ref _PreviewPaneSettingsService);
}

private ILayoutSettingsService _LayoutSettingsService;
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/UserControls/FilePreviews/MediaPreview.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ public MediaPreview(MediaPreviewViewModel model)

private void PlayerContext_Loaded(object sender, RoutedEventArgs e)
{
PlayerContext.MediaPlayer.Volume = UserSettingsService.PaneSettingsService.MediaVolume;
PlayerContext.MediaPlayer.Volume = UserSettingsService.PreviewPaneSettingsService.MediaVolume;
PlayerContext.MediaPlayer.VolumeChanged += MediaPlayer_VolumeChanged;
ViewModel.TogglePlaybackRequested += TogglePlaybackRequestInvoked;
}

private void MediaPlayer_VolumeChanged(MediaPlayer sender, object args)
{
if (sender.Volume != UserSettingsService.PaneSettingsService.MediaVolume)
if (sender.Volume != UserSettingsService.PreviewPaneSettingsService.MediaVolume)
{
UserSettingsService.PaneSettingsService.MediaVolume = sender.Volume;
UserSettingsService.PreviewPaneSettingsService.MediaVolume = sender.Volume;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@
MinWidth="40"
AccessKey="P"
AutomationProperties.Name="{helpers:ResourceString Name=PreviewPaneToggle/AutomationProperties/Name}"
IsChecked="{x:Bind AppModel.PaneViewModel.IsPreviewSelected, Mode=TwoWay}"
IsChecked="{x:Bind PreviewPaneViewModel.IsEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind ShowPreviewPaneButton, Mode=OneWay}"
Label="{helpers:ResourceString Name=PreviewPaneToggle/Label}"
LabelPosition="Collapsed"
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/UserControls/InnerNavigationToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public InnerNavigationToolbar()

public AppModel AppModel => App.AppModel;

public PreviewPaneViewModel PreviewPaneViewModel => App.PreviewPaneViewModel;

public ToolbarViewModel ViewModel
{
get => (ToolbarViewModel)GetValue(ViewModelProperty);
Expand Down
16 changes: 0 additions & 16 deletions src/Files.App/UserControls/Pane/Pane.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Files.App/UserControls/Pane/PaneControl.xaml

This file was deleted.

64 changes: 0 additions & 64 deletions src/Files.App/UserControls/Pane/PaneControl.xaml.cs

This file was deleted.

19 changes: 14 additions & 5 deletions src/Files.App/UserControls/Pane/PreviewPane.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@

namespace Files.App.UserControls
{
public sealed partial class PreviewPane : UserControl, IPane
public enum PreviewPanePositions : ushort
{
public PanePositions Position { get; private set; } = PanePositions.None;
None,
Right,
Bottom,
}

public sealed partial class PreviewPane : UserControl
{
public PreviewPanePositions Position { get; private set; } = PreviewPanePositions.None;

private IPaneSettingsService PaneSettingsService { get; } = Ioc.Default.GetService<IPaneSettingsService>();
private IPreviewPaneSettingsService PaneSettingsService { get; } = Ioc.Default.GetService<IPreviewPaneSettingsService>();

private PreviewPaneViewModel ViewModel => App.PreviewPaneViewModel;

Expand All @@ -25,12 +32,12 @@ public void UpdatePosition(double panelWidth, double panelHeight)
{
if (panelWidth > 700)
{
Position = PanePositions.Right;
Position = PreviewPanePositions.Right;
(MinWidth, MinHeight) = (150, 0);
}
else
{
Position = PanePositions.Bottom;
Position = PreviewPanePositions.Bottom;
(MinWidth, MinHeight) = (0, 140);
}
}
Expand All @@ -39,11 +46,13 @@ public void UpdatePosition(double panelWidth, double panelHeight)

private void Root_Loading(FrameworkElement sender, object args)
=> ViewModel.UpdateSelectedItemPreview();

private void Root_Unloaded(object sender, RoutedEventArgs e)
{
PreviewControlPresenter.Content = null;
Bindings.StopTracking();
}

private void Root_SizeChanged(object sender, SizeChangedEventArgs e)
=> Context.IsHorizontal = Root.ActualWidth >= Root.ActualHeight;

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ private async void RapidAddItemsToCollectionAsync(string path, string previousDi

AdaptiveLayoutHelpers.PredictLayoutMode(folderSettings, WorkingDirectory, filesAndFolders);

if (App.PaneViewModel.IsPreviewSelected)
if (App.PreviewPaneViewModel.IsEnabled)
{
// Find and select README file
foreach (var item in filesAndFolders)
Expand Down
66 changes: 0 additions & 66 deletions src/Files.App/ViewModels/PaneViewModel.cs

This file was deleted.

Loading