Skip to content

Commit 3da4444

Browse files
committed
Moved MapHtmlText to controls
1 parent 0537872 commit 3da4444

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/Controls/src/Core/Label/Label.Mapper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public partial class Label
4141
LabelHandler.Mapper.ModifyMapping<Label, ILabelHandler>(nameof(LineHeight), MapLineHeight);
4242
#endif
4343

44+
#if IOS
45+
LabelHandler.Mapper.AppendToMapping<Label, ILabelHandler>(nameof(ILabel.Font), MapHtmlText);
46+
#endif
47+
4448
// platform-specifics
4549
#if WINDOWS
4650
LabelHandler.Mapper.ReplaceMapping<Label, ILabelHandler>(PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName, MapDetectReadingOrderFromContent);

src/Controls/src/Core/Label/Label.iOS.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ public static void MapText(ILabelHandler handler, Label label)
2626
MapFormatting(handler, label);
2727
}
2828

29+
internal static void MapHtmlText(ILabelHandler handler, Label label)
30+
{
31+
if (handler.PlatformView?.AttributedText != null)
32+
{
33+
handler.PlatformView?.UpdateTextHtml(label);
34+
}
35+
}
36+
2937
public static void MapLineBreakMode(ILabelHandler handler, Label label)
3038
{
3139
handler.PlatformView?.UpdateLineBreakMode(label);

src/Core/src/Handlers/Label/LabelHandler.iOS.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public static void MapFont(ILabelHandler handler, ILabel label)
6363
var fontManager = handler.GetRequiredService<IFontManager>();
6464

6565
handler.PlatformView?.UpdateFont(label, fontManager);
66-
67-
if (handler.PlatformView?.AttributedText != null)
68-
handler.PlatformView?.UpdateTextHtml(label);
6966
}
7067

7168
public static void MapLineHeight(ILabelHandler handler, ILabel label)

src/Core/src/Platform/iOS/LabelExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ internal static void UpdateTextHtml(this UILabel platformLabel, ILabel label)
105105
{
106106
attributedString.AddAttribute(UIStringAttributeKey.Font, uiFontAttribute, range);
107107
}
108+
109+
if(label?.TextColor != null)
110+
{
111+
var color = label.TextColor.ToPlatform();
112+
attributedString.AddAttribute(UIStringAttributeKey.ForegroundColor, color, range);
113+
}
108114
});
109115

110116
platformLabel.AttributedText = attributedString;

0 commit comments

Comments
 (0)