Skip to content

Commit

Permalink
fixed #1625
Browse files Browse the repository at this point in the history
I totally forgot to do a PR, so it's going directly into master because I do not want to redo all that work.
  • Loading branch information
brianlagunas committed Nov 17, 2018
1 parent 21cf084 commit 930e2b0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
Expand Up @@ -20,9 +20,13 @@ public MyMasterDetailViewModel(INavigationService navigationService)
NavigateCommand = new DelegateCommand<string>(Navigate);
}

private void Navigate(string name)
private async void Navigate(string name)
{
_navigationService.NavigateAsync(name);
var result = await _navigationService.NavigateAsync(name);
if (!result.Success)
{

}
}

public override void OnNavigatedFrom(INavigationParameters parameters)
Expand Down
Expand Up @@ -10,9 +10,9 @@
<ContentPage Title="Default">
<StackLayout>
<Button Text="MainPage" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/MainPage" />
<Button Text="ViewA" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/ViewA" />
<Button Text="ViewB" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/ViewB" />
<Button Text="ViewC" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/ViewC" />
<Button Text="ViewA" Command="{Binding NavigateCommand}" CommandParameter="MyTabbedPage?selectedTab=ViewA" />
<Button Text="ViewB" Command="{Binding NavigateCommand}" CommandParameter="MyTabbedPage?selectedTab=ViewB" />
<Button Text="ViewC" Command="{Binding NavigateCommand}" CommandParameter="MyTabbedPage?selectedTab=ViewC" />
<Button Text="XamlNav" Command="{nav:NavigateTo 'MyNavigationPage/ViewA'}" />
</StackLayout>
</ContentPage>
Expand Down
8 changes: 4 additions & 4 deletions Sandbox/Xamarin/HelloWorld/ModuleA/Views/MyTabbedPage.xaml
Expand Up @@ -18,16 +18,16 @@
</x:Arguments>
</NavigationPage>

<!--<NavigationPage Title="View B">
<NavigationPage Title="View B">
<x:Arguments>
<local:ViewB Title="View B" />
</x:Arguments>
</NavigationPage>

<local:ViewC Title="View C" />-->
<local:ViewC Title="View C" />

<!--<local:ViewA Title="View A" />-->
<local:ViewB Title="View B"/>
<local:ViewC Title="View C"/>
<!--<local:ViewB Title="View B"/>-->
<!--<local:ViewC Title="View C"/>-->

</TabbedPage>
29 changes: 19 additions & 10 deletions Source/Xamarin/Prism.Forms/Navigation/PageNavigationService.cs
Expand Up @@ -575,19 +575,22 @@ protected virtual async Task ProcessNavigationForMasterDetailPage(MasterDetailPa
{
detailIsNavPage = true;

//first we check to see if we are being forced to reuse the NavPage by checking the interface
reuseNavPage = !GetClearNavigationPageNavigationStack(navPage);

if (!reuseNavPage)
//we only care if we the next segment is also a NavigationPage.
if (PageUtilities.IsSameOrSubclassOf<NavigationPage>(nextSegmentType))
{
//if we weren't forced to reuse the NavPage, then let's check the NavPage.CurrentPage against the next segment type as we don't want to recreate the entire nav stack
//just in case the user is trying to navigate to the same page which may be nested in a NavPage
var nextPageType = PageNavigationRegistry.GetPageType(UriParsingHelper.GetSegmentName(segments.Peek()));
var currentPageType = navPage.CurrentPage.GetType();
//first we check to see if we are being forced to reuse the NavPage by checking the interface
reuseNavPage = !GetClearNavigationPageNavigationStack(navPage);

if (nextPageType == currentPageType)
if (!reuseNavPage)
{
reuseNavPage = true;
//if we weren't forced to reuse the NavPage, then let's check the NavPage.CurrentPage against the next segment type as we don't want to recreate the entire nav stack
//just in case the user is trying to navigate to the same page which may be nested in a NavPage
var nextPageType = PageNavigationRegistry.GetPageType(UriParsingHelper.GetSegmentName(segments.Peek()));
var currentPageType = navPage.CurrentPage.GetType();
if (nextPageType == currentPageType)
{
reuseNavPage = true;
}
}
}
}
Expand All @@ -597,6 +600,12 @@ protected virtual async Task ProcessNavigationForMasterDetailPage(MasterDetailPa
await ProcessNavigation(detail, segments, parameters, useModalNavigation, animated);
await DoNavigateAction(null, nextSegment, detail, parameters, onNavigationActionCompleted: () =>
{
if (detail is TabbedPage && nextSegment.Contains(KnownNavigationParameters.SelectedTab))
{
var segmentParams = UriParsingHelper.GetSegmentParameters(nextSegment);
SelectPageTab(detail, segmentParams);
}
currentPage.IsPresented = isPresented;
});
return;
Expand Down

0 comments on commit 930e2b0

Please sign in to comment.