Skip to content

Commit

Permalink
Use Forms modularity for Uno implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 23, 2020
1 parent efa56f2 commit 19d0cb5
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Prism.Commands;
using Prism.Modularity;
using Prism.Mvvm;
Expand Down Expand Up @@ -40,6 +41,7 @@ private void LoadModuleExecuted(IModuleInfo moduleInfo)
private void OnModuleLoaded(object sender, LoadModuleCompletedEventArgs e)
{
Modules = _moduleCatalog.Modules;
System.Console.WriteLine($"Stte: {Modules.First().State}");
}

public void Destroy()
Expand Down
1 change: 0 additions & 1 deletion e2e/Uno/HelloUnoWorld.Wasm/HelloUnoWorld.Wasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<WasmHead>true</WasmHead>
<DefineConstants>$(DefineConstants);__WASM__</DefineConstants>
<NoWarn>NU1701</NoWarn>
<WasmShellILLinkerEnabled>false</WasmShellILLinkerEnabled>
</PropertyGroup>
<PropertyGroup>
<!--
Expand Down
8 changes: 5 additions & 3 deletions src/Forms/Prism.Forms/Modularity/ModuleCatalog.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using System.Collections.Generic;

using Xamarin.Forms;

namespace Prism.Modularity
{
/// <summary>
/// The <see cref="ModuleCatalog"/> holds information about the modules that can be used by the
/// application. Each module is described in a <see cref="ModuleInfo"/> class, that records the
/// name and type of the module.
/// </summary>
[ContentProperty(nameof(Items))]
#if HAS_WINUI
[Windows.UI.Xaml.Markup.ContentProperty(Name = nameof(Items))]
#else
[Xamarin.Forms.ContentProperty(nameof(Items))]
#endif
public class ModuleCatalog : ModuleCatalogBase
{

Expand Down
18 changes: 15 additions & 3 deletions src/Forms/Prism.Forms/Modularity/ModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
using System.Collections.ObjectModel;
using System.Reflection;
using Prism.Properties;
using Xamarin.Forms;

namespace Prism.Modularity
{
/// <summary>
/// Defines the metadata that describes a module.
/// </summary>
[ContentProperty(nameof(DependsOn))]
#if HAS_WINUI
[Windows.UI.Xaml.Markup.ContentProperty(Name = nameof(DependsOn))]
#else
[Xamarin.Forms.ContentProperty(nameof(DependsOn))]
#endif
public partial class ModuleInfo : IModuleInfo
{
/// <summary>
Expand Down Expand Up @@ -149,6 +152,15 @@ string IModuleInfo.Ref
/// <summary>
/// Gets or sets the state of the <see cref="ModuleInfo"/> with regards to the module loading and initialization process.
/// </summary>
ModuleState IModuleInfo.State { get; set; }
public ModuleState State { get; private set; }

/// <summary>
/// Gets or sets the state of the <see cref="ModuleInfo"/> with regards to the module loading and initialization process.
/// </summary>
ModuleState IModuleInfo.State
{
get => State;
set => State = value;
}
}
}
2 changes: 2 additions & 0 deletions src/Forms/Prism.Forms/Modularity/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public void Initialize(IModuleInfo moduleInfo)
if (module != null)
{
module.RegisterTypes(_container);
#if !HAS_WINUI
module.GetType().AutoRegisterViews(_container);
#endif
module.OnInitialized(_container);
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/Uno/Prism.Uno/Prism.Uno.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Wpf\Prism.Wpf\**\*.cs" Exclude="..\..\Wpf\Prism.Wpf\bin\**\*.cs;..\..\Wpf\Prism.Wpf\obj\**\*.cs" />
<Compile Include="..\..\Forms\Prism.Forms\Modularity\*.cs" Link="Modularity\%(FileName)%(Extension)" />
<Compile Remove="**\*.net45.cs" />
<Compile Remove="**\*.netcore.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ConfigurationModuleCatalog.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ConfigurationStore.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\IConfigurationStore.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ModuleConfigurationElement.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ModuleConfigurationElementCollection.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ModuleDependencyCollection.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ModuleDependencyConfigurationElement.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Modularity\ModulesConfigurationSection.Desktop.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Bootstrapper.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\Interactivity\InvokeCommandAction.cs" />
<Compile Remove="..\..\Wpf\Prism.Wpf\PrismApplicationBase.cs" />
Expand Down
36 changes: 36 additions & 0 deletions src/Uno/Prism.Uno/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/Uno/Prism.Uno/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,16 @@
<data name="MustBeModuleGroupCatalog" xml:space="preserve">
<value>The ModuleCatalog must implement IModuleGroupCatalog to add groups</value>
</data>
<data name="DuplicatedModuleInCatalog" xml:space="preserve">
<value>A duplicated module with name {0} has been found in the ModuleCatalog.</value>
</data>
<data name="ModuleRefLocationNotSupported" xml:space="preserve">
<value>Module Reference Location is not supported in Xamarin.Forms</value>
</data>
<data name="NavigationModeNotAvailable" xml:space="preserve">
<value>NavigationMode is not available</value>
</data>
<data name="ServiceProviderDidNotHaveIProvideValueTarget" xml:space="preserve">
<value>The ServiceProvider did not provide a 'IProvideValueTarget'</value>
</data>
</root>

0 comments on commit 19d0cb5

Please sign in to comment.