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

Migrate Regions to core #2944

Merged
merged 19 commits into from
Sep 12, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
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: true
workspace: "PrismLibrary.sln"
# - 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"
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
</When>
</Choose>

<ItemGroup>
<None Include="build\Package.props" Pack="true" PackagePath="buildTransitive\$(PackageId).props" Condition="exists('build\Package.props')"/>
<None Include="build\Package.targets" Pack="true" PackagePath="buildTransitive\$(PackageId).targets" Condition="exists('build\Package.targets')"/>
</ItemGroup>

<ItemGroup Condition=" $(IsTestProject) ">
<None Include="$(MSBuildThisFileDirectory)xunit.runner.json"
CopyToOutputDirectory="PreserveNewest" />
Expand Down
33 changes: 16 additions & 17 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,42 @@
<PackageVersion Include="Xamarin.Forms" Version="5.0.0.2401" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
</ItemGroup>

<!-- Maui -->
<ItemGroup Condition=" $(UseMaui) == 'true' ">
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
</ItemGroup>
<!-- Uno -->
<ItemGroup Condition=" $(IsUnoProject) == 'true' ">
<PackageVersion Include="Uno.WinUI" Version="4.9.26" />
<PackageVersion Include="Uno.WinUI.Skia.Gtk" Version="4.9.26" />
<PackageVersion Include="Uno.WinUI.Skia.Linux.FrameBuffer" Version="4.9.26" />
<PackageVersion Include="Uno.WinUI.Skia.Wpf" Version="4.9.26" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="7.0.24" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.24" />
<PackageVersion Include="Uno.WinUI.WebAssembly" Version="4.9.26" />
<PackageVersion Include="Uno.WinUI.RemoteControl" Version="4.9.26" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.9.26" />
<PackageVersion Include="Uno.WinUI" Version="4.9.45" />
<PackageVersion Include="Uno.WinUI.Skia.Gtk" Version="4.9.45" />
<PackageVersion Include="Uno.WinUI.Skia.Linux.FrameBuffer" Version="4.9.45" />
<PackageVersion Include="Uno.WinUI.Skia.Wpf" Version="4.9.45" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="7.0.27" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.27" />
<PackageVersion Include="Uno.WinUI.WebAssembly" Version="4.9.45" />
<PackageVersion Include="Uno.WinUI.RemoteControl" Version="4.9.45" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.9.45" />
<PackageVersion Include="Uno.Core" Version="4.0.1" />
<PackageVersion Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
<PackageVersion Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.0" />
<PackageVersion Include="Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.0" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.0.1" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.2.221109.1" Condition="$(MSBuildProjectName.Contains('Prism'))" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" Condition="!$(MSBuildProjectName.Contains('Prism'))" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.3.230724000" Condition="!$(MSBuildProjectName.Contains('Prism'))" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
<PackageVersion Include="SkiaSharp.Views.Uno.WinUI" Version="2.88.3" />
<PackageVersion Include="SkiaSharp.Skottie" Version="2.88.3" />
<PackageVersion Include="Uno.Resizetizer" Version="1.1.0" />
<PackageVersion Include="SkiaSharp.Views.Uno.WinUI" Version="2.88.5" />
<PackageVersion Include="SkiaSharp.Skottie" Version="2.88.5" />
<PackageVersion Include="Uno.Resizetizer" Version="1.1.2" />
<PackageVersion Include="Uno.Extensions.Core" Version="2.4.2" />
<PackageVersion Include="Uno.Extensions.Logging.OSLog" Version="1.4.0" />
<PackageVersion Include="Uno.Extensions.Logging.WinUI" Version="2.4.2" />
<PackageVersion Include="Uno.Extensions.Logging.Serilog" Version="2.4.2" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.3.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.4.0" />
<PackageVersion Include="Uno.Material.WinUI" Version="2.6.1" />
<PackageVersion Include="Uno.Toolkit.WinUI.Material" Version="3.0.4" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="3.0.4" />
<PackageVersion Include="Uno.Toolkit.WinUI.Material" Version="3.0.5" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="3.0.5" />
<PackageVersion Include="Uno.Extensions.Hosting.WinUI" Version="2.4.2" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageVersion Include="Xamarin.Google.Android.Material" Version="1.7.0.2" />
Expand Down
1 change: 0 additions & 1 deletion e2e/Forms/src/HelloRegions/RegionDemoModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HelloRegions.ViewModels;
using HelloRegions.Views;
using Prism.Ioc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Windows.Input;
using Prism.Commands;
using Prism.Navigation;
using Prism.Regions.Navigation;
using Prism.Navigation.Regions.Navigation;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions.Navigation;
using Prism.Navigation.Regions.Navigation;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions.Navigation;
using Prism.Navigation.Regions.Navigation;

