Skip to content

Fix: Fixed crash that would occur when adding a new tab #12840

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 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
x:Name="SelectionOptions"
Width="Auto"
MinWidth="40"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
AccessKey="S"
AutomationProperties.Name="{helpers:ResourceString Name=SelectionOptions}"
Label="{helpers:ResourceString Name=NavToolbarSelectionOptions/Label}"
Expand Down Expand Up @@ -486,7 +486,7 @@
x:Name="ArrangementOptions"
Width="Auto"
MinWidth="40"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
AccessKey="A"
AutomationProperties.Name="{helpers:ResourceString Name=Sort}"
Label="{helpers:ResourceString Name=Sort}"
Expand Down Expand Up @@ -590,7 +590,7 @@
x:Name="LayoutOptionsButton"
Width="Auto"
MinWidth="40"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
x:Load="{x:Bind ShowViewControlButton, Mode=OneWay}"
AccessKey="L"
AutomationProperties.Name="{helpers:ResourceString Name=Layout}"
Label="{helpers:ResourceString Name=Layout}"
Expand Down
10 changes: 10 additions & 0 deletions src/Files.App/UserControls/InnerNavigationToolbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public ToolbarViewModel ViewModel
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register(nameof(ViewModel), typeof(ToolbarViewModel), typeof(InnerNavigationToolbar), new PropertyMetadata(null));

public bool ShowViewControlButton
{
get { return (bool)GetValue(ShowViewControlButtonProperty); }
set { SetValue(ShowViewControlButtonProperty, value); }
}

// Using a DependencyProperty as the backing store for ShowViewControlButton. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ShowViewControlButtonProperty =
DependencyProperty.Register("ShowViewControlButton", typeof(bool), typeof(AddressToolbar), new PropertyMetadata(null));

public bool ShowPreviewPaneButton
{
get { return (bool)GetValue(ShowPreviewPaneButtonProperty); }
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Views/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
x:Load="False"
Loaded="NavToolbar_Loaded"
ShowPreviewPaneButton="{x:Bind ShouldPreviewPaneBeDisplayed, Mode=OneWay}"
ShowViewControlButton="{x:Bind ShouldViewControlBeDisplayed, Mode=OneWay}"
TabIndex="2" />

<!-- Page Content -->
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ private void PaneSplitter_ManipulationCompleted(object sender, ManipulationCompl
this.ChangeCursor(InputSystemCursor.Create(InputSystemCursorShape.Arrow));
}

public bool ShouldViewControlBeDisplayed => SidebarAdaptiveViewModel.PaneHolder?.ActivePane?.InstanceViewModel?.IsPageTypeNotHome ?? false;

public bool ShouldPreviewPaneBeActive => UserSettingsService.PreviewPaneSettingsService.IsEnabled && ShouldPreviewPaneBeDisplayed;

public bool ShouldPreviewPaneBeDisplayed
Expand All @@ -501,6 +503,7 @@ public bool ShouldPreviewPaneBeDisplayed

private void LoadPaneChanged()
{
OnPropertyChanged(nameof(ShouldViewControlBeDisplayed));
OnPropertyChanged(nameof(ShouldPreviewPaneBeActive));
OnPropertyChanged(nameof(ShouldPreviewPaneBeDisplayed));
UpdatePositioning();
Expand Down