-
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
Support flash scroll indicators for android #15566
Support flash scroll indicators for android #15566
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! |
@@ -18,6 +18,7 @@ var ReactNative = require('ReactNative'); | |||
var Subscribable = require('Subscribable'); | |||
var TextInputState = require('TextInputState'); | |||
var UIManager = require('UIManager'); | |||
var Platform = require('Platform') |
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.
semi: Missing semicolon.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
ea6626a
to
c43950e
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 PR! Just some small changes to make the code simpler.
@@ -471,6 +472,15 @@ var ScrollResponderMixin = { | |||
* @platform ios | |||
*/ | |||
scrollResponderFlashScrollIndicators: function() { | |||
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.
We could just get rid of the iOS code path and always use UIManager.dispatchViewManagerCommand
, afaik it also works on iOS.
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.
Hmm! In honesty, I wasn't quite sure why on iOS there was an explicit ScrollViewManager as a native module, but on android there isn't one
Unfortunately I'm lacking the iOS-foo to test this change out, and I can't see any equivalent docs for running a modified of react-native with iOS - similar to the the Android Building React Native from source docs. I'm going to have to punt on this one unfortunately!
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 ViewManagers as modules were just never implemented on Android. I was mostly basing this comment on other methods like scrollTo uses only dispatchViewManagerCommand even on iOS. On iOS react nativr is already built from source so you could test by either running the RNTester xcodeproj or changing code under node_modules in an app.
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.
But there should not be any native changes required on iOS, it should just work when using dispatchViewManagerCommand
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.
But there should not be any native changes required on iOS, it should just work when using dispatchViewManagerCommand
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; There's some magic inside the UIManager.js
to handle iOS. Gotcha now 👍
Updated :)
@@ -92,6 +92,10 @@ public void setPagingEnabled(boolean pagingEnabled) { | |||
mPagingEnabled = pagingEnabled; | |||
} | |||
|
|||
public boolean flashScrollIndicators() { |
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.
What is the boolean returned by this? Since we're not using it might as well not return it.
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've nuked it now! :)
Just for visibility though; The android API is:
true if the animation is played, false otherwise
@@ -121,6 +121,10 @@ public void setScrollEnabled(boolean scrollEnabled) { | |||
mScrollEnabled = scrollEnabled; | |||
} | |||
|
|||
public boolean flashScrollIndicators() { |
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.
Same for the boolean here
@@ -125,6 +125,11 @@ public void receiveCommand( | |||
} | |||
|
|||
@Override | |||
public void flashScrollIndicators(ReactHorizontalScrollView scrollView) { | |||
scrollView.flashScrollIndicators(); |
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.
We can call awakenScrollBars
right from here, 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.
Unfortunately not as it's protected :)
@@ -92,6 +92,10 @@ public void setPagingEnabled(boolean pagingEnabled) { | |||
mPagingEnabled = pagingEnabled; | |||
} | |||
|
|||
public boolean flashScrollIndicators() { | |||
return super.awakenScrollBars(); |
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.
Why super
?
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 a small left-over piece of code; I was initially overriding to just widen the scope:
@Override
public boolean awakenScrollBars() {
return super.awakeScrolBars();
}
But I decided to align the names with the existing API; And now the super
was out of place. Deleted now, and the PR has been updated :)
5d63ed8
to
48f4b68
Compare
48f4b68
to
4d0bd13
Compare
@janicduplessis All feedback applied now; Is the end result good to ship? :) |
Thanks @AlanFoster, looks good to me, @shergin I think this is good to ship. |
@@ -471,8 +471,11 @@ var ScrollResponderMixin = { | |||
* @platform ios |
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.
We have to remove it now. 🎉
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Thanks for the PR review guys! 👍 Could I possibly chance my arm for a review of migrating the network inspector from ListView->FlatList? #15548 😇 I'm hoping to put up an additional PR once that's approved to make the Network inspector's scrollToBottom mechanism a lot nicer for developers, but I was hoping to get these pre-requisite PRs in first :) |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
Seems I have to fix some internal stuff before it can be landed. I hope I will do it soon. |
There is missing support for flash scroll indicators on Android. This PR adds this functionality.
Test Plan
Ensured that the functionality works now within iOS and Android
Existing iOS Functionality
New Android Functionality