-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.NET MAUI 9 HybridWebView sample app
- Loading branch information
1 parent
f6b26b9
commit 93a8a1b
Showing
43 changed files
with
1,405 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Application | ||
x:Class="HybridWebViewApp.App" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:HybridWebViewApp" | ||
mc:Ignorable="d"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<!-- Additional Styles --> | ||
<x:Double x:Key="ItemSpacing">10</x:Double> | ||
|
||
<Style ApplyToDerivedTypes="True" TargetType="StackBase"> | ||
<Setter Property="Spacing" | ||
Value="{StaticResource ItemSpacing}" /> | ||
</Style> | ||
|
||
<Style x:Key="MauiLabel" TargetType="Label"> | ||
<Setter Property="TextColor" | ||
Value="{AppThemeBinding Dark={StaticResource White}, Light={StaticResource Primary}}" /> | ||
</Style> | ||
|
||
<Style x:Key="Action" TargetType="Button"> | ||
<Setter Property="BackgroundColor" | ||
Value="{AppThemeBinding Dark={StaticResource BackgroundDark}, Light={StaticResource BackgroundLight}}" /> | ||
<Setter Property="TextColor" | ||
Value="{AppThemeBinding Dark={StaticResource TextDark}, Light={StaticResource TextLight}}" /> | ||
<Setter Property="FontFamily" | ||
Value="{StaticResource AppFont}" /> | ||
<Setter Property="FontSize" | ||
Value="{StaticResource AppFontSize}" /> | ||
<Setter Property="Padding" | ||
Value="14,10" /> | ||
</Style> | ||
|
||
<Style x:Key="PrimaryAction" | ||
TargetType="Button" | ||
BasedOn="{StaticResource Action}"> | ||
<Setter Property="BackgroundColor" | ||
Value="{StaticResource Primary}" /> | ||
<Setter Property="FontAttributes" | ||
Value="Bold" /> | ||
<Setter Property="TextColor" | ||
Value="{StaticResource White}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace HybridWebViewApp | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
UserAppTheme = PlatformAppTheme; | ||
} | ||
|
||
protected override Window CreateWindow(IActivationState? activationState) | ||
=> new Window(new MainPage()) { Title = "HybridWebViewApp" }; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/NET_9/HybridWebViewApp/HybridWebViewApp.code-workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "." | ||
} | ||
], | ||
"settings": {}, | ||
"extensions": { | ||
"recommendations": [ | ||
"ms-dotnettools.csharp", | ||
"ms-dotnettools.dotnet-maui", | ||
"VisualStudioExptTeam.vscodeintellicode" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net9.0-android</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst;net9.0-windows10.0.19041.0</TargetFrameworks> | ||
<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-tizen</TargetFrameworks> --> | ||
<TargetFrameworks>$(TargetFrameworks);net9.0</TargetFrameworks> | ||
<OutputType Condition="'$(TargetFramework)' != 'net9.0'">Exe</OutputType> | ||
|
||
<!-- .NET MAUI --> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
|
||
<!-- Project Options --> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RootNamespace>HybridWebViewApp</RootNamespace> | ||
<WindowsPackageType>None</WindowsPackageType> | ||
|
||
<!-- Display name --> | ||
<ApplicationTitle>HybridWebViewApp</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationId>com.companyname.hybridwebviewapp</ApplicationId> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<!-- Target Platform Options --> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> | ||
|
||
<!-- Minimum Target OS Version for Windows Platform --> | ||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" /> | ||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" /> | ||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*" /> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*" /> | ||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="HybridWebViewApp.code-workspace" /> | ||
<None Remove="HybridWebViewApp.slnx" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.*-*" Condition="'$(Configuration)' == 'Debug'" /> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'"> | ||
<BundleResource Include="Platforms\iOS\PrivacyInfo.xcprivacy" LogicalName="PrivacyInfo.xcprivacy" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'"> | ||
<BundleResource Include="Platforms\MacCatalyst\PrivacyInfo.xcprivacy" LogicalName="PrivacyInfo.xcprivacy" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31611.283 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{371A51A3-7E6B-415E-A4CD-ADAC03BCC115}") = "HybridWebViewApp", "HybridWebViewApp.csproj", "{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A46627CB-85E6-4A7B-BAA0-A785D0B73BC1}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {5C1129A5-874B-4811-96D2-0ADA1CB519F8} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Solution> | ||
<Project Path="HybridWebViewApp.csproj"> | ||
<Deploy /> | ||
</Project> | ||
<Properties Name="Visual Studio"> | ||
<!-- Support is provisionally available on Visual Studio 17.10 and later versions. --> | ||
<Property Name="OpenWith" Value="17" /> | ||
</Properties> | ||
</Solution> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
global using HybridWebViewApp; | ||
global using HybridWebViewApp.Views; | ||
|
||
// Static | ||
global using static Microsoft.Maui.Graphics.Colors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace HybridWebViewApp | ||
{ | ||
public static partial class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("OpenSans-SemiBold.ttf", "OpenSansSemiBold"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
return builder.Build(); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/NET_9/HybridWebViewApp/Platforms/Android/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35" /> | ||
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
</manifest> |
12 changes: 12 additions & 0 deletions
12
src/NET_9/HybridWebViewApp/Platforms/Android/MainActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace HybridWebViewApp | ||
{ | ||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
|
||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/NET_9/HybridWebViewApp/Platforms/Android/MainApplication.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Android.App; | ||
using Android.Runtime; | ||
|
||
namespace HybridWebViewApp | ||
{ | ||
[Application] | ||
public class MainApplication : MauiApplication | ||
{ | ||
public MainApplication(IntPtr handle, JniHandleOwnership ownership) | ||
: base(handle, ownership) | ||
{ | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/NET_9/HybridWebViewApp/Platforms/Android/Resources/values/colors.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<resources> | ||
<color name="colorPrimary">#512BD4</color> | ||
<color name="colorPrimaryDark">#2B0B98</color> | ||
<color name="colorAccent">#2B0B98</color> | ||
</resources> |
10 changes: 10 additions & 0 deletions
10
src/NET_9/HybridWebViewApp/Platforms/MacCatalyst/AppDelegate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Foundation; | ||
|
||
namespace HybridWebViewApp | ||
{ | ||
[Register(nameof(AppDelegate))] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/NET_9/HybridWebViewApp/Platforms/MacCatalyst/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UIDeviceFamily</key> | ||
<array> | ||
<integer>1</integer> | ||
<integer>2</integer> | ||
</array> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>arm64</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>XSAppIconAssets</key> | ||
<string>Assets.xcassets/appicon.appiconset</string> | ||
</dict> | ||
</plist> |
43 changes: 43 additions & 0 deletions
43
src/NET_9/HybridWebViewApp/Platforms/MacCatalyst/PrivacyInfo.xcprivacy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSPrivacyAccessedAPITypes</key> | ||
<array> | ||
<dict> | ||
<key>NSPrivacyAccessedAPIType</key> | ||
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string> | ||
<key>NSPrivacyAccessedAPITypeReasons</key> | ||
<array> | ||
<string>C617.1</string> | ||
</array> | ||
</dict> | ||
<dict> | ||
<key>NSPrivacyAccessedAPIType</key> | ||
<string>NSPrivacyAccessedAPICategorySystemBootTime</string> | ||
<key>NSPrivacyAccessedAPITypeReasons</key> | ||
<array> | ||
<string>35F9.1</string> | ||
</array> | ||
</dict> | ||
<dict> | ||
<key>NSPrivacyAccessedAPIType</key> | ||
<string>NSPrivacyAccessedAPICategoryDiskSpace</string> | ||
<key>NSPrivacyAccessedAPITypeReasons</key> | ||
<array> | ||
<string>E174.1</string> | ||
</array> | ||
</dict> | ||
<!-- | ||
The entry below is only needed when you're using the Preferences API in your app. | ||
<dict> | ||
<key>NSPrivacyAccessedAPIType</key> | ||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string> | ||
<key>NSPrivacyAccessedAPITypeReasons</key> | ||
<array> | ||
<string>CA92.1</string> | ||
</array> | ||
</dict> --> | ||
</array> | ||
</dict> | ||
</plist> |
16 changes: 16 additions & 0 deletions
16
src/NET_9/HybridWebViewApp/Platforms/MacCatalyst/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using ObjCRuntime; | ||
using UIKit; | ||
|
||
namespace HybridWebViewApp | ||
{ | ||
public class Program | ||
{ | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
} | ||
} |
Oops, something went wrong.