-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Correctly re-apply font formatting to HTML text #14701
Conversation
Setting the text on iOS resets all formatting, so we need to re-apply size, color and other properties.
} | ||
|
||
public static void MapText(ILabelHandler handler, Label label) | ||
{ | ||
Platform.TextViewExtensions.UpdateText(handler.PlatformView, label); | ||
} | ||
|
||
// TODO: NET8 make this public | ||
internal static void MapTextColor(ILabelHandler handler, Label label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed as the new way of Platform.TextViewExtensions.UpdateText()
correctly handles span colors. There is no difference with either HTML of formatted text.
Platform.TextExtensions.UpdateText(handler.PlatformView, label); | ||
handler.UpdateValue(nameof(ILabel.Text)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling the same method, we should be triggering the Text property so people can properly intercept it.
|
||
MapFormatting(handler, label); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the real iOS fix that re-applied formatting.
static void MapFormatting(ILabelHandler handler, Label label) | ||
{ | ||
handler.UpdateValue(nameof(ILabel.TextColor)); | ||
handler.UpdateValue(nameof(ILabel.Font)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call the properties that need to be re-applied.
handler.PlatformView?.UpdateHorizontalTextAlignment(label); | ||
handler.UpdateValue(nameof(ILabel.HorizontalTextAlignment)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't just call the method, trigger the property so that the mappers can re-run.
Description of Change
Setting the text on iOS resets all formatting, so we need to re-apply size, color and other properties.
Issues Fixed
Fixes #12230
Fixes #11817