Skip to content
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

Conversation

AlanFoster
Copy link
Contributor

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

flashindicators-ios

New Android Functionality

flashindicators-android

@facebook-github-bot
Copy link
Contributor

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')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 20, 2017
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@AlanFoster AlanFoster force-pushed the support-flash-scroll-indicators-for-android branch from ea6626a to c43950e Compare August 20, 2017 01:24
Copy link
Contributor

@janicduplessis janicduplessis left a 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') {
Copy link
Contributor

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.

Copy link
Contributor Author

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!

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why super?

Copy link
Contributor Author

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 :)

@AlanFoster AlanFoster force-pushed the support-flash-scroll-indicators-for-android branch 2 times, most recently from 5d63ed8 to 48f4b68 Compare August 20, 2017 23:29
@AlanFoster AlanFoster force-pushed the support-flash-scroll-indicators-for-android branch from 48f4b68 to 4d0bd13 Compare August 20, 2017 23:30
@AlanFoster
Copy link
Contributor Author

AlanFoster commented Aug 21, 2017

@janicduplessis All feedback applied now; Is the end result good to ship? :)

@janicduplessis
Copy link
Contributor

Thanks @AlanFoster, looks good to me,

@shergin I think this is good to ship.

@@ -471,8 +471,11 @@ var ScrollResponderMixin = {
* @platform ios
Copy link
Contributor

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. 🎉

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Aug 23, 2017
@facebook-github-bot
Copy link
Contributor

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@AlanFoster
Copy link
Contributor Author

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 :)

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Aug 24, 2017
@facebook-github-bot
Copy link
Contributor

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.

@shergin
Copy link
Contributor

shergin commented Aug 24, 2017

Seems I have to fix some internal stuff before it can be landed. I hope I will do it soon.

@shergin shergin self-assigned this Aug 24, 2017
@AlanFoster AlanFoster deleted the support-flash-scroll-indicators-for-android branch September 18, 2017 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants