-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Styling sample * Complete with CommunityToolkit.Maui.Markup
- Loading branch information
1 parent
26bd7f2
commit 543bada
Showing
35 changed files
with
672 additions
and
0 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,12 @@ | ||
using BlazorBindings.Maui; | ||
using StylingSample.Resources; | ||
|
||
namespace StylingSample; | ||
|
||
public class App : BlazorBindingsApplication<AppShell> | ||
{ | ||
public App(IServiceProvider services) : base(services) | ||
{ | ||
Resources.Add(AppStyles.Default); | ||
} | ||
} |
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 @@ | ||
<Shell> | ||
<ShellContent Title="Home"> | ||
<MainPage /> | ||
</ShellContent> | ||
</Shell> |
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,51 @@ | ||
@page "/main" | ||
|
||
<ContentPage Resources="AppStyles.Scoped"> | ||
<VerticalStackLayout Spacing="25" | ||
Padding="new(30,0)" | ||
VerticalOptions="LayoutOptions.Center"> | ||
<Image Source="dotNetBotSource" | ||
HeightRequest="200" | ||
HorizontalOptions="LayoutOptions.Center" /> | ||
|
||
<Label Text="Hello, World!" | ||
FontSize="32" | ||
HorizontalOptions="LayoutOptions.Center" /> | ||
|
||
<Label Text="Welcome to .NET Multi-platform App UI" | ||
FontSize="18" | ||
HorizontalOptions="LayoutOptions.Center" /> | ||
|
||
<Button Text="@ButtonText" | ||
HorizontalOptions="LayoutOptions.Center" | ||
OnClick="OnCounterClicked" /> | ||
|
||
<Button Text="Change App Theme" OnClick="ChangeAppTheme"> | ||
</Button> | ||
</VerticalStackLayout> | ||
</ContentPage> | ||
|
||
@code { | ||
ImageSource dotNetBotSource = ImageSource.FromFile("dotnet_bot.png"); | ||
|
||
int count = 0; | ||
|
||
string ButtonText => count switch | ||
{ | ||
0 => "Click me", | ||
1 => $"Clicked 1 time", | ||
_ => $"Clicked {count} times" | ||
}; | ||
|
||
void OnCounterClicked() | ||
{ | ||
count++; | ||
} | ||
|
||
void ChangeAppTheme() | ||
{ | ||
MC.Application.Current!.UserAppTheme = MC.Application.Current!.UserAppTheme == AppTheme.Light | ||
? AppTheme.Dark | ||
: AppTheme.Light; | ||
} | ||
} |
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,26 @@ | ||
using BlazorBindings.Maui; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace StylingSample; | ||
|
||
public static class MauiProgram | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.UseMauiApp<App>() | ||
.UseMauiBlazorBindings() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); | ||
}); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
return builder.Build(); | ||
} | ||
} |
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"> | ||
<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" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
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 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
|
||
namespace StylingSample; | ||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
} |
14 changes: 14 additions & 0 deletions
14
samples/StylingSample/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,14 @@ | ||
using Android.App; | ||
using Android.Runtime; | ||
|
||
namespace StylingSample; | ||
[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
samples/StylingSample/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> |
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,8 @@ | ||
using Foundation; | ||
|
||
namespace StylingSample; | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
14 changes: 14 additions & 0 deletions
14
samples/StylingSample/Platforms/MacCatalyst/Entitlements.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,14 @@ | ||
<?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"> | ||
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.--> | ||
<dict> | ||
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. --> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. --> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
</dict> | ||
</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,38 @@ | ||
<?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> | ||
<!-- The Mac App Store requires you specify if the app uses encryption. --> | ||
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption --> | ||
<!-- <key>ITSAppUsesNonExemptEncryption</key> --> | ||
<!-- Please indicate <true/> or <false/> here. --> | ||
|
||
<!-- Specify the category for your app here. --> | ||
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype --> | ||
<!-- <key>LSApplicationCategoryType</key> --> | ||
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> --> | ||
<key>UIDeviceFamily</key> | ||
<array> | ||
<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> |
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 @@ | ||
using ObjCRuntime; | ||
using UIKit; | ||
|
||
namespace StylingSample; | ||
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)); | ||
} | ||
} |
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 Microsoft.Maui; | ||
using Microsoft.Maui.Hosting; | ||
using System; | ||
|
||
namespace StylingSample; | ||
|
||
internal class Program : MauiApplication | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
|
||
static void Main(string[] args) | ||
{ | ||
var app = new Program(); | ||
app.Run(args); | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="8" xmlns="http://tizen.org/ns/packages"> | ||
<profile name="common" /> | ||
<ui-application appid="maui-application-id-placeholder" exec="StylingSample.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single"> | ||
<label>maui-application-title-placeholder</label> | ||
<icon>maui-appicon-placeholder</icon> | ||
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" /> | ||
</ui-application> | ||
<shortcut-list /> | ||
<privileges> | ||
<privilege>http://tizen.org/privilege/internet</privilege> | ||
</privileges> | ||
<dependencies /> | ||
<provides-appdefined-privileges /> | ||
</manifest> |
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,8 @@ | ||
<maui:MauiWinUIApplication | ||
x:Class="StylingSample.WinUI.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:maui="using:Microsoft.Maui" | ||
xmlns:local="using:StylingSample.WinUI"> | ||
|
||
</maui:MauiWinUIApplication> |
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,23 @@ | ||
using Microsoft.UI.Xaml; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace StylingSample.WinUI; | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : MauiWinUIApplication | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
samples/StylingSample/Platforms/Windows/Package.appxmanifest
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,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Package | ||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" | ||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" | ||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" | ||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" | ||
IgnorableNamespaces="uap rescap"> | ||
|
||
<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" /> | ||
|
||
<mp:PhoneIdentity PhoneProductId="C507E0CC-F56B-4278-B6DD-35D73F90000B" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> | ||
|
||
<Properties> | ||
<DisplayName>$placeholder$</DisplayName> | ||
<PublisherDisplayName>User Name</PublisherDisplayName> | ||
<Logo>$placeholder$.png</Logo> | ||
</Properties> | ||
|
||
<Dependencies> | ||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> | ||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" /> | ||
</Dependencies> | ||
|
||
<Resources> | ||
<Resource Language="x-generate" /> | ||
</Resources> | ||
|
||
<Applications> | ||
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$"> | ||
<uap:VisualElements | ||
DisplayName="$placeholder$" | ||
Description="$placeholder$" | ||
Square150x150Logo="$placeholder$.png" | ||
Square44x44Logo="$placeholder$.png" | ||
BackgroundColor="transparent"> | ||
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" /> | ||
<uap:SplashScreen Image="$placeholder$.png" /> | ||
</uap:VisualElements> | ||
</Application> | ||
</Applications> | ||
|
||
<Capabilities> | ||
<rescap:Capability Name="runFullTrust" /> | ||
</Capabilities> | ||
|
||
</Package> |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="StylingSample.WinUI.app"/> | ||
|
||
<application xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<windowsSettings> | ||
<!-- The combination of below two tags have the following effect: | ||
1) Per-Monitor for >= Windows 10 Anniversary Update | ||
2) System < Windows 10 Anniversary Update | ||
--> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware> | ||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness> | ||
</windowsSettings> | ||
</application> | ||
</assembly> |
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,8 @@ | ||
using Foundation; | ||
|
||
namespace StylingSample; | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
Oops, something went wrong.