Skip to content

Commit

Permalink
Offload Uno assets to dedicated package
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxuang committed Oct 28, 2024
1 parent 32ca309 commit 097ea87
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 55 deletions.
31 changes: 31 additions & 0 deletions FluentIcons.Uno/FluentIcons.Uno.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>FluentUI System Icons assets package for Uno.</Description>
<TargetsForTfmSpecificContentInPackage>
$(TargetsForTfmSpecificContentInPackage);IncludeAssetsInNuGetPackage
</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\FluentIcons.Common\FluentIcons.Common.csproj" ExactVersion="true" />
</ItemGroup>

<Target Name="IncludeAssetsInNuGetPackage" Condition="'$(IncludeBuildOutput)' != 'false'" DependsOnTargets="GetNuGetShortFolderName">
<ItemGroup>
<TfmSpecificPackageFile Include="../seagull-icons/assets/FluentSystemIcons.ttf">
<Link>Assets/FluentSystemIcons.ttf</Link>
<PackagePath>lib/$(NuGetShortFolderName)/$(PackageId)/%(Link)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="../seagull-icons/assets/SeagullFluentIcons.ttf">
<Link>Assets/SeagullFluentIcons.ttf</Link>
<PackagePath>lib/$(NuGetShortFolderName)/$(PackageId)/%(Link)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="FluentIcons.Uno.uprimarker">
<PackagePath>lib/$(NuGetShortFolderName)/</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>

</Project>
File renamed without changes.
2 changes: 1 addition & 1 deletion FluentIcons.Uwp/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class Extensions
{
public static Application UseSegoeMetrics(this Application app)
{
#if !NET || WINDOWS
#if !HAS_UNO
SymbolIcon.UseSegoeMetricsDefaultValue = true;
#else
SymbolIcon.UseSegoeMetricsProperty.GetMetadata(typeof(SymbolIcon)).DefaultValue = true;
Expand Down
18 changes: 4 additions & 14 deletions FluentIcons.Uwp/FluentIcons.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<InternalsAssemblyName Include="Uno.UI" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FluentIcons.Uno\FluentIcons.Uno.csproj" ExactVersion="true" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="IgnoresAccessChecksToGenerator" PrivateAssets="All" />
<PackageReference Include="Uno.UI" />
Expand Down Expand Up @@ -59,19 +63,5 @@
<BuildAction>Content</BuildAction>
</TfmSpecificPackageFile>
</ItemGroup>

<ItemGroup Condition="!$(TargetFramework.StartsWith('uap'))">
<TfmSpecificPackageFile Include="../seagull-icons/assets/FluentSystemIcons.ttf">
<Link>Assets/FluentSystemIcons.ttf</Link>
<PackagePath>lib/$(NuGetShortFolderName)/$(PackageId)/%(Link)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="../seagull-icons/assets/SeagullFluentIcons.ttf">
<Link>Assets/SeagullFluentIcons.ttf</Link>
<PackagePath>lib/$(NuGetShortFolderName)/$(PackageId)/%(Link)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="FluentIcons.Uwp.uprimarker">
<PackagePath>lib/$(NuGetShortFolderName)/</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
</Project>
23 changes: 14 additions & 9 deletions FluentIcons.Uwp/SymbolIcon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;
using FluentIcons.Common;
using FluentIcons.Common.Internals;
Expand All @@ -14,9 +13,15 @@ namespace FluentIcons.Uwp;

public partial class SymbolIcon : FontIcon
{
internal static readonly FontFamily System = new("ms-appx:///FluentIcons.Uwp/Assets/FluentSystemIcons.ttf#Fluent System Icons");
internal static readonly FontFamily Seagull = new("ms-appx:///FluentIcons.Uwp/Assets/SeagullFluentIcons.ttf#Seagull Fluent Icons");
#if !NET || WINDOWS
private const string AssetsNamespace =
#if !HAS_UNO
"FluentIcons.Uwp";
#else
"FluentIcons.Uno";
#endif
internal static readonly FontFamily System = new($"ms-appx:///{AssetsNamespace}/Assets/FluentSystemIcons.ttf#Fluent System Icons");
internal static readonly FontFamily Seagull = new($"ms-appx:///{AssetsNamespace}/Assets/SeagullFluentIcons.ttf#Seagull Fluent Icons");
#if !HAS_UNO
internal static bool UseSegoeMetricsDefaultValue = false;
#endif

Expand All @@ -25,7 +30,7 @@ public partial class SymbolIcon : FontIcon
public static DependencyProperty IconVariantProperty { get; } =
DependencyProperty.Register(nameof(IconVariant), typeof(IconVariant), typeof(SymbolIcon), new PropertyMetadata(default(IconVariant), OnSymbolPropertiesChanged));
public static DependencyProperty UseSegoeMetricsProperty { get; } =
#if !NET || WINDOWS
#if !HAS_UNO
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), PropertyMetadata.Create(() => UseSegoeMetricsDefaultValue, OnSymbolPropertiesChanged));
#else
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), new PropertyMetadata(false, OnSymbolPropertiesChanged));
Expand All @@ -50,7 +55,7 @@ public SymbolIcon()
RegisterPropertyChangedCallback(MirroredWhenRightToLeftProperty, OnMirroredWhenRightToLeftChanged);
}

