Skip to content

Commit bd9caa2

Browse files
authored
Merge pull request #170 from FmgLib/whats-new-net9
Whats new net9
2 parents 140e6ca + da41f7f commit bd9caa2

Some content is hidden

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

47 files changed

+1955
-170
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- master
7+
- release/*
88
- develop
99

1010
env:

FmgLib.MauiMarkup.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MatchingImage", "sample\Mat
3838
EndProject
3939
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DalluiApp", "sample\DalluiApp\DalluiApp.csproj", "{F5A12C0E-7521-44A3-AE6A-A0B871B82B5B}"
4040
EndProject
41+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App1", "sample\App1\App1.csproj", "{8E5E5952-56CF-462C-9768-79F03E13AEBE}"
42+
EndProject
4143
Global
4244
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4345
Debug|Any CPU = Debug|Any CPU
@@ -102,6 +104,10 @@ Global
102104
{F5A12C0E-7521-44A3-AE6A-A0B871B82B5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
103105
{F5A12C0E-7521-44A3-AE6A-A0B871B82B5B}.Release|Any CPU.Build.0 = Release|Any CPU
104106
{F5A12C0E-7521-44A3-AE6A-A0B871B82B5B}.Release|Any CPU.Deploy.0 = Release|Any CPU
107+
{8E5E5952-56CF-462C-9768-79F03E13AEBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108+
{8E5E5952-56CF-462C-9768-79F03E13AEBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
109+
{8E5E5952-56CF-462C-9768-79F03E13AEBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
110+
{8E5E5952-56CF-462C-9768-79F03E13AEBE}.Release|Any CPU.Build.0 = Release|Any CPU
105111
EndGlobalSection
106112
GlobalSection(SolutionProperties) = preSolution
107113
HideSolutionNode = FALSE
@@ -118,6 +124,7 @@ Global
118124
{B47B6A87-BDE4-4925-B5EE-A0F1B369CE93} = {A4956394-4BE4-4C5A-BDD3-59F439A1FD98}
119125
{244351D3-44F2-4C90-9B1C-3BCE7DD14172} = {A4956394-4BE4-4C5A-BDD3-59F439A1FD98}
120126
{F5A12C0E-7521-44A3-AE6A-A0B871B82B5B} = {A4956394-4BE4-4C5A-BDD3-59F439A1FD98}
127+
{8E5E5952-56CF-462C-9768-79F03E13AEBE} = {A4956394-4BE4-4C5A-BDD3-59F439A1FD98}
121128
EndGlobalSection
122129
GlobalSection(ExtensibilityGlobals) = postSolution
123130
SolutionGuid = {2698E1E7-D253-457B-AF1B-6754123E0A11}

sample/App1/App.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.Maui;
2+
3+
namespace App1;
4+
5+
public partial class App : MC.Application
6+
{
7+
public App()
8+
{
9+
this.Resources(new MC.ResourceDictionary().MergedDictionaries(AppStyles.Default));
10+
}
11+
12+
protected override MC.Window CreateWindow(IActivationState? activationState) => new MC.Window(new AppShell());
13+
}

sample/App1/App1.csproj

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->
8+
9+
<!-- Note for MacCatalyst:
10+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
11+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
12+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
13+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
14+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
15+
16+
<OutputType>Exe</OutputType>
17+
<RootNamespace>App1</RootNamespace>
18+
<UseMaui>true</UseMaui>
19+
<SingleProject>true</SingleProject>
20+
<ImplicitUsings>enable</ImplicitUsings>
21+
<Nullable>enable</Nullable>
22+
23+
<!-- Display name -->
24+
<ApplicationTitle>App1</ApplicationTitle>
25+
26+
<!-- App Identifier -->
27+
<ApplicationId>com.companyname.app10</ApplicationId>
28+
<ApplicationIdGuid>f7b4f002-16fc-4768-af83-3343d9fd3b10</ApplicationIdGuid>
29+
30+
<!-- Versions -->
31+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
32+
<ApplicationVersion>1</ApplicationVersion>
33+
34+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">12.2</SupportedOSPlatformVersion>
35+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">12.0</SupportedOSPlatformVersion>
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
37+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
38+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
39+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
40+
</PropertyGroup>
41+
42+
<ItemGroup>
43+
<!-- App Icon -->
44+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>
45+
46+
<!-- Splash Screen -->
47+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>
48+
49+
<!-- Images -->
50+
<MauiImage Include="Resources\Images\*"/>
51+
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>
52+
53+
<!-- Custom Fonts -->
54+
<MauiFont Include="Resources\Fonts\*"/>
55+
56+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
57+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
58+
</ItemGroup>
59+
60+
<ItemGroup>
61+
<AndroidResource Remove="Views\**"/>
62+
<Compile Remove="Views\**"/>
63+
<EmbeddedResource Remove="Views\**"/>
64+
<MauiCss Remove="Views\**"/>
65+
<MauiXaml Remove="Views\**"/>
66+
<None Remove="Views\**"/>
67+
</ItemGroup>
68+
69+
<ItemGroup>
70+
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.21"/>
71+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.21"/>
72+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0"/>
73+
</ItemGroup>
74+
75+
<ItemGroup>
76+
<ProjectReference Include="..\..\src\FmgLib.MauiMarkup.Generator\FmgLib.MauiMarkup.Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
77+
<ProjectReference Include="..\..\src\FmgLib.MauiMarkup\FmgLib.MauiMarkup.csproj" />
78+
</ItemGroup>
79+
80+
</Project>

sample/App1/AppShell.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace App1;
2+
3+
public partial class AppShell : MC.Shell
4+
{
5+
public AppShell()
6+
{
7+
this
8+
.FlyoutBehavior(Microsoft.Maui.FlyoutBehavior.Disabled)
9+
.Items(
10+
new MC.ShellContent()
11+
.Title("Home")
12+
.ContentTemplate(() => new MainPage())
13+
.Route(nameof(MainPage))
14+
);
15+
}
16+
}

sample/App1/Imports.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
global using App1;
2+
3+
// Markup FmgLib
4+
global using FmgLib.MauiMarkup;
5+
global using FmgLib.MauiMarkup.Core;
6+
7+
// Static
8+
global using static Microsoft.Maui.Graphics.Colors;
9+
global using static Microsoft.Maui.Controls.FontAttributes;
10+
global using static Microsoft.Maui.Controls.LayoutAlignment;
11+
global using static Microsoft.Maui.ScrollBarVisibility;
12+
global using static Microsoft.Maui.SwipeMode;
13+
global using static Microsoft.Maui.SwipeDirection;
14+
global using static Microsoft.Maui.TextType;
15+
global using static Microsoft.Maui.Visibility;
16+
global using MC = Microsoft.Maui.Controls;

sample/App1/MainPage.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using System;
2+
using System.Reflection;
3+
using Microsoft.Maui;
4+
using Microsoft.Maui.Accessibility;
5+
using Microsoft.Maui.Controls.Internals;
6+
using Microsoft.Maui.Hosting;
7+
8+
namespace App1;
9+
10+
public partial class MainPage : MC.ContentPage, IFmgLibHotReload
11+
{
12+
public MainPage()
13+
{
14+
this.InitializeHotReload();
15+
}
16+
17+
public void Build()
18+
{
19+
var version = typeof(MauiApp).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
20+
?.InformationalVersion;
21+
var temp = static (ViewModel model) => model.Title;
22+
this
23+
.BindingContext(new ViewModel(){ Title = "Hello, World!" })
24+
.Content(
25+
new MC.ScrollView()
26+
.Content(
27+
new MC.Grid()
28+
.RowDefinitions(e => e.Star(90).Star(10))
29+
.Children(
30+
new MC.StackLayout()
31+
.Spacing(25)
32+
.Children(
33+
new MC.Label()
34+
.Text("Hello, World!")
35+
.FontSize(32)
36+
.CenterHorizontal()
37+
.SemanticHeadingLevel(SemanticHeadingLevel.Level1),
38+
new MC.Label()
39+
.Assign(out lbl)
40+
.Text(e => e.Getter(static (ViewModel v) => v.Title))
41+
.FontSize(18)
42+
.CenterHorizontal()
43+
.SemanticDescription("Welcome to dot net Multi platform App U I")
44+
.SemanticHeadingLevel(SemanticHeadingLevel.Level1),
45+
new MC.Label()
46+
.Text("Current count: 0")
47+
.FontSize(18)
48+
.FontAttributes(Bold)
49+
.CenterHorizontal()
50+
.Assign(out CounterLabel),
51+
new MC.Button()
52+
.Text("Click me")
53+
.CenterHorizontal()
54+
.OnClicked(OnCounterClicked)
55+
.SemanticHint("Counts the number of times you click"),
56+
new MC.Image()
57+
.Source("dotnet_bot.png")
58+
.SizeRequest(250, 310)
59+
.CenterHorizontal()
60+
.SemanticDescription("Cute dot net bot waving hi to you!")
61+
),
62+
new MC.Grid()
63+
.BackgroundColor(AppColors.Primary)
64+
.Row(1)
65+
.Children(
66+
new MC.Label()
67+
.Text($"dotNet version: {version}")
68+
.TextColor(White)
69+
.Center()
70+
)
71+
)
72+
)
73+
);
74+
75+
76+
}
77+
78+
private int _count = 0;
79+
private MC.Label CounterLabel, lbl;
80+
81+
82+
private void OnCounterClicked(object? sender, EventArgs e)
83+
{
84+
_count++;
85+
CounterLabel.Text = $"Current count: {_count}";
86+
(this.BindingContext as ViewModel).Title = "Deneme";
87+
// lbl.Bind(Label.TextProperty, static (ViewModel model) => model.Title);
88+
// lbl.SetBinding(Label.TextProperty, static (ViewModel model) => model.Title);
89+
SemanticScreenReader.Announce(CounterLabel.Text);
90+
}
91+
}
92+
93+
public class ViewModel : MC.BindableObject
94+
{
95+
private string _title;
96+
97+
public string Title
98+
{
99+
get => _title;
100+
set
101+
{
102+
_title = value;
103+
OnPropertyChanged();
104+
}
105+
}
106+
}

sample/App1/MauiProgram.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Microsoft.Extensions.Logging;
3+
using Microsoft.Maui.Controls.Hosting;
4+
using Microsoft.Maui.Hosting;
5+
6+
namespace App1;
7+
8+
public static class MauiProgram
9+
{
10+
public static MauiApp CreateMauiApp()
11+
{
12+
var builder = MauiApp.CreateBuilder();
13+
builder
14+
.UseMauiApp<App>()
15+
.ConfigureFonts(fonts =>
16+
{
17+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
18+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
19+
});
20+
21+
builder.Logging.AddDebug();
22+
23+
builder.Services
24+
.AddSingleton<App>()
25+
.AddSingleton<AppShell>()
26+
.AddScoped<MainPage>();
27+
28+
return builder.Build();
29+
}
30+
}
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+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
4+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace App1;
6+
7+
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true,
8+
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode |
9+
ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
10+
public class MainActivity : MauiAppCompatActivity
11+
{
12+
}

0 commit comments

Comments
 (0)