Skip to content

Commit b16f8f4

Browse files
committed
Utilize UWP Frame Back Navigation System
1 parent fd22144 commit b16f8f4

File tree

8 files changed

+195
-155
lines changed

8 files changed

+195
-155
lines changed

Files UWP/GenericFileBrowser.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
xmlns:local2="using:Files.Filesystem"
1313
xmlns:local3="using:Files.Interacts"
1414
Name="GenericItemView"
15-
mc:Ignorable="d" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" IsRightTapEnabled="True" RightTapped="GenericItemView_RightTapped" PointerReleased="GenericItemView_PointerReleased">
15+
mc:Ignorable="d" NavigationCacheMode="Required" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" IsRightTapEnabled="True" RightTapped="GenericItemView_RightTapped" PointerReleased="GenericItemView_PointerReleased">
1616
<Page.Resources>
1717
<Style x:Key="TextBoxStyleForPathBar" TargetType="TextBox">
1818
<Setter Property="Foreground" Value="{ThemeResource DefaultTextForegroundThemeBrush}"/>

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
110110
var parameters = (string)eventArgs.Parameter;
111111
App.ViewModel.CancelLoadAndClearFiles();
112112
App.ViewModel.Universal.path = parameters;
113-
ProHome.BackButton.Click += NavigationActions.Back_Click;
114-
ProHome.ForwardButton.Click += NavigationActions.Forward_Click;
113+
//ProHome.BackButton.Click += NavigationActions.Back_Click;
114+
//ProHome.ForwardButton.Click += NavigationActions.Forward_Click;
115115
ProHome.RefreshButton.Click += NavigationActions.Refresh_Click;
116116
ProHome.AddItemButton.Click += AddItem_ClickAsync;
117117
App.ViewModel.AddItemsToCollectionAsync(App.ViewModel.Universal.path, GenericItemView);

Files UWP/Interacts/Interaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
115115
{
116116
ProHome.drivesList.SelectedIndex = 0;
117117
App.ViewModel.Universal.path = clickedOnItem.FilePath;
118-
App.ViewModel.AddItemsToCollectionAsync(App.ViewModel.Universal.path, GenericFileBrowser.GFBPageName);
118+
ProHome.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), App.ViewModel.Universal.path, new SuppressNavigationTransitionInfo());
119119
}
120120
}
121121
else if (clickedOnItem.FileType == "Application")

Files UWP/Navigation/History.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ public static void AddToForwardList(string pathToBeAdded)
5151
{
5252
if (ForwardList[ForwardList.Count - 1] != pathToBeAdded)
5353
{
54-
ForwardList.Add(pathToBeAdded);
54+
//ForwardList.Add(pathToBeAdded);
55+
ForwardList.Insert(0, pathToBeAdded);
5556
}
5657
}
5758
else
5859
{
59-
ForwardList.Add(pathToBeAdded);
60+
//ForwardList.Add(pathToBeAdded);
61+
ForwardList.Insert(0, pathToBeAdded);
6062
}
6163
}
6264
}

Files UWP/Navigation/NavigationActions.cs

Lines changed: 169 additions & 146 deletions
Large diffs are not rendered by default.

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
4747
App.ViewModel.AddItemsToCollectionAsync(parameters, PhotoAlbumViewer);
4848
Interaction.page = this;
4949
FileList.DoubleTapped += Interaction.List_ItemClick;
50-
ProHome.BackButton.Click += Navigation.PhotoAlbumNavActions.Back_Click;
51-
ProHome.ForwardButton.Click += Navigation.PhotoAlbumNavActions.Forward_Click;
50+
//ProHome.BackButton.Click += Navigation.PhotoAlbumNavActions.Back_Click;
51+
//ProHome.ForwardButton.Click += Navigation.PhotoAlbumNavActions.Forward_Click;
5252
ProHome.RefreshButton.Click += Navigation.PhotoAlbumNavActions.Refresh_Click;
5353
FileList.RightTapped += Interaction.FileList_RightTapped;
5454
OpenItem.Click += Interaction.OpenItem_Click;

Files UWP/ProHome.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@
10891089
<ColumnDefinition Width="Auto"/>
10901090
</Grid.ColumnDefinitions>
10911091
<StackPanel Grid.Column="0" Orientation="Horizontal">
1092-
<AppBarButton Icon="Back" LabelPosition="Collapsed" IsEnabled="{x:Bind local:App.ViewModel.BS.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="Back">
1092+
<AppBarButton Icon="Back" Click="Back_Click" LabelPosition="Collapsed" IsEnabled="{x:Bind local:App.ViewModel.BS.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:Name="Back">
10931093

10941094
<AppBarButton.KeyboardAccelerators>
10951095
<KeyboardAccelerator Modifiers="Control" Key="Left"/>

Files UWP/ProHome.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public ProHome()
103103
PopulateNavViewWithExternalDrives();
104104
}
105105

106+
protected override void OnNavigatedTo(NavigationEventArgs e)
107+
{
108+
BackButton.IsEnabled = accessibleContentFrame.CanGoBack;
109+
ForwardButton.IsEnabled = accessibleContentFrame.CanGoForward;
110+
}
111+
106112
public async void PopulateNavViewWithExternalDrives()
107113
{
108114
var knownRemDevices = new ObservableCollection<string>();
@@ -424,6 +430,15 @@ private async void PermissionDialog_PrimaryButtonClick(ContentDialog sender, Con
424430
await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-broadfilesystemaccess"));
425431

426432
}
433+
434+
private void Back_Click(object sender, RoutedEventArgs e)
435+
{
436+
App.ViewModel.CancelLoadAndClearFiles();
437+
if (accessibleContentFrame.CanGoBack)
438+
{
439+
accessibleContentFrame.GoBack();
440+
}
441+
}
427442
}
428443

429444
public class Tab

0 commit comments

Comments
 (0)