Skip to content

Commit

Permalink
Keyboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrariofilippo committed Feb 7, 2023
1 parent 8a48018 commit f690166
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Files.App/Views/LayoutModes/ColumnViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public override void Dispose()
{
viewBase.ItemInvoked -= ColumnViewBase_ItemInvoked;
viewBase.ItemTapped -= ColumnViewBase_ItemTapped;
viewBase.KeyUp -= ColumnViewBase_KeyUp;
}
}
if (frame?.Content is UIElement element)
Expand Down Expand Up @@ -155,6 +156,7 @@ private void DismissOtherBlades(int index)
{
columnLayout.ItemInvoked -= ColumnViewBase_ItemInvoked;
columnLayout.ItemTapped -= ColumnViewBase_ItemTapped;
columnLayout.KeyUp -= ColumnViewBase_KeyUp;
}
(frame?.Content as UIElement).GotFocus -= ColumnViewBrowser_GotFocus;
(frame?.Content as ColumnShellPage).ContentChanged -= ColumnViewBrowser_ContentChanged;
Expand Down Expand Up @@ -202,10 +204,17 @@ private void ColumnViewBrowser_ContentChanged(object sender, UserControls.Multit
columnView.ItemInvoked += ColumnViewBase_ItemInvoked;
columnView.ItemTapped -= ColumnViewBase_ItemTapped;
columnView.ItemTapped += ColumnViewBase_ItemTapped;
columnView.KeyUp -= ColumnViewBase_KeyUp;
columnView.KeyUp += ColumnViewBase_KeyUp;
}
ContentChanged(c);
}

private void ColumnViewBase_KeyUp(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e)
{
CloseUnnecessaryColumns((ActiveColumnShellPage as ColumnShellPage)?.ColumnParams);
}

public void NavigateBack()
{
(ParentShellPageInstance as ModernShellPage)?.Back_Click();
Expand Down Expand Up @@ -355,7 +364,12 @@ private void ColumnViewBase_ItemTapped(object? sender, EventArgs e)
var column = sender as ColumnParam;
if (column?.ListView.FindAscendant<ColumnViewBrowser>() != this || string.IsNullOrEmpty(column.NavPathParam))
return;

CloseUnnecessaryColumns(column);
}

private void CloseUnnecessaryColumns(ColumnParam column)
{
var columnPath = ((ColumnHost.ActiveBlades.Last().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory;
var columnFirstPath = ((ColumnHost.ActiveBlades.First().Content as Frame)?.Content as ColumnShellPage)?.FilesystemViewModel.WorkingDirectory;
if (string.IsNullOrEmpty(columnPath) || string.IsNullOrEmpty(columnFirstPath))
Expand Down

0 comments on commit f690166

Please sign in to comment.