Skip to content

Commit

Permalink
Merge pull request #3068 from PrismLibrary/dev/ds/getnavservice
Browse files Browse the repository at this point in the history
Add NavigationService helper from the IWindowManager
  • Loading branch information
dansiegel authored Feb 11, 2024
2 parents 17f270b + 5144958 commit f9bb8a7
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_uno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
windows-sdk-version: 18362
install-workload: maui maui-tizen macos maui-windows maui-maccatalyst maccatalyst maui-ios ios android maui-android wasm-tools tvos
uno-check: false
uno-check-version: 1.18.1
uno-check-version: 1.19.0
uno-check-parameters: '--skip xcode --skip gtk3 --skip vswin --skip vsmac'
run-tests: false
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
windows-sdk-version: 18362
install-workload: maui maui-tizen macos maui-windows maui-maccatalyst maccatalyst maui-ios ios android maui-android wasm-tools tvos
uno-check: false
uno-check-version: 1.18.1
uno-check-version: 1.19.0
uno-check-parameters: '--skip xcode --skip gtk3 --skip vswin --skip vsmac'
run-tests: false
code-sign: true
Expand Down Expand Up @@ -154,15 +154,15 @@ jobs:
feedUrl: ${{ secrets.IN_HOUSE_NUGET_FEED }}
apiKey: ${{ secrets.IN_HOUSE_API_KEY }}

deploy-prism-ci:
deploy-commercial-plus:
uses: avantipoint/workflow-templates/.github/workflows/deploy-nuget.yml@master
needs: generate-consolidated-artifacts
if: ${{ github.event_name == 'push' }}
with:
name: Deploy Internal
name: Deploy Commercial Plus
secrets:
feedUrl: ${{ secrets.PRISM_CI_NUGET_FEED }}
apiKey: ${{ secrets.PRISM_CI_NUGET_TOKEN }}
feedUrl: ${{ secrets.PRISM_NUGET_FEED }}
apiKey: ${{ secrets.PRISM_NUGET_TOKEN }}

deploy-sponsors:
uses: avantipoint/workflow-templates/.github/workflows/deploy-nuget.yml@master
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/dotnet-format.yml

This file was deleted.

20 changes: 19 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@ on:
types: [published]

jobs:
publish-release:
publish-internal:
uses: avantipoint/workflow-templates/.github/workflows/deploy-nuget-from-release.yml@master
secrets:
feedUrl: ${{ secrets.IN_HOUSE_NUGET_FEED }}
apiKey: ${{ secrets.IN_HOUSE_API_KEY }}

publish-commercial-plus:
uses: avantipoint/workflow-templates/.github/workflows/deploy-nuget-from-release.yml@master
secrets:
feedUrl: ${{ secrets.PRISM_NUGET_FEED }}
apiKey: ${{ secrets.PRISM_NUGET_TOKEN }}

publish-nuget:
uses: avantipoint/workflow-templates/.github/workflows/deploy-nuget-from-release.yml@master
secrets:
apiKey: ${{ secrets.NUGET_API_KEY }}

publish-sponsors:
uses: avantipoint/workflow-templates/.github/workflows/deploy-nuget-from-release.yml@master
secrets:
feedUrl: ${{ secrets.SPONSOR_CONNECT_NUGET_FEED }}
apiKey: ${{ secrets.SPONSOR_CONNECT_TOKEN }}
72 changes: 38 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ These are the base packages for each platform, together with the Prism's Core as

| Platform | Package | NuGet | Commercial Plus Feed |
| -------- | ------- | ------- | ----- |
| Cross Platform | [Prism.Core][CoreNuGet] | [![CoreNuGetShield]][CoreNuGet] | [![CoreSponsorConnectShield]][CoreSponsorConnect] |
| Cross Platform | [Prism.Events][EventsNuGet] | [![EventsNuGetShield]][EventsNuGet] | [![CoreSponsorConnectShield]][CoreSponsorConnect] |
| Cross Platform | [Prism.Container.Abstractions][ContainerAbstractionsNuGet] | [![ContainerAbstractionsNuGetShield]][ContainerAbstractionsNuGet] | [![CoreSponsorConnectShield]][CoreSponsorConnect] |
| Cross Platform | [Prism.Container.DryIoc][ContainerDryIocNuGet] | [![ContainerDryIocNuGetShield]][ContainerDryIocNuGet] | [![CoreSponsorConnectShield]][CoreSponsorConnect] |
| Cross Platform | [Prism.Container.Unity][ContainerUnityNuGet] | [![ContainerUnityNuGetShield]][ContainerUnityNuGet] | [![CoreSponsorConnectShield]][CoreSponsorConnect] |
| WPF | [Prism.Wpf][WpfNuGet] | [![WpfNuGetShield]][WpfNuGet] | [![WpfSponsorConnectShield]][WpfSponsorConnect] |
| Xamarin.Forms | [Prism.Forms][FormsNuGet] | [![FormsNuGetShield]][FormsNuGet] | [![FormsSponsorConnectShield]][FormsSponsorConnect] |
| Uno Platform and WinUI | [Prism.Uno][UnoNuGet] | [![UnoNuGetShield]][UnoNuGet] | [![UnoSponsorConnectShield]][UnoSponsorConnect] |
| Cross Platform | [Prism.Core][CoreNuGet] | [![CoreNuGetShield]][CoreNuGet] | [![CorePrismNuGetShield]][CorePrismNuGet] |
| Cross Platform | [Prism.Events][EventsNuGet] | [![EventsNuGetShield]][EventsNuGet] | [![EventsPrismNuGetShield]][CorePrismNuGet] |
| Cross Platform | [Prism.Container.Abstractions][ContainerAbstractionsNuGet] | [![ContainerAbstractionsNuGetShield]][ContainerAbstractionsNuGet] | [![ContainerAbstractionsPrismNuGetShield]][CorePrismNuGet] |
| Cross Platform | [Prism.Container.DryIoc][ContainerDryIocNuGet] | [![ContainerDryIocNuGetShield]][ContainerDryIocNuGet] | [![ContainerDryIocPrismNuGetShield]][CorePrismNuGet] |
| Cross Platform | [Prism.Container.Unity][ContainerUnityNuGet] | [![ContainerUnityNuGetShield]][ContainerUnityNuGet] | [![ContainerUnityPrismNuGetShield]][CorePrismNuGet] |
| WPF | [Prism.Wpf][WpfNuGet] | [![WpfNuGetShield]][WpfNuGet] | [![WpfPrismNuGetShield]][WpfPrismNuGet] |
| Xamarin.Forms | [Prism.Forms][FormsNuGet] | [![FormsNuGetShield]][FormsNuGet] | [![FormsPrismNuGetShield]][FormsPrismNuGet] |
| Uno Platform and WinUI | [Prism.Uno][UnoNuGet] | [![UnoNuGetShield]][UnoNuGet] | [![UnoPrismNuGetShield]][UnoPrismNuGet] |

### Container-specific packages

Expand All @@ -66,22 +66,22 @@ Each supported IoC container has its own package assisting in the setup and usag

| Package | NuGet | Commercial Plus Feed |
|---------|-------|-------|
| [Prism.DryIoc][DryIocWpfNuGet] | [![DryIocWpfNuGetShield]][DryIocWpfNuGet] | [![DryIocWpfSponsorConnectShield]][DryIocWpfSponsorConnect] |
| [Prism.Unity][UnityWpfNuGet] | [![UnityWpfNuGetShield]][UnityWpfNuGet] | [![UnityWpfSponsorConnectShield]][UnityWpfSponsorConnect] |
| [Prism.DryIoc][DryIocWpfNuGet] | [![DryIocWpfNuGetShield]][DryIocWpfNuGet] | [![DryIocWpfPrismNuGetShield]][DryIocWpfPrismNuGet] |
| [Prism.Unity][UnityWpfNuGet] | [![UnityWpfNuGetShield]][UnityWpfNuGet] | [![UnityWpfPrismNuGetShield]][UnityWpfPrismNuGet] |

