From 2d4b3129af3038b64d54e2a1395fa26810bf5a1d Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Fri, 9 Feb 2024 19:44:59 -0600 Subject: [PATCH 1/4] feat: adding window manager extension for NavigationService --- .../Navigation/IWindowManagerExtensions.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs diff --git a/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs b/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs new file mode 100644 index 0000000000..d5dac38760 --- /dev/null +++ b/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs @@ -0,0 +1,22 @@ +namespace Prism.Navigation; + +/// +/// Provides extensions for the +/// +public static class IWindowManagerExtensions +{ + /// + /// Gets the for the currently displayed . + /// + /// The . + /// The for the current . + public static INavigationService GetCurrentNavigationService(this IWindowManager windowManager) + { + var window = windowManager.Windows.OfType().First(x => x.IsActive); + + if (window.CurrentPage is null) + throw new InvalidOperationException("No current page has been set."); + + return Xaml.Navigation.GetNavigationService(window.CurrentPage); + } +} From f58a9e4bf67de0797f81ab906ba0a6a49f0004de Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Fri, 9 Feb 2024 19:45:13 -0600 Subject: [PATCH 2/4] chore: fixing NuGet Shields --- README.md | 72 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index e5cfb7b104..aab54f3e6c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) @@ -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/ @@ -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 From 804d8db1dcfcafaa44cd974caf6633143c75dc8a Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Sun, 11 Feb 2024 07:16:38 -0600 Subject: [PATCH 3/4] ci: update deployments --- .github/workflows/build_uno.yml | 2 +- .github/workflows/ci.yml | 10 ++++----- .github/workflows/dotnet-format.yml | 30 --------------------------- .github/workflows/publish-release.yml | 20 +++++++++++++++++- 4 files changed, 25 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/dotnet-format.yml diff --git a/.github/workflows/build_uno.yml b/.github/workflows/build_uno.yml index 45075402b8..c378f25ff0 100644 --- a/.github/workflows/build_uno.yml +++ b/.github/workflows/build_uno.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61608d4105..8a8f759973 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml deleted file mode 100644 index 60c2dce23d..0000000000 --- a/.github/workflows/dotnet-format.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: dotnet_format - -on: - pull_request: - branches: - - master - paths: - - 'e2e/**' - - 'src/**' - - 'tests/**' - -jobs: - dotnet_format: - runs-on: windows-latest - steps: - - name: Install dotnet-format - run: dotnet tool install -g dotnet-format - - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - # - name: Run dotnet format - # id: format - # uses: jfversluis/dotnet-format@v1.0.9 - # with: - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # only-changed-files: false - # workspace: "PrismLibrary.sln" diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 867c9b9005..f3f5393c0e 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -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 }} From 51449588dda151e44379bad3808864be3abbfca3 Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Sun, 11 Feb 2024 07:35:43 -0600 Subject: [PATCH 4/4] tests: adding tests for WindowManagerExtensions --- .../Navigation/IWindowManagerExtensions.cs | 2 +- .../Fixtures/Navigation/WindowManagerTests.cs | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Navigation/WindowManagerTests.cs diff --git a/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs b/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs index d5dac38760..237f1e14c0 100644 --- a/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs +++ b/src/Maui/Prism.Maui/Navigation/IWindowManagerExtensions.cs @@ -12,7 +12,7 @@ public static class IWindowManagerExtensions /// The for the current . public static INavigationService GetCurrentNavigationService(this IWindowManager windowManager) { - var window = windowManager.Windows.OfType().First(x => x.IsActive); + var window = windowManager.Windows.OfType().First(); if (window.CurrentPage is null) throw new InvalidOperationException("No current page has been set."); diff --git a/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Navigation/WindowManagerTests.cs b/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Navigation/WindowManagerTests.cs new file mode 100644 index 0000000000..87ed56b008 --- /dev/null +++ b/tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Navigation/WindowManagerTests.cs @@ -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(); + Assert.Same(currentNavigationService, windowManager.GetCurrentNavigationService()); + } +}