Skip to content

Commit 3723654

Browse files
committed
first commit
0 parents  commit 3723654

Some content is hidden

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

44 files changed

+1158
-0
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
.idea/
3+
.vs/
4+
.settings/
5+
.vscode/
6+
node_modules/
7+
dist/
8+
wwwroot/
9+
10+
[Dd]ebug/
11+
[Rr]elease/
12+
x64/
13+
[Bb]in/
14+
[Oo]bj/
15+
16+
17+
*.binlog
18+
*.eslintrc
19+
*.csproj.user
20+
21+
package-lock.json
22+
Thumbs.db
23+
.DS_Store
24+

BlazorMaui.Core/App.cs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.JSInterop;
2+
using System;
3+
4+
namespace BlazorMaui.Core
5+
{
6+
public class App : Application
7+
{
8+
public App(WebViewContainer container)
9+
{
10+
MainPage = container;
11+
}
12+
13+
[JSInvokable]
14+
public static async Task<string> GetSystemInfo()
15+
{
16+
System.Text.StringBuilder sb = new System.Text.StringBuilder();
17+
18+
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux))
19+
{
20+
sb.AppendLine($"OS: {System.Runtime.InteropServices.RuntimeInformation.OSDescription}");
21+
sb.AppendLine($"|| OS Version: {Environment.OSVersion.ToString()}");
22+
sb.AppendLine($"|| .Net Version: {Environment.Version.ToString()}");
23+
sb.AppendLine($"|| MachineName: {Environment.MachineName}");
24+
}
25+
else
26+
{
27+
sb.AppendLine($"Model: {DeviceInfo.Current.Model}");
28+
sb.AppendLine($"|| Manufacturer: {DeviceInfo.Current.Manufacturer}");
29+
sb.AppendLine($"|| Name: {DeviceInfo.Current.Name}");
30+
sb.AppendLine($"|| OS Version: {DeviceInfo.Current.VersionString}");
31+
sb.AppendLine($"|| Idiom: {DeviceInfo.Current.Idiom}");
32+
sb.AppendLine($"|| Platform: {DeviceInfo.Current.Platform}");
33+
}
34+
35+
return await Task.FromResult(
36+
sb.ToString()
37+
);
38+
}
39+
40+
41+
}
42+
}
+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
6+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('linux'))">net8.0;net8.0-android</TargetFrameworks>
7+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
8+
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
9+
10+
<!-- Note for MacCatalyst:
11+
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
12+
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
13+
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
14+
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
15+
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
16+
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
17+
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
18+
<OutputType>Exe</OutputType>
19+
<RootNamespace>BlazorMaui.Core</RootNamespace>
20+
<UseMaui>true</UseMaui>
21+
<SingleProject>true</SingleProject>
22+
<ImplicitUsings>enable</ImplicitUsings>
23+
<EnableDefaultCssItems>false</EnableDefaultCssItems>
24+
<Nullable>enable</Nullable>
25+
26+
<!-- Display name -->
27+
<ApplicationTitle>BlazorMaui.Core</ApplicationTitle>
28+
29+
<!-- App Identifier -->
30+
<ApplicationId>com.companyname.blazormaui.core</ApplicationId>
31+
32+
<!-- Versions -->
33+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
34+
<ApplicationVersion>1</ApplicationVersion>
35+
36+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
37+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
38+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
39+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
40+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
41+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
42+
43+
<WindowsPackageType Condition="$([MSBuild]::IsOSPlatform('windows'))">None</WindowsPackageType>
44+
45+
</PropertyGroup>
46+
47+
<PropertyGroup Condition="'$(IsOSX)'=='true'">
48+
<DefineConstants>OSX</DefineConstants>
49+
</PropertyGroup>
50+
<PropertyGroup Condition="'$(IsLinux)'=='true'">
51+
<DefineConstants>Linux</DefineConstants>
52+
</PropertyGroup>
53+
54+
<ItemGroup>
55+
<!-- App Icon -->
56+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
57+
58+
<!-- Splash Screen -->
59+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
60+
61+
<!-- Images -->
62+
<MauiImage Include="Resources\Images\*" />
63+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
64+
65+
<!-- Custom Fonts -->
66+
<MauiFont Include="Resources\Fonts\*" />
67+
68+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
69+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
70+
</ItemGroup>
71+
72+
<ItemGroup>
73+
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.0.0" />
74+
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.71" />
75+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.71" />
76+
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.71" />
77+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
78+
</ItemGroup>
79+
80+
<Choose>
81+
<When Condition="$([MSBuild]::IsOSPlatform('linux')) And '$(TargetFramework)' == 'net8.0'">
82+
<ItemGroup>
83+
<PackageReference Include="Photino.Blazor" Version="2.7.0" />
84+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
85+
</ItemGroup>
86+
</When>
87+
</Choose>
88+
89+
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('linux')) And '$(TargetFramework)' == 'net8.0'">
90+
<Content Update="wwwroot\**">
91+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
92+
</Content>
93+
</ItemGroup>
94+
95+
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
96+
<Exec Command="npm run build --prefix ../BlazorMaui.UI" />
97+
</Target>
98+
99+
</Project>

