Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge parameters for segments #3058

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading