-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for tintColor on ASImageNode and ASButtonNode #1603
Conversation
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.
Just took a first pass and there are some obvious things to clean up.
When testing against UILabel, UIButton it appears that
- UILabel doesn't respond to tintColor directly even if it's set
- UIButton responds to tintColor but will not override a color that a user has specified
f45a502
to
5bed56d
Compare
Source/ASButtonNode.mm
Outdated
{ | ||
if (title) { | ||
NSMutableAttributedString *mutString = [[NSMutableAttributedString alloc] initWithAttributedString:title]; | ||
NSRange limit = NSMakeRange(0, _normalAttributedTitle.length); |
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.
should this be title
, not _normalAttributedTitle
? It looks like several different titles are being passed in here in updateTitleForegroundColor
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.
Great catch!
Source/ASImageNode.mm
Outdated
|| renderingMode == UIImageRenderingModeAutomatic) | ||
&& key.tintColor) { | ||
asimagenode_modification_block_t tintModificationBlock = ASImageNodeTintColorModificationBlock(key.tintColor); | ||
result = tintModificationBlock(result); |
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.
I like this approach. Using the existing ASImageNodeTintColorModificationBlock
helps to encapsulate this drawing operation nicely and makes the code much cleaner. There are perf and memory trade-offs because we draw one image more (compare to rendering the tint color in the first pass), but we can optimize it later if we find the need to.
🚫 CI failed with log |
5bed56d
to
fef6c3d
Compare
🚫 CI failed with log |
fef6c3d
to
4b07fa7
Compare
@nguyenhuy @bolsinga - Please take another look. I've reworked the PR in a few important ways:
|
🚫 CI failed with log |
🚫 CI failed with log |
🚫 CI failed with log |
🚫 CI failed with log |
🚫 CI failed with log |
- Adding the ability to specify a tintColor for images / buttons that behave similarly to how they would under UIKit
UIKit controls if it is applied to UILabel
d2d36d4
to
255c1d7
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.
Nits aside, LGTM!
To other reviewers: I'm going to land this diff now so we can start testing it internally (we have a fixed sync schedule now). Feel free to do a post-review, especially the changes in ASTextNode2, and we'll follow up on any issues found. |
Co-Authored-By: Huy Nguyen <[email protected]>
Co-Authored-By: Huy Nguyen <[email protected]>
Adding the ability to specify a tintColor for images / buttons that behave similarly to how they would under UIKit