-
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
[Android] Implement fading edges for ScrollView and it's dependent FlatList #26163
[Android] Implement fading edges for ScrollView and it's dependent FlatList #26163
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. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
702084e
to
1979c1f
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.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
1979c1f
to
f1213a1
Compare
f1213a1
to
3bae7cc
Compare
Oh man that options list is getting pretty large...can you make it slightly larger by adding "android-only" to this new option so people don't get confused on iOS and this it's a bug when nothing happens? Also, could you or someone you work with implement support for iOS as well? It would be awesome to have platform parity on as many features as possible. This is a bit old, but is probably still relevant: https://www.cocoanetics.com/2011/08/adding-fading-gradients-to-uitableview/ |
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.
nevermind, your OS === android check is probably fine.
@@ -124,11 +135,29 @@ class FlatListExample extends React.PureComponent<Props, State> { | |||
{renderSmallSwitchOption(this, 'empty')} | |||
{renderSmallSwitchOption(this, 'debug')} | |||
{renderSmallSwitchOption(this, 'useFlatListItemComponent')} | |||
{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.
Oh I see you added an android check - that's fine.
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.
@sahrens is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by André Krüger in f8a64f9. When will my fix make it into a release? | Upcoming Releases |
Is there a need to have a distinction between That would make this go from needing three props, to only one. :) |
I agree, let's only have a single edge length prop. I'm reverting now. |
…ollView and it's dependent FlatList" Summary: After some thought, we decided we don't need the flexibility of separate horizontal and vertical props - it would be much nicer to just have a single prop for the edge length and then the native code can enable the booleans as appropriate. Original PR: #26163 Original commit changeset: f72a9a890d90 Reviewed By: TheSavior Differential Revision: D16997468 fbshipit-source-id: 7973262287a7ec2cee5957f8dc1806a0f28c1432
3bae7cc
to
51acd31
Compare
I did combine the props to a single one, but unfortunately, I don't feel too confident to also implement the feature for iOS (I might be able to do that in a follow-up, though). |
* | ||
* @platform android | ||
*/ | ||
fadingEdgesEnabled?: ?boolean, |
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.
Do we need this Boolean? Or can we just check whether the length is 0 for disabled, non zero for enabled?
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.
Yeah, you're right. Fixed.
51acd31
to
841b6df
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.
Thanks for the update, this is really close! Two more small nits.
@@ -51,6 +58,8 @@ type State = {| | |||
virtualized: boolean, | |||
empty: boolean, | |||
useFlatListItemComponent: boolean, | |||
useFadingEdges: boolean, |
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.
This isn’t needed here anymore, right?
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.
Yes, fixed.
@@ -335,6 +335,13 @@ type AndroidProps = $ReadOnly<{| | |||
* @platform android | |||
*/ | |||
persistentScrollbar?: ?boolean, | |||
/** | |||
* The amount of fading. |
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 add a bit more description here? Assume that what you put here will be the sentence describing what this prop does in our websites api documentation.
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.
Thanks for the feedback. I added more description.
841b6df
to
de33eb8
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.
Looks good! Approved for someone to land on Monday
if (value > 0) { | ||
view.setHorizontalFadingEdgeEnabled(true); | ||
view.setFadingEdgeLength(value); | ||
} |
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, just checking this one last time made me realize that if the prop is set to 0 it should become disabled again.
I think this needs the following, right?
else {
view.setHorizontalFadingEdgeEnabled(false);
}
In both files
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.
Yeah, you're right, this might apply to dev environments where the prop is changed quite often. Maybe the fading edge length should also be reset?
Found one more thing that stood out to me. Sorry for the churn and the back and forth! We'll get this in! |
de33eb8
to
df6bb8a
Compare
Did you verify that toggling the fade switch in the example correctly shows and hides the fade? |
This should add props for enabling horizontal and vertical fading edges for Scrollview and FlatList. These fading edges are used to communicate to the user that there is more content to see.
df6bb8a
to
b86efed
Compare
Yes, it works correctly. I'm now also resetting the fading edge length to zero if the fading edges are disabled, just in case. |
Ok great. |
We are having some trouble landing this PR due to some internal tooling issues around having previously reverting this. I reached out to our Open Source team for support. |
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.
@TheSavior is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary
This should add props for enabling horizontal and vertical fading
edges for Scrollview and FlatList.
These fading edges are used to communicate to the user that there is more content to see.
Changelog
[Android] [Added] - fading edges props to the FlatList and ScrollView components
Test Plan
Open the React Native test app and navigate to the FlatList section.
Enable the
useFadingEdges
switch and insert a number intoFading edge length
.