-
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
Modify TouchableNativeFeedback (Ripple) to follow borderRadius #6515
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
@@ -111,6 +111,17 @@ exports.examples = [ | |||
}, | |||
}]; | |||
|
|||
if(Platform.OS === 'android') { |
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 can add a platform
prop to the example object instead of checking the platform manually. See the '3D Touch' example above that is ios only.
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.
Gotcha, updated.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@jeffchienzabinet updated the pull request. |
Thanks for the PR! Is there a way to do this only by changing implementation of TouchableNativeFeedback and not cc @kmagiera who wrote TouchableNativeFeedback, can you take a look please? :) |
private void refreshTranslucentBackgroundDrawable() { | ||
Drawable background = null; | ||
if (mNativeBackground != null) { | ||
float[] cornerRadii = getOrCreateReactViewBackground().getBorderRadii(); |
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 you may want to check if mReactBackgroundDrawable != null
first. Otherwise this line will create that background object for every view with native background which is undesirable
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.
Ah good catch, updated.
I left one comment inline. Otherwise this looks good to me. |
@jeffchienzabinet updated the pull request. |
@jeffchienzabinet sorry for bugging you again: would you be able to squash your commit so that it only adds 1 commit instead of 9. This helps to keep the history of changes cleaner |
@jeffchienzabinet updated the pull request. |
053ce97
to
c93bb99
Compare
@jeffchienzabinet updated the pull request. |
I messed up the first rebase attempt so I had to hard reset and copy over the changes. I think it should be right...I hope |
<View> | ||
<TouchableNativeFeedback | ||
style={[styles.row, styles.block]} | ||
onPress={() => console.log('TNF Ripple with Border Radius has been clicked')} |
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.
quotes: Strings must use singlequote.
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: I personally find TNF a bit unclear. Can you use TouchableNativeFeedback?
Thanks a lot for the review @kmagiera! I'll wait for the tests to pass before merging. You can also use the shipit bot if you want. |
I've just restarted the tests. |
@facebook-github-bot shipit |
Alright, done. Also fixed some conflicts. |
8b6c830
to
8e48b27
Compare
@jeffchienzabinet updated the pull request. |
if (!drawableDescriptionDict.hasKey("borderless") || | ||
drawableDescriptionDict.isNull("borderless") || | ||
!drawableDescriptionDict.getBoolean("borderless")) { | ||
mask = new ColorDrawable(Color.WHITE); | ||
mask = new PaintDrawable(Color.WHITE); | ||
if (cornerRadii != null) |
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: Please always add braces to keep the formatting consistent with the rest of the codebase:
if (foo) {
oneLiner();
}
It's just a coding convention.
Thanks @jeffchienzabinet! Just some small nits, then this is good to go! 👍 |
Non-ripples generated by TNF.Ripple are now clipped by border radii the same way that the ReactViewGroup it's a background of gets clipped. This is achieved by refreshing those backgrounds in ReactViewGroup whenever nativeBackground or any of the borderRadii is updated, rather than ReactViewManager just setting the background Drawable. Note that TNF.SelectableBackground is not clipped because it's not possible to clip the selectableItemBackground Drawable.
8e48b27
to
ade5cc9
Compare
Alright, done! |
@jeffchienzabinet updated the pull request. |
Thanks @jeffchienzabinet! @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
e438954
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes #6515 Differential Revision: D3126513 Pulled By: AaaChiuuu fb-gh-sync-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1 fbshipit-source-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: mkonicek fb-gh-sync-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81 fbshipit-source-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81
@jeffchienzabinet Product teams at fb reported this broke a few things, such as standard The commit was reverted in 475f1b5. Feel free to submit this again. Can you implement this in a way that only affects Sorry about that, I should have asked for a very thorough Test plan on this pull request that not only tests the new functionality but also the existing one (e.g. borders on views), especially since this modifies such core parts of the codebase ( |
Ahh, damn. Alright, give me some time. Do you guys know what the problem is exactly? |
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: mkonicek fb-gh-sync-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81 fbshipit-source-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: AaaChiuuu fb-gh-sync-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1 fbshipit-source-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1
Any updates on this? |
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: mkonicek fb-gh-sync-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81 fbshipit-source-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: AaaChiuuu fb-gh-sync-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1 fbshipit-source-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1
@mkonicek @jeffchienzabinet @kmagiera any plan to make this again? it sounds awesome ^^ |
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: mkonicek fb-gh-sync-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81 fbshipit-source-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong. I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers! Closes facebook#6515 Differential Revision: D3126513 Pulled By: AaaChiuuu fb-gh-sync-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1 fbshipit-source-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1
Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong.
I added an example to UIExplorer (TouchableExample). This is my first PR to this repo so let me know if something's wrong. Cheers!