|
12 | 12 | using Microsoft.UI.Xaml.Controls;
|
13 | 13 | using Microsoft.UI.Xaml.Input;
|
14 | 14 | using Microsoft.UI.Xaml.Navigation;
|
15 |
| -using System.Runtime.CompilerServices; |
16 | 15 | using Windows.ApplicationModel;
|
17 | 16 | using Windows.Foundation.Metadata;
|
18 | 17 | using Windows.Services.Store;
|
|
21 | 20 |
|
22 | 21 | namespace Files.App.Views
|
23 | 22 | {
|
24 |
| - public sealed partial class MainPage : Page, INotifyPropertyChanged |
| 23 | + public sealed partial class MainPage : Page |
25 | 24 | {
|
26 | 25 | public IUserSettingsService UserSettingsService { get; }
|
27 | 26 | public IApplicationService ApplicationService { get; }
|
@@ -62,6 +61,7 @@ public MainPage()
|
62 | 61 | if (FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft)
|
63 | 62 | FlowDirection = FlowDirection.RightToLeft;
|
64 | 63 |
|
| 64 | + ViewModel.PropertyChanged += ViewModel_PropertyChanged; |
65 | 65 | UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent;
|
66 | 66 |
|
67 | 67 | _updateDateDisplayTimer = DispatcherQueue.CreateTimer();
|
@@ -363,7 +363,7 @@ private void SidebarControl_Loaded(object sender, RoutedEventArgs e)
|
363 | 363 | /// </summary>
|
364 | 364 | private void UpdatePositioning()
|
365 | 365 | {
|
366 |
| - if (PreviewPane is null || !ShouldPreviewPaneBeActive) |
| 366 | + if (PreviewPane is null || !ViewModel.ShouldPreviewPaneBeActive) |
367 | 367 | {
|
368 | 368 | PaneRow.MinHeight = 0;
|
369 | 369 | PaneRow.MaxHeight = double.MaxValue;
|
@@ -434,39 +434,23 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl
|
434 | 434 | this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
|
435 | 435 | }
|
436 | 436 |
|
437 |
| - public bool ShouldViewControlBeDisplayed => SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false; |
438 |
| - |
439 |
| - public bool ShouldPreviewPaneBeActive => UserSettingsService.InfoPaneSettingsService.IsEnabled && ShouldPreviewPaneBeDisplayed; |
440 |
| - |
441 |
| - public bool ShouldPreviewPaneBeDisplayed |
| 437 | + private void LoadPaneChanged() |
442 | 438 | {
|
443 |
| - get |
444 |
| - { |
445 |
| - var isHomePage = !(SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false); |
446 |
| - var isMultiPane = SidebarAdaptiveViewModel.PaneHolder?.IsMultiPaneActive ?? false; |
447 |
| - var isBigEnough = MainWindow.Instance.Bounds.Width > 450 && MainWindow.Instance.Bounds.Height > 450 || RootGrid.ActualWidth > 700 && MainWindow.Instance.Bounds.Height > 360; |
448 |
| - var isEnabled = (!isHomePage || isMultiPane) && isBigEnough; |
| 439 | + var isHomePage = !(SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false); |
| 440 | + var isMultiPane = SidebarAdaptiveViewModel.PaneHolder?.IsMultiPaneActive ?? false; |
| 441 | + var isBigEnough = MainWindow.Instance.Bounds.Width > 450 && MainWindow.Instance.Bounds.Height > 450 || RootGrid.ActualWidth > 700 && MainWindow.Instance.Bounds.Height > 360; |
449 | 442 |
|
450 |
| - return isEnabled; |
451 |
| - } |
452 |
| - } |
| 443 | + ViewModel.ShouldPreviewPaneBeDisplayed = (!isHomePage || isMultiPane) && isBigEnough; |
| 444 | + ViewModel.ShouldPreviewPaneBeActive = UserSettingsService.InfoPaneSettingsService.IsEnabled && ViewModel.ShouldPreviewPaneBeDisplayed; |
| 445 | + ViewModel.ShouldViewControlBeDisplayed = SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false; |
453 | 446 |
|
454 |
| - private void LoadPaneChanged() |
455 |
| - { |
456 |
| - OnPropertyChanged(nameof(ShouldViewControlBeDisplayed)); |
457 |
| - OnPropertyChanged(nameof(ShouldPreviewPaneBeActive)); |
458 |
| - OnPropertyChanged(nameof(ShouldPreviewPaneBeDisplayed)); |
459 | 447 | UpdatePositioning();
|
460 | 448 | }
|
461 | 449 |
|
462 |
| - public event PropertyChangedEventHandler? PropertyChanged; |
463 |
| - |
464 |
| - private void OnPropertyChanged([CallerMemberName] string propertyName = "") |
| 450 | + private async void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) |
465 | 451 | {
|
466 |
| - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
467 |
| - |
468 |
| - if (propertyName == nameof(ShouldPreviewPaneBeActive) && ShouldPreviewPaneBeActive) |
469 |
| - _ = Ioc.Default.GetRequiredService<InfoPaneViewModel>().UpdateSelectedItemPreviewAsync(); |
| 452 | + if (e.PropertyName == nameof(ViewModel.ShouldPreviewPaneBeActive) && ViewModel.ShouldPreviewPaneBeActive) |
| 453 | + await Ioc.Default.GetRequiredService<InfoPaneViewModel>().UpdateSelectedItemPreviewAsync(); |
470 | 454 | }
|
471 | 455 |
|
472 | 456 | private void RootGrid_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
|
|
0 commit comments