-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 selectionColor prop for Text on Android #11947
Conversation
@@ -32,6 +36,7 @@ const viewConfig = { | |||
ellipsizeMode: true, | |||
allowFontScaling: true, | |||
selectable: true, | |||
selectionColor: ColorPropType, |
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 think this should be selectionColor: true
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.
@janicduplessis you're right. I got confused by another place where there was proptype, most probably by mistake.
@@ -317,6 +326,12 @@ const Text = React.createClass({ | |||
isHighlighted: this.state.isHighlighted, | |||
}; | |||
} | |||
if (typeof newProps.selectionColor !== '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.
Looking at other examples (TextInput) it seems like we don't need to manually call processColor for props of type Color.
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.
@janicduplessis Text
doesn't use the requireNativeComponent
which calls processColor
, so this seems to be needed. Otherwise the native side receives a string.
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.
Ahh I see, Could you just change the if check to be newProps.selectionColor != null instead to match null and undefined.
@janicduplessis updated |
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.
Cool, just 2 more small nits then this is good to go!
@@ -11,6 +11,8 @@ | |||
*/ | |||
'use strict'; | |||
|
|||
const ColorPropType = require('ColorPropType'); | |||
const processColor = require('processColor'); |
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.
Nit: Move this with other function requires (those that start with a lowercase letter)
selectable: React.PropTypes.bool, | ||
selectable: PropTypes.bool, | ||
/** | ||
* The highlight color of the 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.
Nit: Align comment *
s.
@janicduplessis updated |
👍 Will ship later today once CI passes. |
@facebook-github-bot shipit |
@facebook-github-bot shipit |
@janicduplessis has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: **Motivation** Customizing the selection color allows to use brand colors in the app. The PR implements a `selectionColor` prop for `Text` component similar to `TextInput`. **Test plan (required)** Run UIExplorer example with the changes and verify everything works fine. ![image](https://cloud.githubusercontent.com/assets/1174278/22023258/70197d84-dceb-11e6-8662-2879d78d14d4.png) cc brentvatne Closes facebook#11947 Differential Revision: D4430265 fbshipit-source-id: 462f16548d93ab03aadb27d6f12acf90842627ab
Summary: **Motivation** Customizing the selection color allows to use brand colors in the app. The PR implements a `selectionColor` prop for `Text` component similar to `TextInput`. **Test plan (required)** Run UIExplorer example with the changes and verify everything works fine. ![image](https://cloud.githubusercontent.com/assets/1174278/22023258/70197d84-dceb-11e6-8662-2879d78d14d4.png) cc brentvatne Closes facebook#11947 Differential Revision: D4430265 fbshipit-source-id: 462f16548d93ab03aadb27d6f12acf90842627ab
Summary: **Motivation** Customizing the selection color allows to use brand colors in the app. The PR implements a `selectionColor` prop for `Text` component similar to `TextInput`. **Test plan (required)** Run UIExplorer example with the changes and verify everything works fine. ![image](https://cloud.githubusercontent.com/assets/1174278/22023258/70197d84-dceb-11e6-8662-2879d78d14d4.png) cc brentvatne Closes facebook/react-native#11947 Differential Revision: D4430265 fbshipit-source-id: 462f16548d93ab03aadb27d6f12acf90842627ab
Motivation
Customizing the selection color allows to use brand colors in the app. The PR implements a
selectionColor
prop forText
component similar toTextInput
.Test plan (required)
Run UIExplorer example with the changes and verify everything works fine.
cc @brentvatne