Skip to content

Feature: Improve Column View #11344

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 6 commits into from
Feb 17, 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
19 changes: 17 additions & 2 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
if (eventArgs.Parameter is NavigationArguments navArgs)
{
navArgs.FocusOnNavigation = (navArgs.AssociatedTabInstance as ColumnShellPage)?.ColumnParams?.Column == 0; // Focus filelist only if first column
columnsOwner = (navArgs.AssociatedTabInstance as FrameworkElement)?.FindAscendant<ColumnViewBrowser>();
var index = (navArgs.AssociatedTabInstance as ColumnShellPage)?.ColumnParams?.Column;
navArgs.FocusOnNavigation = index == columnsOwner?.FocusIndex;

if (index < columnsOwner?.FocusIndex)
FileList.ContainerContentChanging += HighlightPathDirectory;
}

base.OnNavigatedTo(eventArgs);
Expand All @@ -117,6 +121,17 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
FolderSettings.GroupOptionPreferenceUpdated += ZoomIn;
}

private void HighlightPathDirectory(ListViewBase sender, ContainerContentChangingEventArgs args)
{
if (args.Item is ListedItem item && columnsOwner?.OwnerPath is string ownerPath
&& (ownerPath == item.ItemPath || ownerPath.StartsWith(item.ItemPath) && ownerPath[item.ItemPath.Length] is '/' or '\\'))
{
var presenter = args.ItemContainer.FindDescendant<Grid>()!;
presenter!.Background = this.Resources["ListViewItemBackgroundSelected"] as SolidColorBrush;
FileList.ContainerContentChanging -= HighlightPathDirectory;
}
}

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
base.OnNavigatingFrom(e);
Expand Down Expand Up @@ -454,4 +469,4 @@ internal void ClearSelectionIndicator()
FileList.SelectedItem = null;
}
}
}
}
44 changes: 42 additions & 2 deletions src/Files.App/Views/LayoutModes/ColumnViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Collections.Generic;
using System.Linq;
using static Files.App.Constants;
using static Files.App.Helpers.PathNormalization;

namespace Files.App.Views.LayoutModes
{
Expand All @@ -20,6 +21,9 @@ public sealed partial class ColumnViewBrowser : BaseLayout
protected override uint IconSize => Browser.ColumnViewBrowser.ColumnViewSizeSmall;
protected override ItemsControl ItemsControl => ColumnHost;

public string? OwnerPath { get; private set; }
public int FocusIndex { get; private set; }

public ColumnViewBrowser() : base()
{
InitializeComponent();
Expand Down Expand Up @@ -66,6 +70,8 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e)
Column = ColumnHost.ActiveBlades.IndexOf(newblade),
NavPathParam = column.NavPathParam
});
navigationArguments.NavPathParam = column.NavPathParam;
ParentShellPageInstance.TabItemArguments.NavigationArg = column.NavPathParam;
}
}

Expand All @@ -78,7 +84,21 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
base.OnNavigatedTo(eventArgs);

var navigationArguments = (NavigationArguments)eventArgs.Parameter;
var path = navigationArguments.NavPathParam;
var pathStack = new Stack<string>();

if (path is not null)
{
var rootPathList = App.QuickAccessManager.Model.FavoriteItems.Select(x => NormalizePath(x)).ToList();
rootPathList.Add(NormalizePath(GetPathRoot(path)));

while (!rootPathList.Contains(NormalizePath(path)))
{
pathStack.Push(path);
path = GetParentDir(path);
}
}

MainPageFrame.Navigated += Frame_Navigated;
MainPageFrame.Navigate(typeof(ColumnShellPage), new ColumnParam
{
Expand All @@ -87,8 +107,21 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
SearchQuery = navigationArguments.SearchQuery,
SearchUnindexedItems = navigationArguments.SearchUnindexedItems,
SearchPathParam = navigationArguments.SearchPathParam,
NavPathParam = navigationArguments.NavPathParam
NavPathParam = path
});
OwnerPath = navigationArguments.NavPathParam;
FocusIndex = pathStack.Count;
var index = 0;
while (pathStack.TryPop(out path))
{
var (frame, _) = CreateAndAddNewBlade();

frame.Navigate(typeof(ColumnShellPage), new ColumnParam
{
Column = ++index,
NavPathParam = path
});
}
}

protected override void InitializeCommandsViewModel()
Expand Down Expand Up @@ -163,6 +196,11 @@ private void DismissOtherBlades(int index)
ColumnHost.Items.RemoveAt(index + 1);
ColumnHost.ActiveBlades.RemoveAt(index + 1);
}
if ((ColumnHost.ActiveBlades[index].Content as Frame)?.Content is ColumnShellPage s)
{
navigationArguments.NavPathParam = s.FilesystemViewModel.WorkingDirectory;
ParentShellPageInstance.TabItemArguments.NavigationArg = s.FilesystemViewModel.WorkingDirectory;
}
});
}
ContentChanged(ActiveColumnShellPage);
Expand Down Expand Up @@ -242,6 +280,7 @@ public void MoveFocusToPreviousBlade(int currentBladeIndex)

var activeBlade = ColumnHost.ActiveBlades[currentBladeIndex - 1];
activeBlade.Focus(FocusState.Programmatic);
FocusIndex = currentBladeIndex - 1;

var activeBladeColumnViewBase = RetrieveBladeColumnViewBase(activeBlade);
if (activeBladeColumnViewBase is null)
Expand All @@ -260,6 +299,7 @@ public void MoveFocusToNextBlade(int currentBladeIndex)

var activeBlade = ColumnHost.ActiveBlades[currentBladeIndex];
activeBlade.Focus(FocusState.Programmatic);
FocusIndex = currentBladeIndex;

var activeBladeColumnViewBase = RetrieveBladeColumnViewBase(activeBlade);
if (activeBladeColumnViewBase is not null)
Expand Down