Skip to content

Commit deae273

Browse files
Merged dotnet new maui template into samples/NativeAOT
1 parent b09d51a commit deae273

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1605
-61
lines changed

samples/NativeAOT/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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:NativeAOT"
5+
x:Class="NativeAOT.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

samples/NativeAOT/App.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace NativeAOT;
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 AppShell());
13+
}
14+
}

samples/NativeAOT/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="NativeAOT.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:NativeAOT"
7+
Title="NativeAOT">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

samples/NativeAOT/AppShell.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace NativeAOT;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}

samples/NativeAOT/MainActivity.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

samples/NativeAOT/MainPage.xaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
x:Class="NativeAOT.MainPage">
5+
6+
<ScrollView>
7+
<VerticalStackLayout
8+
Padding="30,0"
9+
Spacing="25">
10+
<Image
11+
Source="dotnet_bot.png"
12+
HeightRequest="185"
13+
Aspect="AspectFit"
14+
SemanticProperties.Description="dot net bot in a hovercraft number nine" />
15+
16+
<Label
17+
Text="Hello, World!"
18+
Style="{StaticResource Headline}"
19+
SemanticProperties.HeadingLevel="Level1" />
20+
21+
<Label
22+
Text="Welcome to &#10;.NET Multi-platform App UI"
23+
Style="{StaticResource SubHeadline}"
24+
SemanticProperties.HeadingLevel="Level2"
25+
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
26+
27+
<Button
28+
x:Name="CounterBtn"
29+
Text="Click me"
30+
SemanticProperties.Hint="Counts the number of times you click"
31+
Clicked="OnCounterClicked"
32+
HorizontalOptions="Fill" />
33+
</VerticalStackLayout>
34+
</ScrollView>
35+
36+
</ContentPage>

samples/NativeAOT/MainPage.xaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace NativeAOT;
2+
3+
public partial class MainPage : ContentPage
4+
{
5+
int count = 0;
6+
7+
public MainPage()
8+
{
9+
InitializeComponent();
10+
}
11+
12+
private void OnCounterClicked(object? sender, EventArgs e)
13+
{
14+
count++;
15+
16+
if (count == 1)
17+
CounterBtn.Text = $"Clicked {count} time";
18+
else
19+
CounterBtn.Text = $"Clicked {count} times";
20+
21+
SemanticScreenReader.Announce(CounterBtn.Text);
22+
}
23+
}

samples/NativeAOT/MauiProgram.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Extensions.Logging;
2+
3+
namespace NativeAOT;
4+
5+
public static class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder
11+
.UseMauiApp<App>()
12+
.ConfigureFonts(fonts =>
13+
{
14+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
15+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
16+
});
17+
18+
#if DEBUG
19+
builder.Logging.AddDebug();
20+
#endif
21+
22+
return builder.Build();
23+
}
24+
}

samples/NativeAOT/NativeAOT.csproj

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>$(DotNetAndroidTargetFramework)</TargetFramework>
4-
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
4+
<SupportedOSPlatformVersion>23</SupportedOSPlatformVersion>
55
<OutputType>Exe</OutputType>
66
<Nullable>enable</Nullable>
7+
<UseMaui>true</UseMaui>
8+
<SingleProject>true</SingleProject>
79
<ImplicitUsings>enable</ImplicitUsings>
10+
<ApplicationTitle>NativeAOT</ApplicationTitle>
811
<ApplicationId>net.dot.hellonativeaot</ApplicationId>
912
<ApplicationVersion>1</ApplicationVersion>
1013
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
@@ -30,7 +33,21 @@
3033
</PropertyGroup>
3134

3235
<ItemGroup>
33-
<AndroidJavaSource Update="*.java" Bind="false" />
36+
<AndroidJavaSource Include="*.java" Bind="false" />
3437
<ProjectReference Include="..\..\external\Java.Interop\src\Java.Runtime.Environment\Java.Runtime.Environment.csproj" />
3538
</ItemGroup>
39+
40+
<ItemGroup>
41+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
42+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
43+
<MauiImage Include="Resources\Images\*" />
44+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
45+
<MauiFont Include="Resources\Fonts\*" />
46+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
47+
</ItemGroup>
48+
49+
<ItemGroup>
50+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
51+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0-alpha.1.25071.14" />
52+
</ItemGroup>
3653
</Project>

0 commit comments

Comments
 (0)