Skip to content

Commit

Permalink
Merge pull request #3058 from PrismLibrary/dev/ds/merge-parameters
Browse files Browse the repository at this point in the history
Merge parameters for segments
  • Loading branch information
dansiegel authored Jan 27, 2024
2 parents 5b296e1 + 2c43ee4 commit f5c7e96
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ protected virtual async Task ProcessNavigation(Page currentPage, Queue<string> s

var nextSegment = segments.Dequeue();

var pageParameters = UriParsingHelper.GetSegmentParameters(nextSegment);
var pageParameters = UriParsingHelper.GetSegmentParameters(nextSegment, parameters);

if (pageParameters.TryGetValue<bool>(KnownNavigationParameters.UseModalNavigation, out var parameterModal))
useModalNavigation = parameterModal;
Expand Down Expand Up @@ -604,7 +604,7 @@ await DoNavigateAction(topPage, nextSegment, topPage, parameters, onNavigationAc
{
if (nextSegment.Contains(KnownNavigationParameters.SelectedTab))
{
var segmentParams = UriParsingHelper.GetSegmentParameters(nextSegment);
var segmentParams = UriParsingHelper.GetSegmentParameters(nextSegment, parameters);
SelectPageTab(topPage, segmentParams);
}
});
Expand Down Expand Up @@ -706,7 +706,7 @@ await DoNavigateAction(null, nextSegment, detail, parameters, onNavigationAction
{
if (detail is TabbedPage && nextSegment.Contains(KnownNavigationParameters.SelectedTab))
{
var segmentParams = UriParsingHelper.GetSegmentParameters(nextSegment);
var segmentParams = UriParsingHelper.GetSegmentParameters(nextSegment, parameters);
SelectPageTab(detail, segmentParams);
}
Expand Down Expand Up @@ -891,7 +891,7 @@ protected virtual Page CreatePageFromSegment(string segment)

async Task ConfigureTabbedPage(TabbedPage tabbedPage, string segment, INavigationParameters parameters)
{
var tabParameters = UriParsingHelper.GetSegmentParameters(segment);
var tabParameters = UriParsingHelper.GetSegmentParameters(segment, parameters);

var tabsToCreate = tabParameters.GetValues<string>(KnownNavigationParameters.CreateTab);
foreach (var tabToCreateEncoded in tabsToCreate ?? Array.Empty<string>())
Expand Down Expand Up @@ -1029,7 +1029,7 @@ protected virtual async Task UseReverseNavigation(Page currentPage, string nextS
}

//if any page decide to go modal, we need to consider it and all pages after it an illegal page
var pageParameters = UriParsingHelper.GetSegmentParameters(item);
var pageParameters = UriParsingHelper.GetSegmentParameters(item, parameters);
if (pageParameters.ContainsKey(KnownNavigationParameters.UseModalNavigation))
{
if (pageParameters.GetValue<bool>(KnownNavigationParameters.UseModalNavigation))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,29 @@ public async Task PushesModally(string startUri, string requestUri, bool? expect
Assert.True(PageNavigationService.UseModalNavigation(push.CurrentPage, useModalNavigation));
}

[Fact]
public async Task PushesModally_From_NavigationParameters()
{
var mauiApp = CreateBuilder(prism => prism
.CreateWindow(n => n.NavigateAsync("NavigationPage/MockViewA")))
.Build();
var window = GetWindow(mauiApp);
var page = window.Page;
if (page is NavigationPage navPage)
page = navPage.RootPage;

var navService = Prism.Navigation.Xaml.Navigation.GetNavigationService(page);

var result = await navService.NavigateAsync("MockViewB", new NavigationParameters { { KnownNavigationParameters.UseModalNavigation, true } });
Assert.True(result.Success);

var pushes = navService.GetPushes();
Assert.Single(pushes);
var push = pushes[0];

Assert.True(push.UseModalNavigation);
}

private static void TestPage(Page page)
{
Assert.NotNull(page.BindingContext);
Expand Down

0 comments on commit f5c7e96

Please sign in to comment.