Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and Improvements for Base Icon Extension #89

Merged
merged 5 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# .Net Maui Icons

>The **.NET Maui Icons** is a comprehensive library collection that facilitates icon and font icon management within the .NET Maui framework. This library includes controls that seamlessly integrate three iconic design systems: Fluent, Material, and Cupertino. These controls offer complete access to the Material Icon Collection, delivering a rich and versatile iconography solution for .NET Maui applications.
>The **.NET Maui Icons** is a comprehensive library collection that facilitates icon and font icon management within the .NET Maui framework. This library includes controls that seamlessly integrate three iconic design systems: Fluent, Material, Cupertino and FontAwesome. These controls offer complete access to the mentioned Icon collections, delivering a rich and versatile iconography solution for .NET Maui applications.

Package | Latest stable | Latest Preview | Description
---------|---------------|---------------|------------
Expand All @@ -30,16 +30,16 @@ public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
var builder = MauiApp.CreateBuilder();

// Initialise the .Net Maui Icons - Fluent
builder.UseMauiApp<App>().UseFluentMauiIcons();
// Initialise the .Net Maui Icons - Material
builder.UseMauiApp<App>().UseMaterialMauiIcons();

// Initialise the .Net Maui Icons - Cupertino
builder.UseMauiApp<App>().UseCupertinoMauiIcons();
// Maui App Builder that Comes with Default Maui App
builder.UseMauiApp<App>()
// Initialises the .Net Maui Icons - Fluent
.UseFluentMauiIcons();
// Initialises the .Net Maui Icons - Material
.UseMaterialMauiIcons();
// Initialises the .Net Maui Icons - Cupertino
.UseCupertinoMauiIcons();
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<PropertyGroup Condition="'$(MSBuildProjectName)' != 'MauiIcons.Sample' and $(MSBuildProjectName) != 'MauiIcons.Modules.UnitTest'">
<Title>MauiIcons</Title>
<PackageIcon>icon.png</PackageIcon>
<AssemblyVersion>2.1.1.0</AssemblyVersion>
<AssemblyFileVersion>2.1.1.0</AssemblyFileVersion>
<Version>2.1.1</Version>
<AssemblyVersion>2.1.2.0</AssemblyVersion>
<AssemblyFileVersion>2.1.2.0</AssemblyFileVersion>
<Version>2.1.2</Version>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion>
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
Expand Down
18 changes: 14 additions & 4 deletions src/MauiIcons.Core/Extensions/BaseIconExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace MauiIcons.Core;

[ContentProperty(nameof(Icon))]
public abstract class BaseIconExtension<TEnum> : IMarkupExtension<object> where TEnum : Enum
public abstract class BaseIconExtension<TEnum> : IMarkupExtension where TEnum : Enum
{
#nullable enable
public TEnum? Icon { get; set; }
Expand All @@ -25,11 +25,11 @@ public abstract class BaseIconExtension<TEnum> : IMarkupExtension<object> where
const double DefaultIconSize = 30.0;
public object ProvideValue(IServiceProvider serviceProvider)
{
IProvideValueTarget provideValueTarget = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
Type returnType = (provideValueTarget.TargetProperty as BindableProperty)?.ReturnType;
var valueProvider = serviceProvider.GetService<IProvideValueTarget>() ?? throw new ArgumentException();
Type returnType = (valueProvider.TargetProperty as BindableProperty)?.ReturnType;

if (PlatformHelper.IsValidPlatformsAndIdioms(OnPlatforms, OnIdioms))
return AssignIconsBasedOnType(provideValueTarget.TargetObject, returnType);
return AssignIconsBasedOnType(valueProvider.TargetObject, returnType);

return null;
}
Expand All @@ -56,6 +56,9 @@ object AssignIconsBasedOnType(object targetObject, Type returnType)
throw new MauiIconsExpection("MauiIcons only supports ImageSource or FontImageSource in conjunction with OnPlatform and OnIdiom After Assigning TypeArgument." +
"it is recommended to utilize MauiIcon's integrated OnPlatform or OnIdiom functionalities for optimal compatibility.");

else if (returnType is null && targetObject is Setter)
throw new MauiIconsExpection("MauiIcons doesn't support style setter to be used in conjunction with xaml extension.");

throw new MauiIconsExpection($"MauiIcons extension does not provide {returnType} support");
}

Expand Down Expand Up @@ -112,6 +115,13 @@ string AssignFontProperties(object targetObject)
mauiIcon.IconSize = IconSize;
mauiIcon.IconAutoScaling = IconAutoScaling;
break;
case FontImageSource fontImageSource:
fontImageSource.Glyph = Icon.GetDescription();
fontImageSource.FontFamily = Icon.GetFontFamily();
fontImageSource.Size = IconSize;
fontImageSource.Color = IconColor;
fontImageSource.FontAutoScalingEnabled = IconAutoScaling;
break;
default:
throw new MauiIconsExpection($"MauiIcons extension doesn't support this control {targetObject}");
}
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Core/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Cupertino/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Fluent.Filled/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Fluent/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.FontAwesome.Brand/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.FontAwesome.Solid/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.FontAwesome/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Material.Outlined/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Material.Rounded/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Material.Sharp/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.Material/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down
2 changes: 1 addition & 1 deletion src/MauiIcons.Modules.UnitTest/Controls/MauiIconTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void CastingLabelSpacer()
// Assert
label.FormattedText.Should().NotBeNull();
label.FormattedText.Spans[1].Should().NotBeNull();
label.FormattedText.Spans[1].Text.Should().Be(" ");
label.FormattedText.Spans[1].Text.Should().Be("");
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion src/MauiIcons.SegoeFluent/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v2.1.1
v2.1.2
• Minor Fixes and Improvements for Base Extension

v2.1.1
• Minor Patch on Issue #83

v2.1.0
Expand Down