#if UAP10_0_17763_0
#if !HAS_UNO
internal SymbolIcon(bool bindFlowDirection) : this()
{
if (!bindFlowDirection)
Expand Down Expand Up @@ -163,14 +168,14 @@ public class SymbolIconExtension : MarkupExtension
public double? FontSize { get; set; }
public Brush? Foreground { get; set; }

#if UAP10_0_17763_0
#if !HAS_UNO
protected override object ProvideValue()
#else
protected override object ProvideValue(IXamlServiceProvider serviceProvider)
#endif
{
var icon = new SymbolIcon(
#if UAP10_0_17763_0
#if !HAS_UNO
true
#endif
);
Expand All @@ -181,7 +186,7 @@ protected override object ProvideValue(IXamlServiceProvider serviceProvider)
if (FontSize.HasValue) icon.FontSize = FontSize.Value;
if (Foreground is not null) icon.Foreground = Foreground;

#if !UAP10_0_17763_0
#if HAS_UNO
var service = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
if (service?.TargetObject is FrameworkElement source)
{
Expand Down
9 changes: 4 additions & 5 deletions FluentIcons.Uwp/SymbolIconSource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using FluentIcons.Common;
using FluentIcons.Common.Internals;
using Windows.UI.Text;
Expand All @@ -17,7 +16,7 @@ public partial class SymbolIconSource : FontIconSource
public static DependencyProperty IconVariantProperty { get; } =
DependencyProperty.Register(nameof(IconVariant), typeof(IconVariant), typeof(SymbolIcon), new PropertyMetadata(default(IconVariant), OnSymbolPropertiesChanged));
public static DependencyProperty UseSegoeMetricsProperty { get; } =
#if WINDOWS
#if !HAS_UNO
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), PropertyMetadata.Create(() => SymbolIcon.UseSegoeMetricsDefaultValue, OnSymbolPropertiesChanged));
#else
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), new PropertyMetadata(false, OnSymbolPropertiesChanged));
Expand Down Expand Up @@ -132,13 +131,13 @@ public class SymbolIconSourceExtension : MarkupExtension
public Symbol? Symbol { get; set; }
public IconVariant? IconVariant { get; set; }
public bool? UseSegoeMetrics { get; set; }
#if UAP10_0_17763_0
#if !HAS_UNO
public FlowDirection? FlowDirection { get; set; }
#endif
public double? FontSize { get; set; }
public Brush? Foreground { get; set; }

#if UAP10_0_17763_0
#if !HAS_UNO
protected override object ProvideValue()
#else
protected override object ProvideValue(IXamlServiceProvider serviceProvider)
Expand All @@ -152,7 +151,7 @@ protected override object ProvideValue(IXamlServiceProvider serviceProvider)
if (FontSize.HasValue) icon.FontSize = FontSize.Value;
if (Foreground is not null) icon.Foreground = Foreground;

