-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
@@ -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. |
5cb04ca
to
c5a6de1
Compare
Rebased to main with the new UITest structure! |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
{ | ||
// Any text update requires that we update any attributed string formatting | ||
var uiFontAttribute = fontManager.GetFont(textStyle.Font, UIFont.ButtonFontSize); | ||
var attributedString = new NSMutableAttributedString(new NSAttributedString(platformButton.CurrentTitle!)); |
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.
Looks like there may some situations where this platformButton.CurrentTitle! is null and crashes. Perhaps a null check and bailing could be useful here if the title is not populated yet?
https://gist.github.com/tj-devel709/10346a24bbb84b04a1f8dc4e15777410
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.
You're right! I've added a null check
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
9366d37
to
23fe76a
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/rebase |
1 similar comment
/rebase |
51c87b8
to
b3e03d9
Compare
Co-Authored-By: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
b3e03d9
to
e040d14
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/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