Skip to content

Commit

Permalink
Merge pull request #277 from egvijayanand/working
Browse files Browse the repository at this point in the history
New Project Template using HybridWebView
  • Loading branch information
egvijayanand authored Nov 29, 2024
2 parents 515e211 + 0dafd93 commit 4abca4b
Show file tree
Hide file tree
Showing 37 changed files with 1,364 additions and 358 deletions.
213 changes: 145 additions & 68 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/MauiTemplatesCLI/Create-Template.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ if not exist .\bin\%config%\%packageName%.%packageVersion%.nupkg goto create
echo.
call Info "Deleting existing package ..."

echo.
del .\bin\%config%\%packageName%.%packageVersion%.nupkg

:create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
{
"id": "include-camera",
"name": {
"text": "Add and configure CommunityTool_kit.Maui.Camera NuGet package reference (.NET 8 or later)"
"text": "Add and configure CommunityTool_kit.Maui.Camera NuGet package reference"
},
"isVisible": true,
"defaultValue": "false"
Expand Down
101 changes: 75 additions & 26 deletions src/MauiTemplatesCLI/MauiAppCS/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
]
},
{
"condition": "(Hybrid)",
"condition": "(Hybrid || JSHybrid)",
"exclude": [
"AppShell.razor",
"Views/MainPage.razor"
Expand Down Expand Up @@ -347,7 +347,7 @@
}
},
{
"condition": "(Plain || Hybrid || CSharp)",
"condition": "(Plain || Hybrid || JSHybrid || CSharp)",
"exclude": [
"**/Exceptions/*",
"**/Models/*",
Expand All @@ -367,7 +367,7 @@
]
},
{
"condition": "((Xaml || Hybrid || Markup) && MauiLib)",
"condition": "((Xaml || Hybrid || JSHybrid || Markup) && MauiLib)",
"rename": {
"App.xaml": "MauiApp.1.MauiLib/App.xaml",
"App.xaml.cs": "MauiApp.1.MauiLib/App.xaml.cs",
Expand Down Expand Up @@ -402,7 +402,7 @@
}
},
{
"condition": "((Xaml || Hybrid) && MauiLib)",
"condition": "((Xaml || Hybrid || JSHybrid) && MauiLib)",
"rename": {
"Resources/Colors.xaml": "MauiApp.1.MauiLib/Resources/Colors.xaml",
"Resources/Styles.xaml": "MauiApp.1.MauiLib/Resources/Styles.xaml",
Expand Down Expand Up @@ -449,7 +449,7 @@
}
},
{
"condition": "((Plain || Hierarchical || Tabbed || Hybrid || Markup) && MauiLib & Mvvm)",
"condition": "((Plain || Hierarchical || Tabbed || Hybrid || JSHybrid || Markup) && MauiLib & Mvvm)",
"rename": {
"ViewModels/BaseViewModel.cs": "MauiApp.1.MauiLib/ViewModels/BaseViewModel.cs",
"ViewModels/MainViewModel.cs": "MauiApp.1.MauiLib/ViewModels/MainViewModel.cs"
Expand Down Expand Up @@ -530,6 +530,39 @@
"exclude": [
"NuGet.config"
]
},
{
"condition": "(JSHybridNet9 && MauiLib)",
"rename": {
"Converters/HybridWebViewRawMessageReceivedEventArgs.cs": "MauiApp.1.MauiLib/Converters/HybridWebViewRawMessageReceivedEventArgs.cs",
"Resources/Raw/hybridroot/css/bootstrap/bootstrap.min.css": "MauiApp.1/Resources/Raw/wwwroot/css/bootstrap/bootstrap.min.css",
"Resources/Raw/hybridroot/css/bootstrap/bootstrap.min.css.map": "MauiApp.1/Resources/Raw/wwwroot/css/bootstrap/bootstrap.min.css.map",
"Resources/Raw/hybridroot/css/app.css": "MauiApp.1/Resources/Raw/wwwroot/css/app.css",
"Resources/Raw/hybridroot/scripts/hwv.js": "MauiApp.1/Resources/Raw/wwwroot/scripts/hwv.js",
"Resources/Raw/hybridroot/index.html": "MauiApp.1/Resources/Raw/wwwroot/index.html"
}
},
{
"condition": "(JSHybridNet9)",
"rename": {
"hybridroot/css/bootstrap/bootstrap.min.css": "wwwroot/css/bootstrap/bootstrap.min.css",
"hybridroot/css/bootstrap/bootstrap.min.css.map": "wwwroot/css/bootstrap/bootstrap.min.css.map",
"hybridroot/css/app.css": "wwwroot/css/app.css",
"hybridroot/scripts/hwv.js": "wwwroot/scripts/hwv.js",
"hybridroot/index.html": "wwwroot/index.html"
}
},
{
"condition": "(Net8 || !JSHybrid)",
"exclude": [
"Resources/Raw/hybridroot/**/*"
]
},
{
"condition": "(Net8 || !(JSHybrid && Mvvm))",
"exclude": [
"Converters/**/*"
]
}
]
}
Expand Down Expand Up @@ -585,15 +618,19 @@
},
{
"choice": "Tab",
"description": "App configured to work in a Tabbed fashion using TabbedPage."
"description": "App configured to work in a Tabbed mode using TabbedPage."
},
{
"choice": "Shell",
"description": "App configured to work with Routes using Shell page."
},
{
"choice": "Hybrid",
"description": "App configured to work in a Hybrid fashion using BlazorWebView."
"description": "App configured to work in a Blazor Hybrid mode using BlazorWebView."
},
{
"choice": "JSHybrid",
"description": "App configured to work in a JavaScript Hybrid mode using HybridWebView (.NET MAUI 9 or later)."
},
{
"choice": "Markup",
Expand Down Expand Up @@ -739,7 +776,7 @@
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Option to add and configure CommunityToolkit.Maui.Camera NuGet package reference (.NET 8 or later).",
"description": "Option to add and configure CommunityToolkit.Maui.Camera NuGet package reference.",
"displayName": "Add and configure CommunityTool_kit.Maui.Camera NuGet package reference"
},
"include-maps": {
Expand Down Expand Up @@ -842,6 +879,22 @@
"toLower": true
}
},
"Net8": {
"type": "computed",
"value": "(frameworkLower == \"net8.0\")"
},
"Net9": {
"type": "computed",
"value": "(frameworkLower == \"net9.0\")"
},
"Net8OrLater": {
"type": "computed",
"value": "(Net8 || Net9)"
},
"Net9OrLater": {
"type": "computed",
"value": "(Net9)"
},
"Plain": {
"type": "computed",
"value": "(design-pattern == \"Plain\" || designPatternLower == \"plain\")"
Expand All @@ -862,6 +915,18 @@
"type": "computed",
"value": "(design-pattern == \"Hybrid\" || designPatternLower == \"hybrid\")"
},
"JSHybrid": {
"type": "computed",
"value": "(design-pattern == \"JSHybrid\" || designPatternLower == \"jshybrid\")"
},
"JSHybridNet9": {
"type": "computed",
"value": "(Net9OrLater && JSHybrid)"
},
"Fallback": {
"type": "computed",
"value": "(Net8 && JSHybrid)"
},
"Markup": {
"type": "computed",
"value": "(design-pattern == \"Markup\" || designPatternLower == \"markup\")"
Expand All @@ -888,7 +953,7 @@
},
"Xaml": {
"type": "computed",
"value": "(Plain || Hierarchical || Tabbed || Shell)"
"value": "(Plain || Hierarchical || Tabbed || Shell || JSHybrid)"
},
"Mvvm": {
"type": "computed",
Expand All @@ -902,22 +967,6 @@
"type": "computed",
"value": "(Razor || Reactor)"
},
"Net8": {
"type": "computed",
"value": "(frameworkLower == \"net8.0\")"
},
"Net9": {
"type": "computed",
"value": "(frameworkLower == \"net9.0\")"
},
"Net8OrLater": {
"type": "computed",
"value": "(Net8 || Net9)"
},
"Net9OrLater": {
"type": "computed",
"value": "(Net9)"
},
"AllPlatforms": {
"type": "computed",
"value": "(target-platform == \"All\")"
Expand Down Expand Up @@ -976,7 +1025,7 @@
},
"AddToolkit": {
"type": "computed",
"value": "(include-toolkit)"
"value": "(include-toolkit || (JSHybridNet9 && Mvvm))"
},
"AddSyncfusionToolkit": {
"type": "computed",
Expand Down
4 changes: 2 additions & 2 deletions src/MauiTemplatesCLI/MauiAppCS/App.markup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public App()
.MauiStyle);
Resources.Add("Action", new Style<Button>(
(Button.FontFamilyProperty, AppString("AppFont")!),
(Button.FontSizeProperty, AppDouble("AppFontSize")!),
(Button.FontSizeProperty, AppResource<double>("AppFontSize", 14d)),
(Button.PaddingProperty, new Thickness(14,10))
).AddAppThemeBinding(Button.BackgroundColorProperty, AppColor("BackgroundLight"), AppColor("BackgroundDark"))
.AddAppThemeBinding(Button.TextColorProperty, AppColor("TextLight"), AppColor("TextDark"))
Expand All @@ -53,7 +53,7 @@ public App()

#if Net8
#if Mvvm
MainPage = services.GetService<MainPage>();
MainPage = services.GetRequiredService<MainPage>();
#else
MainPage = new MainPage();
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/MauiTemplatesCLI/MauiAppCS/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public partial class App : Application
{
#if Mvvm
#if Net9OrLater
#if (Plain || Hierarchical || Hybrid)
#if (Plain || Hierarchical || Hybrid || JSHybridNet9)
private readonly IServiceProvider _services;

#endif
Expand All @@ -24,15 +24,15 @@ public App(IServiceProvider services)
{
InitializeComponent();
#if Net9OrLater
#if (Plain || Hierarchical || Hybrid)
#if (Plain || Hierarchical || Hybrid || JSHybridNet9)
_services = services;
#endif
#endif

#if Net8
#if Hierarchical
MainPage = new NavigationPage(services.GetRequiredService<MainPage>());
#elif (Plain || Hybrid)
#elif (Plain || Hybrid || Fallback)
MainPage = services.GetRequiredService<MainPage>();
#elif Shell
MainPage = new AppShell();
Expand Down Expand Up @@ -63,15 +63,15 @@ public App()
UserAppTheme = PlatformAppTheme;
}
#endif
#if (Net9OrLater || Plain || Hierarchical || Tabbed || Hybrid)
#if (Net9OrLater || Plain || Hierarchical || Tabbed || Hybrid || Fallback)

protected override Window CreateWindow(IActivationState? activationState)
{
#if Net9OrLater
#if Mvvm
#if Hierarchical
var window = new Window(new NavigationPage(_services.GetRequiredService<MainPage>()));
#elif (Plain || Hybrid)
#elif (Plain || Hybrid || JSHybridNet9)
var window = new Window(_services.GetRequiredService<MainPage>());
#elif Shell
return new Window(new AppShell());
Expand All @@ -90,7 +90,7 @@ protected override Window CreateWindow(IActivationState? activationState)
#else
var window = base.CreateWindow(activationState);
#endif
#if (Plain || Hierarchical || Tabbed || Hybrid)
#if (Plain || Hierarchical || Tabbed || Hybrid || JSHybridNet9 || Fallback)
window.Title = "MauiApp._1";
return window;
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace MauiApp._1.Converters
{
[AcceptEmptyServiceProvider]
public partial class HybridWebViewRawMessageReceivedEventArgsConverter : BaseConverterOneWay<HybridWebViewRawMessageReceivedEventArgs?, object?>
{
public override object? DefaultConvertReturnValue { get; set; } = null;

[return: NotNullIfNotNull(nameof(value))]
public override object? ConvertFrom(HybridWebViewRawMessageReceivedEventArgs? value, CultureInfo? culture)
=> value switch
{
null => null,
_ => value.Message
};
}
}
12 changes: 8 additions & 4 deletions src/MauiTemplatesCLI/MauiAppCS/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<!--#if (Net9)-->
<!--#if (Nightly)-->
<MauiVersion>9.0.10</MauiVersion>
<MauiVersion>9.0.20-ci.main.24578.1</MauiVersion>
<!--#else-->
<MauiVersion>9.0.10</MauiVersion>
<!--#endif-->
Expand Down Expand Up @@ -78,8 +78,12 @@
<PackageVersion Include="Syncfusion.Maui.Toolkit" Version="1.0.2" />
<!--#endif-->
<!--#if (AddMarkup)-->
<!--#if (Net9)-->
<PackageVersion Include="CommunityToolkit.Maui.Markup" Version="5.1.0" />
<!--#else-->
<PackageVersion Include="CommunityToolkit.Maui.Markup" Version="4.2.0" />
<!--#endif-->
<!--#endif-->
<!--#if (AddCamera)-->
<PackageVersion Include="CommunityToolkit.Maui.Camera" Version="1.0.5" />
<!--#endif-->
Expand All @@ -101,10 +105,10 @@
<!--#endif-->
<!--#if (Reactor)-->
<!--#if (Net9OrLater)-->
<PackageVersion Include="Reactor.Maui" Version="3.0.0-beta" />
<PackageVersion Include="Reactor.Maui.Canvas" Version="3.0.0-beta" />
<PackageVersion Include="Reactor.Maui" Version="3.0.6-beta" />
<PackageVersion Include="Reactor.Maui.Canvas" Version="3.0.6-beta" />
<!--#if (AddMaps)-->
<PackageVersion Include="Reactor.Maui.Maps" Version="3.0.0-beta" />
<PackageVersion Include="Reactor.Maui.Maps" Version="3.0.6-beta" />
<!--#endif-->
<!--#else-->
<PackageVersion Include="Reactor.Maui" Version="2.0.55" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@
<PackageReference Include="Syncfusion.Maui.Toolkit" Version="1.*" />
<!--#endif-->
<!--#if (AddMarkup)-->
<!--#if (Net9)-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="5.*" />
<!--#else-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.*" />
<!--#endif-->
<!--#endif-->
<!--#if (AddCamera)-->
<PackageReference Include="CommunityToolkit.Maui.Camera" Version="1.*" />
<!--#endif-->
Expand Down
4 changes: 4 additions & 0 deletions src/MauiTemplatesCLI/MauiAppCS/MauiApp.1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,12 @@
<PackageReference Include="Syncfusion.Maui.Toolkit" Version="1.*" />
<!--#endif-->
<!--#if (AddMarkup)-->
<!--#if (Net9)-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="5.*" />
<!--#else-->
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.*" />
<!--#endif-->
<!--#endif-->
<!--#if (AddCamera)-->
<PackageReference Include="CommunityToolkit.Maui.Camera" Version="1.*" />
<!--#endif-->
Expand Down
Loading

0 comments on commit 4abca4b

Please sign in to comment.