-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[iOS] Button CharacterSpacing Fix #20537
base: main
Are you sure you want to change the base?
Conversation
Hey there @kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
95005d7
to
789a8fd
Compare
@@ -33,6 +33,10 @@ private static void MapPadding(IButtonHandler handler, Button button) | |||
public static void MapText(IButtonHandler handler, Button button) | |||
{ | |||
handler.PlatformView?.UpdateText(button); | |||
|
|||
// Update all of the attributed text formatting properties |
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.
Firsr of all, thanks for the contributions.
In Controls and in Core, we are mapping the Text to a extension method. In Core, invoke the MapFormatting
method that update the AttributedTitle
taking into account the character spacing and the text color. Instead create a new method with a similar logic, everything should be in the same existing method in Core ButtonExtensions, here:
platformButton?.SetAttributedTitle(attributedText, UIControlState.Normal); |
This also will avoid the publicAPI small breaking changes.
I think, just need to set the font family and size there. The rest of changes, the test etc are fine.
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.
Thank you for this advice! I've refactored the code and hope it is what you want
@@ -151,6 +157,27 @@ static void SetControlPropertiesFromProxy(UIButton platformView) | |||
} | |||
} | |||
|
|||
internal static void UpdateAttributedTitle(IButtonHandler handler, ITextStyle textStyle) |
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.
Could we move this as an extension method in ButtonExtensions
?
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.
Sure, I just did it. I have one question though. This method needs fontManager
which currently is getting resolved by IButtonHandler
. Should I keep this line of code: var fontManager = handler.GetRequiredService<IFontManager>();
inside this new extension method or pass IFontManager
as a parameter to the UpdateAttributedTitle
method and call handler.GetRequiredService<IFontManager>();
before calling UpdateAttributedTitle
?
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.
Good question. We usually pass it as parameter. For example, here https://github.com/dotnet/maui/blob/85adc13a249fe4ac59da6518ea5dc70055ee569c/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs#L125C4-L125C65
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.
Changed in the last commit
d627114
to
bcf199e
Compare
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Let's wait until this PR is merged
#20953
Added pending test snapshot. |
/rebase |
71c0f08
to
4aad58f
Compare
@@ -83,5 +84,24 @@ public static void UpdatePadding(this UIButton platformButton, Thickness padding | |||
#pragma warning restore CA1422 // Validate platform compatibility | |||
#pragma warning restore CA1416 | |||
} | |||
|
|||
public static void UpdateAttributedTitle(this UIButton platformButton, IFontManager fontManager, ITextStyle textStyle) |
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.
Can you change this to internal?
4aad58f
to
1952c68
Compare
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.
(with gisted code here: https://gist.github.com/tj-devel709/34d29859c873925ac84e7f4556bff305)
This is looking great to me! I was wondering if we can add a font to the UITest as well? Just to catch if we mess up something in the future :)
I added a fontfamily and textcolor to your test but let me know if that is not wanted! |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
That's awesome! Thank you |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Based on the changes, there are several golden tests (comparing an snapshot) with small differences. Waiting the build to complete and review all of them. |
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
5cb04ca
to
c5a6de1
Compare
Rebased to main with the new UITest structure! |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Description of Change
The
AttributedTitle
property of the iOS's native button hasn't been always updated when needed.Issues Fixed
Fixes #18832
Fixes #21722
Before.mov
Fixed.mov