-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First take at the implementation of MaterialIcon
Crashes with HRESULT E_FAIL (0x80004005)
- Loading branch information
1 parent
5557e08
commit e663bb6
Showing
51 changed files
with
1,442 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:Material.Icons.Maui.Demo" | ||
x:Class="Material.Icons.Maui.Demo.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</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,10 @@ | ||
namespace Material.Icons.Maui.Demo; | ||
|
||
public partial class App { | ||
public App() { | ||
InitializeComponent(); | ||
|
||
// UserAppTheme = AppTheme.Light; | ||
MainPage = new AppShell(); | ||
} | ||
} |
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" ?> | ||
<Shell | ||
x:Class="Material.Icons.Maui.Demo.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:Material.Icons.Maui.Demo" | ||
Shell.FlyoutBehavior="Disabled" | ||
Title="Material.Icons Demo"> | ||
|
||
<ShellContent | ||
ContentTemplate="{DataTemplate local:MainPage}" | ||
Route="MainPage" /> | ||
|
||
</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,7 @@ | ||
namespace Material.Icons.Maui.Demo; | ||
|
||
public partial class AppShell { | ||
public AppShell() { | ||
InitializeComponent(); | ||
} | ||
} |
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,48 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<maui:ReactiveContentPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
x:TypeArguments="demo:MainViewModel" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:material="http://schemas.skproch/material/icons/2024" | ||
xmlns:maui="clr-namespace:ReactiveUI.Maui;assembly=ReactiveUI.Maui" | ||
xmlns:demo="clr-namespace:Material.Icons.Maui.Demo" | ||
x:Class="Material.Icons.Maui.Demo.MainPage" | ||
x:DataType="demo:MainViewModel"> | ||
|
||
<Grid> | ||
<CollectionView | ||
ItemsSource="{Binding Kinds}" | ||
SelectionMode="Single"> | ||
|
||
<CollectionView.ItemsLayout> | ||
<GridItemsLayout Orientation="Vertical" Span="12" /> | ||
</CollectionView.ItemsLayout> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate x:DataType="demo:PackIconKindGroup"> | ||
<Grid | ||
WidthRequest="64" HeightRequest="64" | ||
HorizontalOptions="Center" | ||
RowDefinitions="32,32" | ||
Background="Transparent"> | ||
|
||
<material:MaterialIcon | ||
Margin="2" | ||
Grid.Row="0" | ||
Kind="{Binding Kind}" /> | ||
|
||
<Label | ||
Grid.Row="1" | ||
Text="{Binding DisplayName}" | ||
MaxLines="1" | ||
LineBreakMode="TailTruncation" | ||
HorizontalTextAlignment="Center" | ||
VerticalOptions="Center" /> | ||
|
||
</Grid> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</Grid> | ||
|
||
</maui:ReactiveContentPage> |
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,11 @@ | ||
namespace Material.Icons.Maui.Demo; | ||
|
||
public partial class MainPage { | ||
public MainPage(MainViewModel viewModel) { | ||
Controls.Init(); | ||
|
||
BindingContext = viewModel; | ||
|
||
InitializeComponent(); | ||
} | ||
} |
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,63 @@ | ||
using System.Reactive.Linq; | ||
|
||
using DynamicData.Binding; | ||
using DynamicData; | ||
|
||
using ReactiveUI; | ||
using ReactiveUI.SourceGenerators; | ||
|
||
namespace Material.Icons.Maui.Demo; | ||
|
||
public partial class MainViewModel : ReactiveObject { | ||
private readonly SourceList<PackIconKindGroup> _kindsSource = new(); | ||
|
||
[Reactive] | ||
private ObservableCollectionExtended<PackIconKindGroup> _kinds = new(); | ||
|
||
[Reactive] | ||
private string? _searchText; | ||
|
||
[Reactive] | ||
private PackIconKindGroup? _group; | ||
|
||
[ObservableAsProperty] | ||
private string? _copyText; | ||
|
||
public MainViewModel() { | ||
_kindsSource.AddRange( | ||
(from name in Enum.GetNames<MaterialIconKind>() | ||
let kind = Enum.Parse<MaterialIconKind>(name) | ||
let value = (int)kind | ||
let item = (Name: name, Kind: kind, Value: value) | ||
group item by item.Value | ||
into g | ||
select new PackIconKindGroup(g.Select(x => x.Name))) | ||
.OrderBy(x => x.DisplayName)); | ||
|
||
var kindsFilter = this.WhenAnyValue(x => x.SearchText) | ||
.Select(text => string.IsNullOrEmpty(text) | ||
? CreateUnfilteredFilter() | ||
: CreateTextFilter(text)) | ||
.Throttle(TimeSpan.FromMilliseconds(250)); | ||
|
||
_kindsSource | ||
.Connect() | ||
.Filter(kindsFilter) | ||
.Sort(SortExpressionComparer<PackIconKindGroup>.Ascending(p => p.DisplayName)) | ||
.ObserveOn(RxApp.MainThreadScheduler) | ||
.Bind(_kinds) | ||
.Subscribe(); | ||
|
||
_copyTextHelper = this.WhenAnyValue(x => x.Group) | ||
.Select(value => value is null ? null : $"<wpf:MaterialIcon Kind=\"{value.Kind}\" />") | ||
.ToProperty(this, x => x.CopyText); | ||
} | ||
|
||
private static Func<PackIconKindGroup, bool> CreateUnfilteredFilter() { | ||
return _ => true; | ||
} | ||
|
||
private static Func<PackIconKindGroup, bool> CreateTextFilter(string searchText) { | ||
return kindGroup => kindGroup.Names.Any(a => a.Contains(searchText, StringComparison.CurrentCultureIgnoreCase)); | ||
} | ||
} |
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,73 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks> | ||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> | ||
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> --> | ||
|
||
<!-- Note for MacCatalyst: | ||
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64. | ||
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>. | ||
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated; | ||
either BOTH runtimes must be indicated or ONLY macatalyst-x64. --> | ||
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> --> | ||
|
||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Material.Icons.Maui.Demo</RootNamespace> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<!-- Display name --> | ||
<ApplicationTitle>Material.Icons Demo</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationId>com.companyname.material.icons.maui.demo</ApplicationId> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> | ||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" /> | ||
|
||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" /> | ||
|
||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*" /> | ||
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" /> | ||
|
||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*" /> | ||
|
||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" /> | ||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" /> | ||
<PackageReference Include="ReactiveUI.Maui" Version="20.1.1" /> | ||
<PackageReference Include="ReactiveUI.SourceGenerators" Version="1.0.3" /> | ||
<PackageReference Include="Splat.Microsoft.Extensions.DependencyInjection" Version="15.1.1" /> | ||
<PackageReference Include="Splat.Microsoft.Extensions.Logging" Version="15.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Material.Icons.Maui\Material.Icons.Maui.csproj" /> | ||
</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,44 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
using ReactiveUI; | ||
|
||
using Splat; | ||
using Splat.Microsoft.Extensions.DependencyInjection; | ||
using Splat.Microsoft.Extensions.Logging; | ||
|
||
namespace Material.Icons.Maui.Demo; | ||
|
||
public static 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"); | ||
}); | ||
|
||
// Initialization of Splat and ReactiveUI | ||
builder.Logging.AddSplat(); | ||
builder.Services.UseMicrosoftDependencyResolver(); | ||
Locator.CurrentMutable.InitializeSplat(); | ||
Locator.CurrentMutable.InitializeReactiveUI(); | ||
|
||
// ViewModels | ||
builder.Services.AddSingleton<MainViewModel>(); | ||
|
||
// Views | ||
builder.Services.AddSingleton<MainPage>(); | ||
|
||
#if DEBUG | ||
builder.Logging.AddDebug(); | ||
#endif | ||
|
||
var app = builder.Build(); | ||
|
||
// Post-initialization of Splat | ||
app.Services.UseMicrosoftDependencyResolver(); | ||
|
||
return app; | ||
} | ||
} |
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 @@ | ||
namespace Material.Icons.Maui.Demo; | ||
|
||
public class PackIconKindGroup { | ||
public PackIconKindGroup(IEnumerable<string> kinds) { | ||
var sortedKinds = kinds.OrderBy(x => x, StringComparer.InvariantCultureIgnoreCase).ToArray(); | ||
if (sortedKinds.Length == 0) | ||
throw new ArgumentException($"{nameof(kinds)} must contain at least one value"); | ||
Kind = Enum.Parse<MaterialIconKind>(sortedKinds[0]); | ||
DisplayName = sortedKinds[0]; | ||
Names = sortedKinds; | ||
} | ||
|
||
public MaterialIconKind Kind { get; } | ||
public string DisplayName { get; } | ||
public string[] Names { get; } | ||
} |
6 changes: 6 additions & 0 deletions
6
Material.Icons.Maui.Demo/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"> | ||
<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 Material.Icons.Maui.Demo { | ||
[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 { | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Material.Icons.Maui.Demo/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,13 @@ | ||
using Android.App; | ||
using Android.Runtime; | ||
|
||
namespace Material.Icons.Maui.Demo { | ||
[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
Material.Icons.Maui.Demo/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> |
8 changes: 8 additions & 0 deletions
8
Material.Icons.Maui.Demo/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,8 @@ | ||
using Foundation; | ||
|
||
namespace Material.Icons.Maui.Demo { | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate { | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Material.Icons.Maui.Demo/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> | ||
|
Oops, something went wrong.