namespace HelloRegions.ViewModels
{
Expand Down
6 changes: 2 additions & 4 deletions e2e/Forms/src/HelloRegions/ViewModels/RegionDemoBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation;
using Prism.Regions;
using Prism.Regions.Navigation;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand All @@ -26,7 +24,7 @@ private void Navigate(string target)
_regionManager.RequestNavigate(RegionName, target, NavigationCallback);
}

private void NavigationCallback(IRegionNavigationResult result)
private void NavigationCallback(NavigationResult result)
{

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Prism.Regions;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down
12 changes: 6 additions & 6 deletions e2e/Forms/src/HelloRegions/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions.Navigation;
using Prism.Navigation.Regions;

namespace HelloRegions.ViewModels
{
Expand Down Expand Up @@ -38,28 +38,28 @@ public bool IsActive
set => SetProperty(ref _isActive, value, OnIsActiveChanged);
}

private INavigationContext _context;
private INavigationContext Context
private NavigationContext _context;
private NavigationContext Context
{
get => _context;
set => SetProperty(ref _context, value);
}

public bool IsNavigationTarget(INavigationContext navigationContext)
public bool IsNavigationTarget(NavigationContext navigationContext)
{
Console.WriteLine($"{GetType().Name} IsNavigationTarget called");
var lookingFor = navigationContext.NavigatedName();
return _contextName == lookingFor;
}

public void OnNavigatedFrom(INavigationContext navigationContext)
public void OnNavigatedFrom(NavigationContext navigationContext)
{
Context = navigationContext;
Console.WriteLine($"{GetType().Name} NavigatedFrom");
}

private string _contextName;
public void OnNavigatedTo(INavigationContext navigationContext)
public void OnNavigatedTo(NavigationContext navigationContext)
{
Context = navigationContext;
_contextName = navigationContext.NavigatedName();
Expand Down
3 changes: 2 additions & 1 deletion e2e/Maui/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<Project>
<Import Project="..\..\src\Maui\Prism.Maui\build\Prism.Maui.targets" />
<Import Project="..\..\src\Prism.Core\build\Package.targets" />
<Import Project="..\..\src\Maui\Prism.Maui\build\Package.targets" />
</Project>
4 changes: 2 additions & 2 deletions e2e/Maui/MauiRegionsModule/MauiTestRegionsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class MauiTestRegionsModule : IModule
public void OnInitialized(IContainerProvider containerProvider)
{
var regionManager = containerProvider.Resolve<IRegionManager>();
regionManager.RegisterViewWithRegion("ContentRegion", "RegionViewA");
regionManager.RegisterViewWithRegion<RegionViewA>("ContentRegion");
}

public void RegisterTypes(IContainerRegistry containerRegistry)
Expand All @@ -23,4 +23,4 @@ public void RegisterTypes(IContainerRegistry containerRegistry)
.RegisterForRegionNavigation<RegionViewB, RegionViewBViewModel>()
.RegisterForRegionNavigation<RegionViewC, RegionViewCViewModel>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected RegionViewModelBase(INavigationService navigationService, IPageAccesso
_pageAccessor = pageAccessor;
}

public bool IsNavigationTarget(INavigationContext navigationContext) =>
public bool IsNavigationTarget(NavigationContext navigationContext) =>
navigationContext.NavigatedName() == Name;

private string? _message;
Expand All @@ -34,12 +34,12 @@ public int ViewCount

public string? PageName => _pageAccessor.Page?.GetType()?.Name;

public void OnNavigatedFrom(INavigationContext navigationContext)
public void OnNavigatedFrom(NavigationContext navigationContext)
{

}

public void OnNavigatedTo(INavigationContext navigationContext)
public void OnNavigatedTo(NavigationContext navigationContext)
{
if (navigationContext.Parameters.ContainsKey(nameof(Message)))
Message = navigationContext.Parameters.GetValue<string>(nameof(Message));
Expand Down
2 changes: 1 addition & 1 deletion e2e/Uno/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<Project ToolsVersion="15.0">
<Import Project="..\..\src\Uno\Prism.Uno\build\Prism.Uno.WinUI.targets" />
<Import Project="..\..\src\Prism.Core\build\Package.targets" />
</Project>
2 changes: 1 addition & 1 deletion e2e/Uno/HelloWorld/Views/Shell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
x:Class="HelloWorld.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pr="using:Prism.Regions"
xmlns:pr="using:Prism.Navigation.Regions"
xmlns:pvm="using:Prism.Mvvm"
pvm:ViewModelLocator.AutowireViewModel="true"
xmlns:local="using:HelloWorld.Views"
Expand Down
4 changes: 2 additions & 2 deletions e2e/Wpf/HelloWorld/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using HelloWorld.Core;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Navigation.Regions;
using Prism.Dialogs;

namespace HelloWorld.ViewModels
Expand Down Expand Up @@ -35,7 +35,7 @@ public MainWindowViewModel(IDialogService dialogService, IRegionManager regionMa
{
_dialogService = dialogService;
_regionManager = regionManager;
ShowDialogCommand = new DelegateCommand(ShowDialog);
ShowDialogCommand = new DelegateCommand(ShowDialog);
}

private void ShowDialog()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Prism.Ioc;
using Prism.Regions;
using Prism.Regions.Xaml;
using Prism.Navigation.Regions;
using Xamarin.Forms;

namespace Prism.Behaviors
Expand Down
8 changes: 4 additions & 4 deletions src/Forms/Prism.Forms.Regions/Common/MvvmHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Prism.Regions.Navigation;
using Prism.Navigation.Regions;
using Xamarin.Forms;

namespace Prism.Common
Expand Down Expand Up @@ -34,7 +34,7 @@ public static T GetImplementerFromViewOrViewModel<T>(object view)
return null;
}

public static bool IsNavigationTarget(object view, INavigationContext navigationContext)
public static bool IsNavigationTarget(object view, NavigationContext navigationContext)
{
if (view is IRegionAware viewAsRegionAware)
{
Expand All @@ -55,12 +55,12 @@ public static bool IsNavigationTarget(object view, INavigationContext navigation
return path == viewType.Name || path == viewType.FullName;
}

public static void OnNavigatedFrom(object view, INavigationContext navigationContext)
public static void OnNavigatedFrom(object view, NavigationContext navigationContext)
{
ViewAndViewModelAction<IRegionAware>(view, x => x.OnNavigatedFrom(navigationContext));
}

public static void OnNavigatedTo(object view, INavigationContext navigationContext)
public static void OnNavigatedTo(object view, NavigationContext navigationContext)
{
ViewAndViewModelAction<IRegionAware>(view, x => x.OnNavigatedTo(navigationContext));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Prism.Regions;
using Prism.Regions.Adapters;
using Prism.Regions.Behaviors;
using Prism.Regions.Navigation;
using System;
using Prism.Navigation.Regions;
using Prism.Navigation.Regions.Adapters;
using Prism.Navigation.Regions.Behaviors;
using Prism.Navigation.Regions.Navigation;
using Xamarin.Forms;

namespace Prism.Ioc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Prism.Navigation;
using Prism.Regions;
using Prism.Navigation.Regions;

namespace Prism.Ioc
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Prism.Behaviors;
using Prism.Common;
using Prism.Ioc;
using Prism.Navigation;
using Prism.Properties;
using Prism.Regions.Behaviors;
using Prism.Regions.Navigation;
using Xamarin.Forms;

namespace Prism.Regions.Adapters
namespace Prism.Navigation.Regions.Adapters
{
/// <summary>
/// Adapter that creates a new <see cref="SingleActiveRegion"/> and monitors its
Expand Down Expand Up @@ -56,7 +51,7 @@ protected override void Adapt(IRegion region, CarouselView regionTarget)

region.ActiveViews.CollectionChanged += delegate
{
var activeView = region.ActiveViews.FirstOrDefault();
var activeView = region.ActiveViews.OfType<VisualElement>().FirstOrDefault();
regionBehavior.CurrentView = activeView;
regionTarget.CurrentItem = activeView;
};
Expand Down
Loading
Loading