#if UAP10_0_17763_0
#if !HAS_UNO
if (FlowDirection.HasValue) icon.FlowDirection = FlowDirection.Value;
#else
var service = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
Expand Down
4 changes: 2 additions & 2 deletions FluentIcons.WinUI/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class Extensions
{
public static Application UseSegoeMetrics(this Application app)
{
#if !NET || WINDOWS
#if !HAS_UNO
SymbolIcon.UseSegoeMetricsDefaultValue = true;
#else
SymbolIcon.UseSegoeMetricsProperty.GetMetadata(typeof(SymbolIcon)).DefaultValue = true;
Expand All @@ -18,7 +18,7 @@ public static Application UseSegoeMetrics(this Application app)

public static IHostBuilder UseSegoeMetrics(this IHostBuilder builder)
{
#if !NET || WINDOWS
#if !HAS_UNO
SymbolIcon.UseSegoeMetricsDefaultValue = true;
#else
SymbolIcon.UseSegoeMetricsProperty.GetMetadata(typeof(SymbolIcon)).DefaultValue = true;
Expand Down
18 changes: 4 additions & 14 deletions FluentIcons.WinUI/FluentIcons.WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<InternalsAssemblyName Include="Uno.UI" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FluentIcons.Uno\FluentIcons.Uno.csproj" ExactVersion="true" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="IgnoresAccessChecksToGenerator" PrivateAssets="All" />
<PackageReference Include="Uno.WinUI" />
Expand All @@ -54,19 +58,5 @@
<BuildAction>Content</BuildAction>
</TfmSpecificPackageFile>
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
<TfmSpecificPackageFile Include="../seagull-icons/assets/FluentSystemIcons.ttf">
<Link>Assets/FluentSystemIcons.ttf</Link>
<PackagePath>lib/$(NuGetShortFolderName)/$(PackageId)/%(Link)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="../seagull-icons/assets/SeagullFluentIcons.ttf">
<Link>Assets/SeagullFluentIcons.ttf</Link>
<PackagePath>lib/$(NuGetShortFolderName)/$(PackageId)/%(Link)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="FluentIcons.WinUI.uprimarker">
<PackagePath>lib/$(NuGetShortFolderName)/</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
</Project>
2 changes: 0 additions & 2 deletions FluentIcons.WinUI/FluentIcons.WinUI.uprimarker

This file was deleted.

15 changes: 10 additions & 5 deletions FluentIcons.WinUI/SymbolIcon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;
using FluentIcons.Common;
using FluentIcons.Common.Internals;
Expand All @@ -14,9 +13,15 @@ namespace FluentIcons.WinUI;

public partial class SymbolIcon : FontIcon
{
internal static readonly FontFamily System = new("ms-appx:///FluentIcons.WinUI/Assets/FluentSystemIcons.ttf#Fluent System Icons");
internal static readonly FontFamily Seagull = new("ms-appx:///FluentIcons.WinUI/Assets/SeagullFluentIcons.ttf#Seagull Fluent Icons");
#if !NET || WINDOWS
private const string AssetsNamespace =
#if !HAS_UNO
"FluentIcons.WinUI";
#else
"FluentIcons.Uno";
#endif
internal static readonly FontFamily System = new($"ms-appx:///{AssetsNamespace}/Assets/FluentSystemIcons.ttf#Fluent System Icons");
internal static readonly FontFamily Seagull = new($"ms-appx:///{AssetsNamespace}/Assets/SeagullFluentIcons.ttf#Seagull Fluent Icons");
#if !HAS_UNO
internal static bool UseSegoeMetricsDefaultValue = false;
#endif

Expand All @@ -25,7 +30,7 @@ public partial class SymbolIcon : FontIcon
public static DependencyProperty IconVariantProperty { get; } =
DependencyProperty.Register(nameof(IconVariant), typeof(IconVariant), typeof(SymbolIcon), new PropertyMetadata(default(IconVariant), OnSymbolPropertiesChanged));
public static DependencyProperty UseSegoeMetricsProperty { get; } =
#if !NET || WINDOWS
#if !HAS_UNO
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), PropertyMetadata.Create(() => UseSegoeMetricsDefaultValue, OnSymbolPropertiesChanged));
#else
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), new PropertyMetadata(false, OnSymbolPropertiesChanged));
Expand Down
3 changes: 1 addition & 2 deletions FluentIcons.WinUI/SymbolIconSource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using FluentIcons.Common;
using FluentIcons.Common.Internals;
using Microsoft.UI.Text;
Expand All @@ -17,7 +16,7 @@ public partial class SymbolIconSource : FontIconSource
public static DependencyProperty IconVariantProperty { get; } =
DependencyProperty.Register(nameof(IconVariant), typeof(IconVariant), typeof(SymbolIcon), new PropertyMetadata(default(IconVariant), OnSymbolPropertiesChanged));
public static DependencyProperty UseSegoeMetricsProperty { get; } =
#if WINDOWS
#if !HAS_UNO
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), PropertyMetadata.Create(() => SymbolIcon.UseSegoeMetricsDefaultValue, OnSymbolPropertiesChanged));
#else
DependencyProperty.Register(nameof(UseSegoeMetrics), typeof(bool), typeof(SymbolIcon), new PropertyMetadata(false, OnSymbolPropertiesChanged));
Expand Down
6 changes: 6 additions & 0 deletions FluentIcons.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentIcons.Avalonia.Fluent
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentIcons.Maui", "FluentIcons.Maui\FluentIcons.Maui.csproj", "{0147C878-92EA-4F88-B5EF-8B1A63C9C462}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentIcons.Uno", "FluentIcons.Uno\FluentIcons.Uno.csproj", "{165238B5-7446-4D7F-8C97-705BA7305BEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentIcons.Uwp", "FluentIcons.Uwp\FluentIcons.Uwp.csproj", "{E1112BAC-EDEA-4303-A9C3-2CC9DA33EDED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentIcons.WinUI", "FluentIcons.WinUI\FluentIcons.WinUI.csproj", "{BCA0EB9E-A440-4294-9241-1CF2A1B3889E}"
Expand Down Expand Up @@ -47,6 +49,10 @@ Global
{0147C878-92EA-4F88-B5EF-8B1A63C9C462}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0147C878-92EA-4F88-B5EF-8B1A63C9C462}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0147C878-92EA-4F88-B5EF-8B1A63C9C462}.Release|Any CPU.Build.0 = Release|Any CPU
{165238B5-7446-4D7F-8C97-705BA7305BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{165238B5-7446-4D7F-8C97-705BA7305BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{165238B5-7446-4D7F-8C97-705BA7305BEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{165238B5-7446-4D7F-8C97-705BA7305BEE}.Release|Any CPU.Build.0 = Release|Any CPU
{E1112BAC-EDEA-4303-A9C3-2CC9DA33EDED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1112BAC-EDEA-4303-A9C3-2CC9DA33EDED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1112BAC-EDEA-4303-A9C3-2CC9DA33EDED}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ A multi-framework control library of [fluentui-system-icons](https://github.com/

| Package | Platform |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![FluentIcons.Common](https://img.shields.io/nuget/v/FluentIcons.Common?label=FluentIcons.Common)](https://www.nuget.org/packages/FluentIcons.Common) | |
| [![FluentIcons.Common](https://img.shields.io/nuget/v/FluentIcons.Common?label=FluentIcons.Common)](https://www.nuget.org/packages/FluentIcons.Common) | _meta package_ |
| [![FluentIcons.Uno](https://img.shields.io/nuget/v/FluentIcons.Uno?label=FluentIcons.Uno)](https://www.nuget.org/packages/FluentIcons.Uno) | _meta package_ |
| [![FluentIcons.Avalonia](https://img.shields.io/nuget/v/FluentIcons.Avalonia?label=FluentIcons.Avalonia)](https://www.nuget.org/packages/FluentIcons.Avalonia) | [![](https://cdn.jsdelivr.net/gh/davidxuang/FluentIcons@static/assets/avalonia.svg) Avalonia 11](https://www.nuget.org/packages/Avalonia/11.0.0) |
| [![FluentIcons.Avalonia.Fluent](https://img.shields.io/nuget/v/FluentIcons.Avalonia.Fluent?label=FluentIcons.Avalonia.Fluent)](https://www.nuget.org/packages/FluentIcons.Avalonia.Fluent) | [![](https://cdn.jsdelivr.net/gh/davidxuang/FluentIcons@static/assets/avalonia-fluent.svg) FluentAvalonia 2](https://www.nuget.org/packages/FluentAvaloniaUI/2.0.0) (Avalonia 11) |
| [![FluentIcons.Maui](https://img.shields.io/nuget/v/FluentIcons.Maui?label=FluentIcons.Maui)](https://www.nuget.org/packages/FluentIcons.Maui) | [![](https://cdn.jsdelivr.net/gh/davidxuang/FluentIcons@static/assets/maui.svg) MAUI 8](https://www.nuget.org/packages/Microsoft.Maui.Sdk/8.0.3) |
Expand Down

0 comments on commit 097ea87

Please sign in to comment.