#### Xamarin Forms

| Package | NuGet | Commercial Plus Feed |
|---------|-------|-------|
| [Prism.DryIoc.Forms][DryIocFormsNuGet] | [![DryIocFormsNuGetShield]][DryIocFormsNuGet] | [![DryIocFormsSponsorConnectShield]][DryIocFormsSponsorConnect] |
| [Prism.Unity.Forms][UnityFormsNuGet] | [![UnityFormsNuGetShield]][UnityFormsNuGet] | [![UnityFormsSponsorConnectShield]][UnityFormsSponsorConnect] |
| [Prism.Forms.Regions][PrismFormsRegionsNuget] | [![PrismFormsRegionsNuGetShield]][PrismFormsRegionsNuGet] | [![PrismFormsRegionsSponsorConnectShield]][PrismFormsRegionsSponsorConnect] |
| [Prism.DryIoc.Forms][DryIocFormsNuGet] | [![DryIocFormsNuGetShield]][DryIocFormsNuGet] | [![DryIocFormsPrismNuGetShield]][DryIocFormsPrismNuGet] |
| [Prism.Unity.Forms][UnityFormsNuGet] | [![UnityFormsNuGetShield]][UnityFormsNuGet] | [![UnityFormsPrismNuGetShield]][UnityFormsPrismNuGet] |
| [Prism.Forms.Regions][PrismFormsRegionsNuget] | [![PrismFormsRegionsNuGetShield]][PrismFormsRegionsNuGet] | [![PrismFormsRegionsPrismNuGetShield]][PrismFormsRegionsPrismNuGet] |

#### Uno Platform

| Package | NuGet | Commercial Plus Feed |
|---------|-------|-------|
| [Prism.DryIoc.Uno][DryIocUnoPlatformNuGet] | [![DryIocUnoPlatformNuGetShield]][DryIocUnoPlatformNuGet] | [![DryIocUnoPlatformSponsorConnectShield]][DryIocUnoPlatformSponsorConnect] |
| [Prism.DryIoc.Uno][DryIocUnoPlatformNuGet] | [![DryIocUnoPlatformNuGetShield]][DryIocUnoPlatformNuGet] | [![DryIocUnoPlatformPrismNuGetShield]][DryIocUnoPlatformPrismNuGet] |

![NuGet package tree](images/NuGetPackageTree.png)

Expand Down Expand Up @@ -112,9 +112,9 @@ We strongly encourage you to get involved and help us evolve the code base.
[UnoNuGet]: https://www.nuget.org/packages/Prism.Uno.WinUI/

