Skip to content

Commit 18c1b86

Browse files
authored
Small fixes for Column View (#5962)
1 parent 278513f commit 18c1b86

File tree

5 files changed

+45
-37
lines changed

5 files changed

+45
-37
lines changed

Files/BaseLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
436436
ParentShellPageInstance.InstanceViewModel.IsPageTypeZipFolder = ZipStorageFolder.IsZipPath(workingDir);
437437
ParentShellPageInstance.InstanceViewModel.IsPageTypeSearchResults = false;
438438
ParentShellPageInstance.NavToolbarViewModel.PathControlDisplayText = navigationArguments.NavPathParam;
439-
if (!navigationArguments.IsLayoutSwitch)
439+
if (!navigationArguments.IsLayoutSwitch || previousDir != workingDir)
440440
{
441441
ParentShellPageInstance.FilesystemViewModel.RefreshItems(previousDir, SetSelectedItemsOnNavigation);
442442
}

Files/ViewModels/FolderSettingsViewModel.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public FolderSettingsViewModel()
2929
public FolderSettingsViewModel(FolderLayoutModes modeOverride)
3030
{
3131
rootLayoutMode = modeOverride;
32+
3233
this.LayoutPreference = new LayoutPreferences();
34+
35+
SetLayoutInformation();
3336
}
3437

3538
private readonly FolderLayoutModes? rootLayoutMode;
@@ -98,15 +101,6 @@ public void SetLayoutInformation()
98101
};
99102
}
100103

101-
public void SetLayoutInformation(FolderLayoutModes mode)
102-
{
103-
LayoutModeInformation = new FolderLayoutInformation()
104-
{
105-
Mode = mode,
106-
SizeKind = GridViewSizeKind
107-
};
108-
}
109-
110104
private bool isLayoutModeChanging;
111105

112106
public bool IsLayoutModeChanging
@@ -197,7 +191,7 @@ public void SwitchAdaptiveLayout(bool enable)
197191

198192
LastLayoutModeSelected = FolderLayout.GridViewLarge;
199193

200-
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(LayoutMode, GridViewSize));
194+
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.GridView, GridViewSize));
201195
});
202196

203197
public RelayCommand<bool> ToggleLayoutModeColumnView => new RelayCommand<bool>((manuallySet) =>
@@ -219,7 +213,7 @@ public void SwitchAdaptiveLayout(bool enable)
219213

220214
LastLayoutModeSelected = FolderLayout.ColumnView;
221215

222-
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(LayoutMode, GridViewSize));
216+
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.ColumnView, GridViewSize));
223217
});
224218

225219
public RelayCommand<bool> ToggleLayoutModeGridViewMedium => new RelayCommand<bool>((manuallySet) =>
@@ -248,7 +242,7 @@ public void SwitchAdaptiveLayout(bool enable)
248242

249243
LastLayoutModeSelected = FolderLayout.GridViewMedium;
250244

251-
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(LayoutMode, GridViewSize));
245+
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.GridView, GridViewSize));
252246
});
253247

254248
public RelayCommand<bool> ToggleLayoutModeGridViewSmall => new RelayCommand<bool>((manuallySet) =>
@@ -277,7 +271,7 @@ public void SwitchAdaptiveLayout(bool enable)
277271

278272
LastLayoutModeSelected = FolderLayout.GridViewSmall;
279273

280-
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(LayoutMode, GridViewSize));
274+
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.GridView, GridViewSize));
281275
});
282276

283277
public RelayCommand<int> ToggleLayoutModeGridView => new RelayCommand<int>((size) =>
@@ -313,7 +307,7 @@ public void SwitchAdaptiveLayout(bool enable)
313307

314308
LastLayoutModeSelected = FolderLayout.TilesView;
315309

316-
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(LayoutMode, GridViewSize));
310+
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.TilesView, GridViewSize));
317311
});
318312

319313
public RelayCommand<bool> ToggleLayoutModeDetailsView => new RelayCommand<bool>((manuallySet) =>
@@ -336,7 +330,7 @@ public void SwitchAdaptiveLayout(bool enable)
336330

337331
LastLayoutModeSelected = FolderLayout.DetailsView;
338332

339-
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(LayoutMode, GridViewSize));
333+
LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.DetailsView, GridViewSize));
340334
});
341335

342336
public GridViewSizeKind GridViewSizeKind

