Skip to content

Commit c0dff0c

Browse files
authored
Add MAUI desktop app (#54)
* Added basic MAUI desktop app * update build to use windows image
1 parent 22b9531 commit c0dff0c

File tree

25 files changed

+477
-2
lines changed

25 files changed

+477
-2
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
build:
1414
name: Builds the entire solution
15-
runs-on: ubuntu-latest
15+
runs-on: windows-latest
1616

1717
steps:
1818
- uses: actions/checkout@v4

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@
2727
/src/NodeDev.Core.Types/bin
2828
/src/NodeDev.EndToEndTests/bin
2929
/src/NodeDev.EndToEndTests/obj
30-
/src/NodeDev.Blazor.Server/project_backup.json
30+
/src/NodeDev.Blazor.Server/project_backup.json
31+
/src/NodeDev.Blazor.MAUI/bin/Debug/net9.0-windows10.0.19041.0/win10-x64
32+
/src/NodeDev.Blazor.MAUI/obj

src/NodeDev.Blazor.MAUI/App.xaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:NodeDev.Blazor.MAUI"
5+
x:Class="NodeDev.Blazor.MAUI.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
9+
<!--
10+
For information about styling .NET MAUI pages
11+
please refer to the documentation:
12+
https://go.microsoft.com/fwlink/?linkid=2282329
13+
-->
14+
15+
</ResourceDictionary>
16+
</Application.Resources>
17+
</Application>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace NodeDev.Blazor.MAUI
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new MainPage());
13+
}
14+
}
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@page "/"
2+
3+
<NodeDev.Blazor.Index />
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Router AppAssembly="@typeof(MauiProgram).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
</Router>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@using System.Net.Http
2+
@using System.Net.Http.Json
3+
@using Microsoft.AspNetCore.Components.Forms
4+
@using Microsoft.AspNetCore.Components.Routing
5+
@using Microsoft.AspNetCore.Components.Web
6+
@using Microsoft.AspNetCore.Components.Web.Virtualization
7+
@using Microsoft.JSInterop
8+
@using NodeDev.Blazor.MAUI
9+
@using NodeDev.Blazor.MAUI.Components
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:NodeDev.Blazor.MAUI"
5+
x:Class="NodeDev.Blazor.MAUI.MainPage">
6+
7+
<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
8+
<BlazorWebView.RootComponents>
9+
<RootComponent Selector="#app" ComponentType="{x:Type local:Components.Routes}" />
10+
</BlazorWebView.RootComponents>
11+
</BlazorWebView>
12+
13+
</ContentPage>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace NodeDev.Blazor.MAUI
2+
{
3+
public partial class MainPage : ContentPage
4+
{
5+
public MainPage()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Microsoft.Extensions.Logging;
2+
using NodeDev.Blazor.Services;
3+
4+
namespace NodeDev.Blazor.MAUI
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
});
17+
18+
var blazorWebView = builder.Services.AddMauiBlazorWebView();
19+
20+
blazorWebView.Services.AddNodeDev();
21+
22+
#if DEBUG
23+
builder.Services.AddBlazorWebViewDeveloperTools();
24+
builder.Logging.AddDebug();
25+
#endif
26+
27+
return builder.Build();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)