BlazorMaui.Core/MauiProgram.cs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Microsoft.Extensions.Logging;
2+
using CommunityToolkit.Maui.Markup;
3+
4+
namespace BlazorMaui.Core
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
// Enable Remote Debugging (Chrome Remote Debugger)
11+
Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--remote-debugging-port=5999");
12+
13+
var builder = MauiApp.CreateBuilder();
14+
builder
15+
.UseMauiApp<App>()
16+
.UseMauiCommunityToolkitMarkup()
17+
.ConfigureFonts(fonts =>
18+
{
19+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
20+
});
21+
22+
builder.Services.AddMauiBlazorWebView();
23+
24+
#if DEBUG
25+
builder.Services.AddBlazorWebViewDeveloperTools();
26+
builder.Logging.AddDebug();
27+
#endif
28+
29+
builder.Services.AddSingleton<App>();
30+
builder.Services.AddSingleton<WebViewContainer>();
31+
32+
return builder.Build();
33+
}
34+
}
35+
}
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace BlazorMaui.Core;
6+
7+
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
8+
public class MainActivity : MauiAppCompatActivity
9+
{
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace BlazorMaui.Core;
5+
6+
[Application]
7+
public class MainApplication : MauiApplication
8+
{
9+
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10+
: base(handle, ownership)
11+
{
12+
}
13+
14+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15+
}
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Foundation;
2+
3+
namespace BlazorMaui.Core;
4+
5+
[Register("AppDelegate")]
6+
public class AppDelegate : MauiUIApplicationDelegate
7+
{
8+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
5+
<dict>
6+
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
7+
<key>com.apple.security.app-sandbox</key>
8+
<true/>
9+
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
10+
<key>com.apple.security.network.client</key>
11+
<true/>
12+
</dict>
13+
</plist>
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<!-- The Mac App Store requires you specify if the app uses encryption. -->
6+
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption -->
7+
<!-- <key>ITSAppUsesNonExemptEncryption</key> -->
8+
<!-- Please indicate <true/> or <false/> here. -->
9+
10+
<!-- Specify the category for your app here. -->
11+
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype -->
12+
<!-- <key>LSApplicationCategoryType</key> -->
13+
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> -->
14+
<key>UIDeviceFamily</key>
15+
<array>
16+
<integer>2</integer>
17+
</array>
18+
<key>UIRequiredDeviceCapabilities</key>
19+
<array>
20+
<string>arm64</string>
21+
</array>
22+
<key>UISupportedInterfaceOrientations</key>
23+
<array>
24+
<string>UIInterfaceOrientationPortrait</string>
25+
<string>UIInterfaceOrientationLandscapeLeft</string>
26+
<string>UIInterfaceOrientationLandscapeRight</string>
27+
</array>
28+
<key>UISupportedInterfaceOrientations~ipad</key>
29+
<array>
30+
<string>UIInterfaceOrientationPortrait</string>
31+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
32+
<string>UIInterfaceOrientationLandscapeLeft</string>
33+
<string>UIInterfaceOrientationLandscapeRight</string>
34+
</array>
35+
<key>XSAppIconAssets</key>
36+
<string>Assets.xcassets/appicon.appiconset</string>
37+
</dict>
38+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using ObjCRuntime;
2+
using UIKit;
3+
4+
namespace BlazorMaui.Core;
5+
6+
public class Program
7+
{
8+
// This is the main entry point of the application.
9+
static void Main(string[] args)
10+
{
11+
// if you want to use a different Application Delegate class from "AppDelegate"
12+
// you can specify it here.
13+
UIApplication.Main(args, null, typeof(AppDelegate));
14+
}
15+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using Microsoft.Maui;
3+
using Microsoft.Maui.Hosting;
4+
5+
namespace BlazorMaui.Core;
6+
7+
class Program : MauiApplication
8+
{
9+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
10+
11+
static void Main(string[] args)
12+
{
13+
var app = new Program();
14+
app.Run(args);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="8" xmlns="http://tizen.org/ns/packages">
3+
<profile name="common" />
4+
<ui-application appid="maui-application-id-placeholder" exec="BlazorMaui.Core.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
5+
<label>maui-application-title-placeholder</label>
6+
<icon>maui-appicon-placeholder</icon>
7+
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
8+
</ui-application>
9+
<shortcut-list />
10+
<privileges>
11+
<privilege>http://tizen.org/privilege/internet</privilege>
12+
</privileges>
13+
<dependencies />
14+
<provides-appdefined-privileges />
15+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<maui:MauiWinUIApplication
2+
x:Class="BlazorMaui.Core.WinUI.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:maui="using:Microsoft.Maui"
6+
xmlns:local="using:BlazorMaui.Core.WinUI">
7+
8+
</maui:MauiWinUIApplication>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.UI.Xaml;
2+
3+
// To learn more about WinUI, the WinUI project structure,
4+
// and more about our project templates, see: http://aka.ms/winui-project-info.
5+
6+
namespace BlazorMaui.Core.WinUI;
7+
8+
/// <summary>
9+
/// Provides application-specific behavior to supplement the default Application class.
10+
/// </summary>
11+
public partial class App : MauiWinUIApplication
12+
{
13+
/// <summary>
14+
/// Initializes the singleton application object. This is the first line of authored code
15+
/// executed, and as such is the logical equivalent of main() or WinMain().
16+
/// </summary>
17+
public App()
18+
{
19+
this.InitializeComponent();
20+
}
21+
22+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23+
}
24+

0 commit comments

Comments
 (0)