Files/Views/ColumnShellPage.xaml.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public ColumnShellPage()
159159
//NavigationToolbar.SearchBox.SuggestionChosen += ColumnShellPage_SuggestionChosen;
160160

161161
NavToolbarViewModel.ToolbarPathItemInvoked += ColumnShellPage_NavigationRequested;
162+
NavToolbarViewModel.ToolbarFlyoutOpened += ColumnShellPage_ToolbarFlyoutOpened;
163+
NavToolbarViewModel.ToolbarPathItemLoaded += ColumnShellPage_ToolbarPathItemLoaded;
162164
NavToolbarViewModel.AddressBarTextEntered += ColumnShellPage_AddressBarTextEntered;
163165
NavToolbarViewModel.PathBoxItemDropped += ColumnShellPage_PathBoxItemDropped;
164166
NavToolbarViewModel.BackRequested += ColumnShellPage_BackNavRequested;
@@ -187,6 +189,16 @@ public ColumnShellPage()
187189
App.DrivesManager.PropertyChanged += DrivesManager_PropertyChanged;
188190
}
189191

192+
private async void ColumnShellPage_ToolbarPathItemLoaded(object sender, ToolbarPathItemLoadedEventArgs e)
193+
{
194+
await NavToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, e.Item, this);
195+
}
196+
197+
private async void ColumnShellPage_ToolbarFlyoutOpened(object sender, ToolbarFlyoutOpenedEventArgs e)
198+
{
199+
await NavToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, (e.OpenedFlyout.Target as FontIcon).DataContext as PathBoxItem, this);
200+
}
201+
190202
private void InitToolbarCommands()
191203
{
192204
NavToolbarViewModel.SelectAllContentPageItemsCommand = new RelayCommand(() => SlimContentPage?.ItemManipulationModel.SelectAllItems());
@@ -208,13 +220,6 @@ private void InitToolbarCommands()
208220

209221
private void FolderSettings_LayoutPreferencesUpdateRequired(object sender, LayoutPreferenceEventArgs e)
210222
{
211-
if (FilesystemViewModel != null)
212-
{
213-
(sender as FolderSettingsViewModel).UpdateLayoutPreferencesForPath(FilesystemViewModel.WorkingDirectory, e.LayoutPreference);
214-
if (e.IsAdaptiveLayoutUpdateRequired)
215-
{
216-
}
217-
}
218223
}
219224

220225
/*
@@ -804,6 +809,8 @@ public void Dispose()
804809
App.DrivesManager.PropertyChanged -= DrivesManager_PropertyChanged;
805810

806811
NavToolbarViewModel.ToolbarPathItemInvoked -= ColumnShellPage_NavigationRequested;
812+
NavToolbarViewModel.ToolbarFlyoutOpened -= ColumnShellPage_ToolbarFlyoutOpened;
813+
NavToolbarViewModel.ToolbarPathItemLoaded -= ColumnShellPage_ToolbarPathItemLoaded;
807814
NavToolbarViewModel.AddressBarTextEntered -= ColumnShellPage_AddressBarTextEntered;
808815
NavToolbarViewModel.PathBoxItemDropped -= ColumnShellPage_PathBoxItemDropped;
809816
NavToolbarViewModel.BackRequested -= ColumnShellPage_BackNavRequested;

Files/Views/LayoutModes/ColumnViewBase.xaml.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
163163
//await ParentShellPageInstance.FilesystemViewModel.SetWorkingDirectoryAsync(NavParam);
164164
//await viewmodel.SetWorkingDirectoryAsync(NavParam);
165165
ParentShellPageInstance.IsCurrentInstance = true;
166-
if(!navigationArguments.IsSearchResultPage)
167-
{
168-
ColumnViewBrowser.columnparent.UpdatePathUIToWorkingDirectory(param.NavPathParam);
169-
}
170166
var parameters = (NavigationArguments)eventArgs.Parameter;
171167
if (parameters.IsLayoutSwitch)
172168
{
@@ -580,12 +576,12 @@ protected override void BaseFolderSettings_LayoutModeChangeRequested(object send
580576
var parent = this.FindAscendant<ModernShellPage>();
581577
if (parent != null)
582578
{
583-
FolderSettings.LayoutMode = e.LayoutMode;
584579
var layoutType = FolderSettings.GetLayoutType(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, false);
585580

586581
if (layoutType != ParentShellPageInstance.CurrentPageType)
587582
{
588-
FolderSettings.IsLayoutModeChanging = true;
583+
parent.FolderSettings.LayoutMode = e.LayoutMode;
584+
parent.FolderSettings.IsLayoutModeChanging = true;
589585
parent.NavigateWithArguments(layoutType, new NavigationArguments()
590586
{
591587
NavPathParam = navigationArguments.NavPathParam,
@@ -596,6 +592,9 @@ protected override void BaseFolderSettings_LayoutModeChangeRequested(object send
596592
IsLayoutSwitch = true,
597593
AssociatedTabInstance = parent
598594
});
595+
596+
// Remove old layout from back stack
597+
parent.RemoveLastPageFromBackStack();
599598
}
600599
}
601600
}

Files/Views/LayoutModes/ColumnViewBrowser.xaml.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ namespace Files.Views.LayoutModes
3131
/// </summary>
3232
public sealed partial class ColumnViewBrowser : BaseLayout
3333
{
34-
public static IShellPage columnparent;
3534
private NavigationArguments parameters;
3635
private ListViewItem listViewItem;
3736

@@ -249,7 +248,6 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
249248
ColumnViewBase.UnFocusPreviousListView += ColumnViewBase_UnFocusPreviousListView;
250249
ColumnViewBase.DismissColumn -= ColumnViewBase_DismissColumn;
251250
ColumnViewBase.DismissColumn += ColumnViewBase_DismissColumn;
252-
columnparent = ParentShellPageInstance;
253251
parameters = (NavigationArguments)eventArgs.Parameter;
254252
if (parameters.IsLayoutSwitch)
255253
{
@@ -404,6 +402,9 @@ public override void Dispose()
404402
ColumnHost.ActiveBlades.Select(x => (x.Content as Frame)?.Content).OfType<IDisposable>().ForEach(x => x.Dispose());
405403
UnhookEvents();
406404
CommandsViewModel?.Dispose();
405+
ColumnViewBase.ItemInvoked -= ColumnViewBase_ItemInvoked;
406+
ColumnViewBase.UnFocusPreviousListView -= ColumnViewBase_UnFocusPreviousListView;
407+
ColumnViewBase.DismissColumn -= ColumnViewBase_DismissColumn;
407408
}
408409

409410
#endregion IDisposable
@@ -749,29 +750,36 @@ private void FileList_ContainerContentChanging(ListViewBase sender, ContainerCon
749750

750751
public void UpColumn()
751752
{
752-
if(!IsLastColumnBase)
753+
if (!IsLastColumnBase)
753754
{
754-
DismissOtherBlades(ColumnHost.ActiveBlades[ColumnHost.ActiveBlades.Count-2]);
755+
DismissOtherBlades(ColumnHost.ActiveBlades[ColumnHost.ActiveBlades.Count - 2]);
755756
}
756757
}
757758

758759
public void SetSelectedPathOrNavigate(PathNavigationEventArgs e)
759760
{
760-
var p = e.ItemPath.TrimEnd('\\');
761-
if(!IsLastColumnBase)
761+
if (!IsLastColumnBase)
762762
{
763763
foreach (var item in ColumnHost.ActiveBlades)
764764
{
765-
if ((item.Content as Frame)?.Content is ColumnShellPage s && s.FilesystemViewModel.WorkingDirectory == p)
765+
if ((item.Content as Frame)?.Content is ColumnShellPage s &&
766+
Helpers.PathNormalization.NormalizePath(s.FilesystemViewModel.WorkingDirectory) ==
767+
Helpers.PathNormalization.NormalizePath(e.ItemPath))
766768
{
767769
DismissOtherBlades(item);
768770
return;
769771
}
770772
}
771-
} else if(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory != p)
773+
}
774+
if (Helpers.PathNormalization.NormalizePath(ParentShellPageInstance.FilesystemViewModel.WorkingDirectory) !=
775+
Helpers.PathNormalization.NormalizePath(e.ItemPath))
772776
{
773777
ParentShellPageInstance.NavigateToPath(e.ItemPath);
774778
}
779+
else
780+
{
781+
DismissOtherBlades(FirstBlade);
782+
}
775783
}
776784

777785
public IBaseLayout LastColumnBrowser => IsLastColumnBase ? this : ((ColumnHost.ActiveBlades.Last().Content as Frame).Content as ColumnShellPage).SlimContentPage as ColumnViewBase;

0 commit comments

Comments
 (0)