-
Notifications
You must be signed in to change notification settings - Fork 16
update Text to support gradient colors #54
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
Conversation
| */ | ||
| minimumFontScale?: number | undefined; | ||
|
|
||
| gradientColors?: number[] | undefined; |
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 know it's a fork but maybe doc on the expected format, eg: what type of "int based color" is expected here and also presumably its a horizontal gradient only.
| protected boolean mIsBackgroundColorSet = false; | ||
| protected int mBackgroundColor; | ||
|
|
||
| protected int[] mGradientColors = new int[0]; |
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.
maybe just leave it as null so we don't pay any added memory cost for the majority case where gradient colors are not being used.
| } | ||
| } | ||
| if (colors.size() >= 2) { | ||
| mGradientColors = colors.stream() |
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 would be wary of using .stream() I am not entirely sure if this Java API is backported to all the old Android versions we support.
I'd suggest sticking to a simple for loop.
Summary:
We added a new Boost perk called "Enhanced Role Colors/Styles" that allows admins to set gradient colors for roles in their guild. To support this on mobile, we have to provide native components that can render gradients.
At first, we were planning to create a custom native component but ran into 2 issues:
heightandwidthdefined for it to render. This was fixed by using aShadowNodebut we ran into other sizing issues.Textnodes and wouldn't render our custom view even when it extendedBaseText.We decided rather than creating a new custom component and solving for the above issues, it'd be easier to update
Textto support gradient colors.Changelog:
Textto supportgradientColorswhich is an optional array ofnumbersTest Plan:
Tested updating
ChatInputReplyBarto show gradient colors with the following test cases:gradientColorswith a list ofnumbersgradientColorswith somenullvaluesgradientColorswith somestringvaluesgradientColorswith somedoublevaluesFor the value types not
int, the goal is to not crash the app. This equates to different behaviors between the platforms but the dev will get a type error on the React JS side of things so things should generally work as expected.I picked
ChatInputReplyBarbecause it demonstrates the behavior with nestedTextnodes and is a place where we will want to render gradient colors.screenshots
happy path

tertiaryColorisstring(which is ignored so only first 2 colors show)tertiaryColorisdouble(which is translated as0on Android and some other number on iOS)