[PrismFormsRegionsNuGet]: https://www.nuget.org/packages/Prism.Forms.Regions/
[PrismFormsRegionsSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Forms.Regions
[PrismFormsRegionsPrismNuGet]: #
[PrismFormsRegionsNuGetShield]: https://img.shields.io/nuget/vpre/Prism.Forms.Regions.svg
[PrismFormsRegionsSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Forms.Regions/vpre
[PrismFormsRegionsPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Forms.Regions/vpre

[DryIocWpfNuGet]: https://www.nuget.org/packages/Prism.DryIoc/
[UnityWpfNuGet]: https://www.nuget.org/packages/Prism.Unity/
Expand All @@ -141,31 +141,35 @@ We strongly encourage you to get involved and help us evolve the code base.

[DryIocUnoPlatformNuGetShield]: https://img.shields.io/nuget/vpre/Prism.DryIoc.Uno.WinUI.svg

[CoreSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Core
[WpfSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Wpf
[FormsSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Forms
[UnoSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Uno.WinUI
[CorePrismNuGet]: #
[WpfPrismNuGet]: #
[FormsPrismNuGet]: #
[UnoPrismNuGet]: #

[DryIocWpfSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.DryIoc
[UnityWpfSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Unity
[DryIocWpfPrismNuGet]: #
[UnityWpfPrismNuGet]: #

[UnityFormsSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.Unity.Forms
[DryIocFormsSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.DryIoc.Forms
[UnityFormsPrismNuGet]: #
[DryIocFormsPrismNuGet]: #

[DryIocUnoPlatformSponsorConnect]: https://sponsorconnect.dev/nuget/package/Prism.DryIoc.Uno.WinUI
[DryIocUnoPlatformPrismNuGet]: #

[CoreSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Core/vpre
[WpfSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Wpf/vpre
[FormsSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Forms/vpre
[UnoSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Uno.WinUI/vpre
[CorePrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Core/vpre
[EventsPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Events/vpre
[ContainerAbstractionsPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Container.Abstractions/vpre
[ContainerDryIocPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Container.DryIoc/vpre
[ContainerUnityPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Container.Unity/vpre
[WpfPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Wpf/vpre
[FormsPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Forms/vpre
[UnoPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Uno.WinUI/vpre

[DryIocWpfSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.DryIoc/vpre
[UnityWpfSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Unity/vpre
[DryIocWpfPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.DryIoc/vpre
[UnityWpfPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Unity/vpre

[DryIocFormsSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.DryIoc.Forms/vpre
[UnityFormsSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.Unity.Forms/vpre
[DryIocFormsPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.DryIoc.Forms/vpre
[UnityFormsPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.Unity.Forms/vpre

[DryIocUnoPlatformSponsorConnectShield]: https://ci.nuget.prismlibrary.com/shield/Prism.DryIoc.Uno.WinUI/vpre
[DryIocUnoPlatformPrismNuGetShield]: https://nuget.prismlibrary.com/shield/Prism.DryIoc.Uno.WinUI/vpre

[TwitterLogo]: https://dansiegelgithubsponsors.blob.core.windows.net/images/twitter.png
[TwitchLogo]: https://dansiegelgithubsponsors.blob.core.windows.net/images/twitch.png
Expand Down
22 changes: 22 additions & 0 deletions src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Prism.Navigation;

/// <summary>
/// Provides extensions for the <see cref="IWindowManager"/>
/// </summary>
public static class IWindowManagerExtensions
{
/// <summary>
/// Gets the <see cref="INavigationService"/> for the currently displayed <see cref="Page"/>.
/// </summary>
/// <param name="windowManager">The <see cref="IWindowManager"/>.</param>
/// <returns>The <see cref="INavigationService"/> for the current <see cref="Page"/>.</returns>
public static INavigationService GetCurrentNavigationService(this IWindowManager windowManager)
{
var window = windowManager.Windows.OfType<PrismWindow>().First();

if (window.CurrentPage is null)
throw new InvalidOperationException("No current page has been set.");

return Xaml.Navigation.GetNavigationService(window.CurrentPage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

using Prism.Navigation.Xaml;

namespace Prism.DryIoc.Maui.Tests.Fixtures.Navigation;

public class WindowManagerTests : TestBase
{
public WindowManagerTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}

[Theory]
[InlineData("NavigationPage/MockViewA/MockViewB/MockViewC")]
[InlineData("MockHome/NavigationPage/MockViewA")]
public void WindowManagerGetsNavigationServiceFromCurrentPage(string uri)
{
var mauiApp = CreateBuilder(prism => prism.CreateWindow(uri))
.Build();
var window = GetWindow(mauiApp);

var rootPage = window.Page;
var currentPage = rootPage;
if (rootPage is NavigationPage navigationPage)
{
currentPage = navigationPage.CurrentPage;
}
if (rootPage is FlyoutPage flyoutPage && flyoutPage.Detail is NavigationPage detailPage)
{
currentPage = detailPage.CurrentPage;
}

var currentNavigationService = Prism.Navigation.Xaml.Navigation.GetNavigationService(currentPage);
var windowManager = rootPage.GetContainerProvider().Resolve<IWindowManager>();
Assert.Same(currentNavigationService, windowManager.GetCurrentNavigationService());
}
}

0 comments on commit f9bb8a7

Please sign in to comment.