Skip to content

Commit

Permalink
Improve tab behavior when in special folders (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsieu authored Apr 12, 2020
1 parent d3eb996 commit bb47fd5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 35 deletions.
6 changes: 0 additions & 6 deletions Files/Interacts/Interaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,7 @@ private async void OpenSelectedItems(bool displayApplicationPicker)
CurrentInstance.NavigationToolbar.PathControlDisplayText = selectedItemPath;

(CurrentInstance.ContentPage as BaseLayout).AssociatedViewModel.EmptyTextState.IsVisible = Visibility.Collapsed;
App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && x.Path.Equals(selectedItemPath, StringComparison.OrdinalIgnoreCase));
if (App.CurrentInstance.SidebarSelectedItem == null)
{
App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && x.Path.Equals(Path.GetPathRoot(selectedItemPath), StringComparison.OrdinalIgnoreCase));
}
CurrentInstance.ContentFrame.Navigate(sourcePageType, selectedItemPath, new SuppressNavigationTransitionInfo());

}
else
{
Expand Down
12 changes: 6 additions & 6 deletions Files/UserControls/ModernSidebar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
{
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.HomeItems.isEnabled = false;
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.ShareItems.isEnabled = false;
string NaviagtionPath = ""; // path to navigate
string NavigationPath = ""; // path to navigate

if (args.InvokedItem == null)
{
Expand All @@ -77,21 +77,21 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
}
else // Any other item
{
NaviagtionPath = args.InvokedItemContainer.Tag.ToString();
NavigationPath = args.InvokedItemContainer.Tag.ToString();
}

break;
}
case NavigationControlItemType.OneDrive:
{
NaviagtionPath = App.AppSettings.OneDrivePath;
NavigationPath = App.AppSettings.OneDrivePath;
break;
}
default:
{
var clickedItem = args.InvokedItemContainer;

NaviagtionPath = clickedItem.Tag.ToString();
NavigationPath = clickedItem.Tag.ToString();

App.CurrentInstance.NavigationToolbar.PathControlDisplayText = clickedItem.Tag.ToString();
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.LayoutItems.isEnabled = true;
Expand All @@ -102,11 +102,11 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende

if (App.AppSettings.LayoutMode == 0) // List View
{
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), NaviagtionPath, new SuppressNavigationTransitionInfo());
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), NavigationPath, new SuppressNavigationTransitionInfo());
}
else
{
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), NaviagtionPath, new SuppressNavigationTransitionInfo());
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), NavigationPath, new SuppressNavigationTransitionInfo());
}

App.CurrentInstance.NavigationToolbar.PathControlDisplayText = App.CurrentInstance.ViewModel.WorkingDirectory;
Expand Down
16 changes: 8 additions & 8 deletions Files/UserControls/YourHome.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,40 +96,40 @@ private void DropShadowPanel_PointerExited(object sender, Windows.UI.Xaml.Input.

private void Button_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
string NaviagtionPath = ""; // path to navigate
string NavigationPath = ""; // path to navigate
string ClickedCard = (sender as Button).Tag.ToString();

switch (ClickedCard)
{
case "Downloads":
NaviagtionPath = App.AppSettings.DownloadsPath;
NavigationPath = App.AppSettings.DownloadsPath;
break;

case "Documents":
NaviagtionPath = App.AppSettings.DocumentsPath;
NavigationPath = App.AppSettings.DocumentsPath;
break;

case "Pictures":
NaviagtionPath = App.AppSettings.PicturesPath;
NavigationPath = App.AppSettings.PicturesPath;
break;

case "Music":
NaviagtionPath = App.AppSettings.MusicPath;
NavigationPath = App.AppSettings.MusicPath;
break;

case ("Videos"):
NaviagtionPath = App.AppSettings.VideosPath;
NavigationPath = App.AppSettings.VideosPath;
break;
}


switch (App.AppSettings.LayoutMode)
{
case 0:
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), NaviagtionPath); // List View
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), NavigationPath); // List View
break;
case 1:
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), NaviagtionPath); // Grid View
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), NavigationPath); // Grid View
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Files/View Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public string WorkingDirectory
{
_WorkingDirectory = value;

App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && x.Path.Equals(value.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase));
App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && value.StartsWith(x.Path, StringComparison.OrdinalIgnoreCase));
if (App.CurrentInstance.SidebarSelectedItem == null)
{
App.CurrentInstance.SidebarSelectedItem = App.sideBarItems.FirstOrDefault(x => x.Path != null && x.Path.Equals(Path.GetPathRoot(value), StringComparison.OrdinalIgnoreCase));
Expand Down
28 changes: 14 additions & 14 deletions Files/Views/InstanceTabsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,37 +137,37 @@ public void AddNewTab(Type t, string path)
}
}
}
else if (path == App.AppSettings.DesktopPath)
else if (path.StartsWith(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarDesktop");
fontIconSource.Glyph = "\xE8FC";
}
else if (path == App.AppSettings.DownloadsPath)
else if (path.StartsWith(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarDownloads");
fontIconSource.Glyph = "\xE896";
}
else if (path == App.AppSettings.DocumentsPath)
else if (path.StartsWith(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarDocuments");
fontIconSource.Glyph = "\xE8A5";
}
else if (path == App.AppSettings.PicturesPath)
else if (path.StartsWith(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarPictures");
fontIconSource.Glyph = "\xEB9F";
}
else if (path == App.AppSettings.MusicPath)
else if (path.StartsWith(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarMusic");
fontIconSource.Glyph = "\xEC4F";
}
else if (path == App.AppSettings.VideosPath)
else if (path.StartsWith(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarVideos");
fontIconSource.Glyph = "\xE8B2";
}
else if (path == App.AppSettings.OneDrivePath)
else if (App.AppSettings.OneDrivePath != null && path.StartsWith(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = "OneDrive";
fontIconSource.Glyph = "\xE753";
Expand Down Expand Up @@ -222,37 +222,37 @@ public async void SetSelectedTabInfo(string text, string currentPathForTabIcon =
tabLocationHeader = "New tab";
fontIconSource.Glyph = "\xE737";
}
else if (currentPathForTabIcon == App.AppSettings.DesktopPath)
else if (currentPathForTabIcon.StartsWith(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarDesktop");
fontIconSource.Glyph = "\xE8FC";
}
else if (currentPathForTabIcon == App.AppSettings.DownloadsPath)
else if (currentPathForTabIcon.StartsWith(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarDownloads");
fontIconSource.Glyph = "\xE896";
}
else if (currentPathForTabIcon == App.AppSettings.DocumentsPath)
else if (currentPathForTabIcon.StartsWith(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarDocuments");
fontIconSource.Glyph = "\xE8A5";
}
else if (currentPathForTabIcon == App.AppSettings.PicturesPath)
else if (currentPathForTabIcon.StartsWith(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarPictures");
fontIconSource.Glyph = "\xEB9F";
}
else if (currentPathForTabIcon == App.AppSettings.MusicPath)
else if (currentPathForTabIcon.StartsWith(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarMusic");
fontIconSource.Glyph = "\xEC4F";
}
else if (currentPathForTabIcon == App.AppSettings.VideosPath)
else if (currentPathForTabIcon.StartsWith(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = resourceLoader.GetString("SidebarVideos");
fontIconSource.Glyph = "\xE8B2";
}
else if (currentPathForTabIcon == App.AppSettings.OneDrivePath)
else if (App.AppSettings.OneDrivePath != null && currentPathForTabIcon.StartsWith(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
{
tabLocationHeader = "OneDrive";
fontIconSource.Glyph = "\xE753";
Expand Down

0 comments on commit bb47fd5

Please sign in to comment.