Skip to content

Commit

Permalink
Skip some mappings when using formatted text (#4174)
Browse files Browse the repository at this point in the history
On iOS, we have more mappings registered and they fire _after_ the mapper that fires for FormattedText.  Since these other ones also set the AttributedString on the platform control, they override what was in FormattedText.

This changes it so they do not, and FormattedText always takes priority.
  • Loading branch information
Redth authored Jan 18, 2022
1 parent cd8ee6c commit b7437d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Label/Label.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public static void MapText(LabelHandler handler, Label label)

public static void MapTextDecorations(LabelHandler handler, Label label)
{
if (label?.HasFormattedTextSpans ?? false)
return;

if (label?.TextType == TextType.Html)
{
return;
Expand All @@ -26,6 +29,9 @@ public static void MapTextDecorations(LabelHandler handler, Label label)

public static void MapCharacterSpacing(LabelHandler handler, Label label)
{
if (label?.HasFormattedTextSpans ?? false)
return;

if (label?.TextType == TextType.Html)
{
return;
Expand All @@ -36,6 +42,9 @@ public static void MapCharacterSpacing(LabelHandler handler, Label label)

public static void MapLineHeight(LabelHandler handler, Label label)
{
if (label?.HasFormattedTextSpans ?? false)
return;

if (label?.TextType == TextType.Html)
{
return;
Expand All @@ -46,6 +55,9 @@ public static void MapLineHeight(LabelHandler handler, Label label)

public static void MapFont(LabelHandler handler, Label label)
{
if (label?.HasFormattedTextSpans ?? false)
return;

if (label?.TextType == TextType.Html)
{
return;
Expand All @@ -56,6 +68,9 @@ public static void MapFont(LabelHandler handler, Label label)

public static void MapTextColor(LabelHandler handler, Label label)
{
if (label?.HasFormattedTextSpans ?? false)
return;

if (label?.TextType == TextType.Html)
{
return;
Expand Down
2 changes: 2 additions & 0 deletions src/Controls/src/Core/Label.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ void ITextElement.OnCharacterSpacingPropertyChanged(double oldValue, double newV
InvalidateMeasure();
}

internal bool HasFormattedTextSpans
=> (FormattedText?.Spans?.Count ?? 0) > 0;

public override IList<GestureElement> GetChildElements(Point point)
{
Expand Down

0 comments on commit b7437d4

Please sign in to comment.