Skip to content

Commit

Permalink
Merge pull request #102 from AathifMahir/vNext
Browse files Browse the repository at this point in the history
vNext with TFM Update and Fixes
  • Loading branch information
AathifMahir authored May 11, 2024
2 parents bf82f30 + 3b08cc7 commit e343fa9
Show file tree
Hide file tree
Showing 29 changed files with 215 additions and 347 deletions.
32 changes: 8 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ if you came across this issue dotnet/maui#7503 when using new namespace, Make su

```

## Breaking Changes from v2
## Breaking Changes

### Version 1 to 2

`Old (v1)`

Expand All @@ -91,6 +93,11 @@ xmlns:mi="http://www.aathifmahir.com/dotnet/2022/maui/icons"
<mi:MauiIcon Icon="{mi:Material ABC}"/>
```

### Version 2 to 3

- Removal of **TypeArgument** and Built in OnPlatform and OnIdiom Support, Use MauiIcons Integrated [Custom OnPlatform and OnIdioms Feature](#custom-onplatform-and-onidiom-usage)
- Removal of **Dotnet 7** Support

### Nuget Package Changes

- **`AathifMahir.Maui.MauiIcons.Material`** doesn't contain all the Variants anymore, Now only contains **Regular version** of Material Icons. Other Variants Decoupled into Seperate Packages Like Below
Expand Down Expand Up @@ -243,29 +250,6 @@ new MauiIcon().Icon(FluentIcons.Accounts).OnIdioms(new List<string>{"Desktop", "
new MauiIcon().Icon(MaterialIcons.ABC).OnPlatforms(new List<string>{"WinUI", "Android"}).OnIdioms(new List<string>{"Desktop", "Phone"});
```

## Maui Built in OnPlatform and OnIdiom Usage

```xml
<Image>
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource" Default="{mi:FluentFilled Icon=Airplane20Filled, TypeArgument={x:Type ImageSource}}">
<On Platform="MacCatalyst, WinUI"
Value="{mi:Cupertino Icon=Airplane, IconBackgroundColor=Cyan, TypeArgument={x:Type ImageSource}}"/>
</OnPlatform>
</Image.Source>
</Image>

<Image>
<Image.Source>
<OnIdiom Default="{mi:FluentFilled Icon=Airplane20Filled, TypeArgument={x:Type ImageSource}}"
Desktop="{mi:FluentFilled Icon=Airplane20Filled, TypeArgument={x:Type ImageSource}}">
</OnIdiom>
</Image.Source>
</Image>

```
**Disclaimer:** Only **ImageSource** or **FontImageSource** Supports Maui's Built in OnPlatform or OnIdiom and **TypeArgument** Should be Assigned to Work Optimally, Therefore It's Recommended to use MauiIcons Custom OnPlatform and OnIdioms

# Properties

| Parameters | Type | Description |
Expand Down
15 changes: 2 additions & 13 deletions samples/MauiIcons.Sample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,8 @@
</HorizontalStackLayout>

<HorizontalStackLayout HorizontalOptions="Center" Spacing="20">
<Image BackgroundColor="Red">
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource" Default="{mi:FluentFilled Icon=Airplane20Filled, TypeArgument={x:Type ImageSource}}">
<On Platform="MacCatalyst, WinUI" Value="{mi:Cupertino Icon=Airplane, IconBackgroundColor=Cyan, TypeArgument={x:Type ImageSource}}" />
</OnPlatform>
</Image.Source>
</Image>

<Image BackgroundColor="Red">
<Image.Source>
<OnIdiom Default="{mi:FluentFilled Icon=Airplane20Filled, TypeArgument={x:Type ImageSource}}" Desktop="{mi:FluentFilled Icon=Airplane20Filled, TypeArgument={x:Type ImageSource}}" />
</Image.Source>
</Image>
<Image BackgroundColor="Red" Source="{mi:FluentFilled Icon=ZoomIn24Filled, OnPlatforms='MacCatalyst, Android, WinUI'}" />
<Image BackgroundColor="Red" Source="{mi:FluentFilled Icon=Airplane20Filled, OnIdioms='Desktop, Mobile'}" />
</HorizontalStackLayout>

<HorizontalStackLayout HorizontalOptions="Center" Spacing="10">
Expand Down
14 changes: 9 additions & 5 deletions samples/MauiIcons.Sample/MauiIcons.Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0;net7.0-windows10.0.19041.0</TargetFrameworks>
<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);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
Expand All @@ -14,15 +14,15 @@
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>

<!-- Display name -->
<ApplicationTitle>MauiIcons.Sample</ApplicationTitle>
<ApplicationTitle>MauiIcons Gallery</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.mauiicons.sample</ApplicationId>
<ApplicationIdGuid>32B5B7F1-9EC0-44BE-ACAE-9AC11F0EEC47</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.2</ApplicationDisplayVersion>
<ApplicationVersion>3</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
Expand All @@ -32,6 +32,10 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net8'))">
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
Expand Down
10 changes: 5 additions & 5 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectName)' != 'MauiIcons.Sample' and $(MSBuildProjectName) != 'MauiIcons.Modules.UnitTest'">
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0;net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0;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);net6.0-tizen</TargetFrameworks> -->

Expand All @@ -29,9 +29,9 @@
<PropertyGroup Condition="'$(MSBuildProjectName)' != 'MauiIcons.Sample' and $(MSBuildProjectName) != 'MauiIcons.Modules.UnitTest'">
<Title>MauiIcons</Title>
<PackageIcon>icon.png</PackageIcon>
<AssemblyVersion>2.2.5.0</AssemblyVersion>
<AssemblyFileVersion>2.2.5.0</AssemblyFileVersion>
<Version>2.2.5</Version>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyFileVersion>3.0.0.0</AssemblyFileVersion>
<Version>3.0.0</Version>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion>
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
Expand Down
52 changes: 30 additions & 22 deletions src/MauiIcons.Core/Extensions/BaseIconExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace MauiIcons.Core;

[ContentProperty(nameof(Icon))]
public abstract class BaseIconExtension<TEnum> : BindableObject, IMarkupExtension where TEnum : Enum
public abstract class BaseIconExtension<TEnum> : BindableObject, IMarkupExtension<BindingBase> where TEnum : Enum
{
public static readonly BindableProperty IconProperty = BindableProperty.Create(nameof(Icon), typeof(TEnum?), typeof(BaseIconExtension<TEnum>), null);
public static readonly BindableProperty IconSizeProperty = BindableProperty.Create(nameof(IconSize), typeof(double), typeof(BaseIconExtension<TEnum>), 30.0);
Expand Down Expand Up @@ -52,9 +52,7 @@ public bool IconAutoScaling
[System.ComponentModel.TypeConverter(typeof(ListStringTypeConverter))]
public IList<string> OnIdioms { get; set; } = new List<string>();

public Type? TypeArgument { get; set; }

public object ProvideValue(IServiceProvider serviceProvider)
public BindingBase ProvideValue(IServiceProvider serviceProvider)
{
var valueProvider = serviceProvider.GetService<IProvideValueTarget>() ?? throw new ArgumentException();
Type? returnType = (valueProvider.TargetProperty as BindableProperty)?.ReturnType;
Expand All @@ -65,7 +63,10 @@ public object ProvideValue(IServiceProvider serviceProvider)
return new Binding();
}

object SetMauiIconBasedOnType(object targetObject, Type? returnType)
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) =>
(this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);

Binding SetMauiIconBasedOnType(object targetObject, Type? returnType)
{
if(returnType == typeof(Enum))
return SetFontProperties(targetObject, disableConverter: true);
Expand All @@ -79,17 +80,14 @@ object SetMauiIconBasedOnType(object targetObject, Type? returnType)
if (returnType is null && (targetObject is On or OnPlatform<ImageSource>
or OnPlatform<FontImageSource> or OnPlatformExtension
or OnIdiom<ImageSource> or OnIdiom<FontImageSource>
or OnIdiomExtension) && (TypeArgument == typeof(ImageSource) || TypeArgument == typeof(FontImageSource)))
return SetImageSourceProperties();

else if (returnType is null && targetObject is On && (TypeArgument is null || TypeArgument != typeof(ImageSource) || TypeArgument != typeof(FontImageSource)))
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.");
or OnIdiomExtension))
throw new MauiIconsExpection("MauiIcons doesn't support Maui OnPlatform or OnIdiom," +
"Therefore it is recommended to utilize MauiIcon's integrated Custom OnPlatform or OnIdiom functionalities.");

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 doesn't support Style Setter to be used in conjunction with Xaml Extension.");

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

Binding SetFontProperties(object targetObject, bool disableConverter = false)
Expand Down Expand Up @@ -170,18 +168,28 @@ Binding SetFontProperties(object targetObject, bool disableConverter = false)
}
return new Binding(nameof(Icon), mode: BindingMode.OneWay, converter: !disableConverter ? new EnumToStringConverter() : null, source: this);
}
FontImageSource SetImageSourceProperties()

Binding SetImageSourceProperties()
{
var fontImageSource = new FontImageSource();
fontImageSource.SetBinding(FontImageSource.GlyphProperty, new Binding(nameof(Icon), mode: BindingMode.OneWay, converter: new EnumToStringConverter(), source: this));
fontImageSource.FontFamily = Icon.GetFontFamily();
fontImageSource.SetBinding(FontImageSource.SizeProperty, new Binding(nameof(IconSize), source: this, mode: BindingMode.OneWay));
fontImageSource.SetBinding(FontImageSource.ColorProperty, new Binding(nameof(IconColor), source: this, mode: BindingMode.OneWay,
converter: new DefaultColorConverter(), converterParameter: fontImageSource.Color));
fontImageSource.SetBinding(FontImageSource.FontAutoScalingEnabledProperty, new Binding(nameof(IconAutoScaling), source: this, mode: BindingMode.OneWay));
return fontImageSource;
InternalSource = new FontImageSource();
((FontImageSource)InternalSource).SetBinding(FontImageSource.GlyphProperty, new Binding(nameof(Icon), mode: BindingMode.OneWay, converter: new EnumToStringConverter(), source: this));
((FontImageSource)InternalSource).FontFamily = Icon.GetFontFamily();
((FontImageSource)InternalSource).SetBinding(FontImageSource.SizeProperty, new Binding(nameof(IconSize), source: this));
((FontImageSource)InternalSource).SetBinding(FontImageSource.ColorProperty, new Binding(nameof(IconColor), source: this,
converter: new DefaultColorConverter(), converterParameter: ((FontImageSource)InternalSource).Color));
((FontImageSource)InternalSource).SetBinding(FontImageSource.FontAutoScalingEnabledProperty, new Binding(nameof(IconAutoScaling), source: this));
return new Binding(nameof(InternalSource), mode: BindingMode.OneWay, source: this);
}

public static readonly BindableProperty InternalSourceProperty = BindableProperty.Create(nameof(InternalSource), typeof(ImageSource), typeof(BaseIconExtension<TEnum>), null);

/// <summary>
/// This is Used Internally, Don't Use it in XAML or CodeBehind
/// </summary>
public ImageSource InternalSource
{
get => (ImageSource)GetValue(InternalSourceProperty);
set => SetValue(InternalSourceProperty, value);
}

}
7 changes: 6 additions & 1 deletion src/MauiIcons.Core/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
v2.2.5
v3.0.0
• Critical Fixes for Xaml Markup Binding Support
• Breaking Changes: Removal of Dotnet 7 Support
• Breaking Changes: Removal of Maui OnPlatform and OnIdioms Support Instead Use MauiIcons Integrated Custom OnPlatforms and OnIdioms Feature

v2.2.5
• New and Improved Xaml Markup Extension with Binding Support

v2.1.5
Expand Down
7 changes: 6 additions & 1 deletion src/MauiIcons.Cupertino/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
v2.2.5
v3.0.0
• Critical Fixes for Xaml Markup Binding Support
• Breaking Changes: Removal of Dotnet 7 Support
• Breaking Changes: Removal of Maui OnPlatform and OnIdioms Support Instead Use MauiIcons Integrated Custom OnPlatforms and OnIdioms Feature

v2.2.5
• New and Improved Xaml Markup Extension with Binding Support

v2.1.5
Expand Down
32 changes: 8 additions & 24 deletions src/MauiIcons.Cupertino/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ if you came across this issue dotnet/maui#7503 when using new namespace, Make su

```

## Breaking Changes from v2
## Breaking Changes

### Version 1 to 2

`Old (v1)`

Expand All @@ -70,6 +72,11 @@ xmlns:mi="http://www.aathifmahir.com/dotnet/2022/maui/icons"
<mi:MauiIcon Icon="{mi:Cupertino Airplane}"/>
```

### Version 2 to 3

- Removal of **TypeArgument** and Built in OnPlatform and OnIdiom Support, Use MauiIcons Integrated [Custom OnPlatform and OnIdioms Feature](#custom-onplatform-and-onidiom-usage)
- Removal of **Dotnet 7** Support

## Built in Control Usage

`Xaml`
Expand Down Expand Up @@ -161,29 +168,6 @@ new MauiIcon().Icon(CupertinoIcons.Airplane).OnIdioms(new List<string>{"Desktop"
new MauiIcon().Icon(CupertinoIcons.AntFill).OnPlatforms(new List<string>{"WinUI", "Android"}).OnIdioms(new List<string>{"Desktop", "Phone"});
```

## Maui Built in OnPlatform and OnIdiom Usage

```xml
<Image>
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource" Default="{mi:Cupertino Icon=Airplane, TypeArgument={x:Type ImageSource}}">
<On Platform="MacCatalyst, WinUI"
Value="{mi:Cupertino Icon=AntFill, IconBackgroundColor=Cyan, TypeArgument={x:Type ImageSource}}"/>
</OnPlatform>
</Image.Source>
</Image>

<Image>
<Image.Source>
<OnIdiom Default="{mi:Cupertino Icon=AntFill, TypeArgument={x:Type ImageSource}}"
Desktop="{mi:Cupertino Icon=Airplane, TypeArgument={x:Type ImageSource}}">
</OnIdiom>
</Image.Source>
</Image>

```
**Disclaimer:** Only **ImageSource** or **FontImageSource** Supports Maui's Built in OnPlatform or OnIdiom and **TypeArgument** Should be Assigned to Work Optimally, Therefore It's Recommended to use MauiIcons Custom OnPlatform and OnIdioms

# License

**MauiIcons.Cupertino**
Expand Down
7 changes: 6 additions & 1 deletion src/MauiIcons.Fluent.Filled/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
v2.2.5
v3.0.0
• Critical Fixes for Xaml Markup Binding Support
• Breaking Changes: Removal of Dotnet 7 Support
• Breaking Changes: Removal of Maui OnPlatform and OnIdioms Support Instead Use MauiIcons Integrated Custom OnPlatforms and OnIdioms Feature

v2.2.5
• New and Improved Xaml Markup Extension with Binding Support

v2.1.5
Expand Down
34 changes: 9 additions & 25 deletions src/MauiIcons.Fluent.Filled/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ if you came across this issue dotnet/maui#7503 when using new namespace, Make su

```

## Breaking Changes from v2
## Breaking Changes

### Version 1 to 2

`Old (v1)`

```xml
xmlns:fluentFilled="clr-namespace:MauiIcons.FluentFilled;assembly=MauiIcons.FluentFilled"
xmlns:fluentFilled="clr-namespace:MauiIcons.Fluent.Filled;assembly=MauiIcons.Fluent.Filled"

<fluentFilled:MauiIcon Icon="AppFolder48Filled"/>
```
Expand All @@ -70,6 +72,11 @@ xmlns:mi="http://www.aathifmahir.com/dotnet/2022/maui/icons"
<mi:MauiIcon Icon="{mi:FluentFilled AppFolder48Filled}"/>
```

### Version 2 to 3

- Removal of **TypeArgument** and Built in OnPlatform and OnIdiom Support, Use MauiIcons Integrated [Custom OnPlatform and OnIdioms Feature](#custom-onplatform-and-onidiom-usage)
- Removal of **Dotnet 7** Support

### Nuget Package Changes

- **`AathifMahir.Maui.MauiIcons.FluentFilled`** is Depcrecated and Replaced by [`AathifMahir.Maui.MauiIcons.Fluent.Filled`](https://www.nuget.org/packages/AathifMahir.Maui.MauiIcons.Fluent.Filled/)
Expand Down Expand Up @@ -165,29 +172,6 @@ new MauiIcon().Icon(FluentFilledIcons.Accessibility48Filled).OnIdioms(new List<s
new MauiIcon().Icon(FluentFilledIcons.AppFolder48Filled).OnPlatforms(new List<string>{"WinUI", "Android"}).OnIdioms(new List<string>{"Desktop", "Phone"});
```

## Maui Built in OnPlatform and OnIdiom Usage

```xml
<Image>
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource" Default="{mi:FluentFilled Icon=Accessibility48Filled, TypeArgument={x:Type ImageSource}}">
<On Platform="MacCatalyst, WinUI"
Value="{mi:FluentFilled Icon=AppFolder48Filled, IconBackgroundColor=Cyan, TypeArgument={x:Type ImageSource}}"/>
</OnPlatform>
</Image.Source>
</Image>

<Image>
<Image.Source>
<OnIdiom Default="{mi:FluentFilled Icon=AppFolder48Filled, TypeArgument={x:Type ImageSource}}"
Desktop="{mi:FluentFilled Icon=Accessibility48Filled, TypeArgument={x:Type ImageSource}}">
</OnIdiom>
</Image.Source>
</Image>

```
**Disclaimer:** Only **ImageSource** or **FontImageSource** Supports Maui's Built in OnPlatform or OnIdiom and **TypeArgument** Should be Assigned to Work Optimally, Therefore It's Recommended to use MauiIcons Custom OnPlatform and OnIdioms

# License

**MauiIcons.Fluent.Filled**
Expand Down
7 changes: 6 additions & 1 deletion src/MauiIcons.Fluent/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
v2.2.5
v3.0.0
• Critical Fixes for Xaml Markup Binding Support
• Breaking Changes: Removal of Dotnet 7 Support
• Breaking Changes: Removal of Maui OnPlatform and OnIdioms Support Instead Use MauiIcons Integrated Custom OnPlatforms and OnIdioms Feature

v2.2.5
• New and Improved Xaml Markup Extension with Binding Support

v2.1.5
Expand Down
Loading

0 comments on commit e343fa9

Please sign in to comment.