Skip to content

Commit dc70648

Browse files
Merged dotnet new maui template into samples/NativeAOT
1 parent 70bd636 commit dc70648

Some content is hidden

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

42 files changed

+735
-52
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: 17 additions & 1 deletion
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>
@@ -25,4 +28,17 @@
2528
<_FastDeploymentDiagnosticLogging>true</_FastDeploymentDiagnosticLogging>
2629
</PropertyGroup>
2730

31+
<ItemGroup>
32+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
33+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
34+
<MauiImage Include="Resources\Images\*" />
35+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
36+
<MauiFont Include="Resources\Fonts\*" />
37+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
38+
</ItemGroup>
39+
40+
<ItemGroup>
41+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
42+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0-alpha.1.25071.14" />
43+
</ItemGroup>
2844
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
3+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
44
</application>
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
56
<uses-permission android:name="android.permission.INTERNET" />
67
</manifest>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
using Android.Runtime;
5+
6+
namespace NativeAOT;
7+
8+
// Name required for typemap in NativeAotTypeManager
9+
[Activity (Name = "my.MainActivity", Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
10+
public class MainActivity : MauiAppCompatActivity
11+
{
12+
protected override void OnCreate(Bundle? savedInstanceState)
13+
{
14+
Log.Debug ("NativeAOT", "MainActivity.OnCreate()");
15+
16+
base.OnCreate (savedInstanceState);
17+
}
18+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace NativeAOT;
5+
6+
/// <summary>
7+
/// NOTE: This class is not required, but used for testing Android.App.Application subclasses.
8+
/// Name required for typemap in NativeAotTypeManager
9+
/// </summary>
10+
[Application (Name = "my.MainApplication")]
11+
public class MainApplication : MauiApplication
12+
{
13+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
14+
: base(handle, ownership)
15+
{
16+
Log.Debug ("NativeAOT", $"Application..ctor({handle.ToString ("x2")}, {transfer})");
17+
}
18+
19+
public override void OnCreate ()
20+
{
21+
Log.Debug ("NativeAOT", "Application.OnCreate()");
22+
23+
base.OnCreate ();
24+
}
25+
26+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
27+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#512BD4</color>
4+
<color name="colorPrimaryDark">#2B0B98</color>
5+
<color name="colorAccent">#2B0B98</color>
6+
</resources>
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading
Binary file not shown.
Binary file not shown.
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Any raw assets you want to be deployed with your application can be placed in
2+
this directory (and child directories). Deployment of the asset to your application
3+
is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
4+
5+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
6+
7+
These files will be deployed with your package and will be accessible using Essentials:
8+
9+
async Task LoadMauiAsset()
10+
{
11+
using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
12+
using var reader = new StreamReader(stream);
13+
14+
var contents = reader.ReadToEnd();
15+
}
Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<?xaml-comp compile="true" ?>
3+
<ResourceDictionary
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
6+
7+
<!-- Note: For Android please see also Platforms\Android\Resources\values\colors.xml -->
8+
9+
<Color x:Key="Primary">#512BD4</Color>
10+
<Color x:Key="PrimaryDark">#ac99ea</Color>
11+
<Color x:Key="PrimaryDarkText">#242424</Color>
12+
<Color x:Key="Secondary">#DFD8F7</Color>
13+
<Color x:Key="SecondaryDarkText">#9880e5</Color>
14+
<Color x:Key="Tertiary">#2B0B98</Color>
15+
16+
<Color x:Key="White">White</Color>
17+
<Color x:Key="Black">Black</Color>
18+
<Color x:Key="Magenta">#D600AA</Color>
19+
<Color x:Key="MidnightBlue">#190649</Color>
20+
<Color x:Key="OffBlack">#1f1f1f</Color>
21+
22+
<Color x:Key="Gray100">#E1E1E1</Color>
23+
<Color x:Key="Gray200">#C8C8C8</Color>
24+
<Color x:Key="Gray300">#ACACAC</Color>
25+
<Color x:Key="Gray400">#919191</Color>
26+
<Color x:Key="Gray500">#6E6E6E</Color>
27+
<Color x:Key="Gray600">#404040</Color>
28+
<Color x:Key="Gray900">#212121</Color>
29+
<Color x:Key="Gray950">#141414</Color>
30+
31+
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource Primary}"/>
32+
<SolidColorBrush x:Key="SecondaryBrush" Color="{StaticResource Secondary}"/>
33+
<SolidColorBrush x:Key="TertiaryBrush" Color="{StaticResource Tertiary}"/>
34+
<SolidColorBrush x:Key="WhiteBrush" Color="{StaticResource White}"/>
35+
<SolidColorBrush x:Key="BlackBrush" Color="{StaticResource Black}"/>
36+
37+
<SolidColorBrush x:Key="Gray100Brush" Color="{StaticResource Gray100}"/>
38+
<SolidColorBrush x:Key="Gray200Brush" Color="{StaticResource Gray200}"/>
39+
<SolidColorBrush x:Key="Gray300Brush" Color="{StaticResource Gray300}"/>
40+
<SolidColorBrush x:Key="Gray400Brush" Color="{StaticResource Gray400}"/>
41+
<SolidColorBrush x:Key="Gray500Brush" Color="{StaticResource Gray500}"/>
42+
<SolidColorBrush x:Key="Gray600Brush" Color="{StaticResource Gray600}"/>
43+
<SolidColorBrush x:Key="Gray900Brush" Color="{StaticResource Gray900}"/>
44+
<SolidColorBrush x:Key="Gray950Brush" Color="{StaticResource Gray950}"/>
45+
</ResourceDictionary>

0 commit comments

Comments
 (0)