-
Notifications
You must be signed in to change notification settings - Fork 766
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
Allow for custom ScrollStateDetector implementation #757
base: master
Are you sure you want to change the base?
Conversation
This change breaks the existing ScrollStateDetector implementation into two. It extracts an interface that users can potentially implement to provide their own ScrollStateDetector. It also creates an additional DefaultScrollStateDetector class that now contains the default ScrollStateDetector implementation.
This change adds onInterceptTouchEvent support to ScrollStateDetector and the relevant hooks in LithoScrollView and HorizontalScrollSpec. The implementation in the DefaultScrollStateDetector will be a no-op, because in that class all detection is done through onTouchEvent. Finally it also adds documentation in the ScrollStateDetector interface.
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.
Hi @chggr !
I've left a couple of comments below, but @arpitratan would probably add more after checking the actual functionally.
Can you also add a line to CHANGELOG.md about the new/changed functionality to keep everyone updated, please?
litho-it/src/test/java/com/facebook/litho/widget/DefaultScrollStateDetectorTest.java
Outdated
Show resolved
Hide resolved
litho-widget/src/main/java/com/facebook/litho/widget/HorizontalScrollSpec.java
Outdated
Show resolved
Hide resolved
litho-widget/src/main/java/com/facebook/litho/widget/VerticalScrollSpec.java
Outdated
Show resolved
Hide resolved
This change addds @nullable for ScrollStateDetector in both the HorizontalScrollSpec and VerticalScrollSpec. It also changes the method names in DefaultScrollStateDetectorTest to conform to the Litho standard.
Thanks @colriot for the review, great feedback! I have made all required changes, please let me know if there is anything else outstanding. Many thanks again and have a great day :-) |
Hi @arpitratan, @colriot, I hope you are well! Please let me know if you have any feedback on this PR. |
@colriot has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary
Support for a default ScrollStateDetector n HorizontalScrollSpec and VerticalScrollSpec was added
in a previous PR. This PR allows users to provide their own custom ScrollStateDetector implementation.
It breaks the existing ScrollStateDetector class into two: It extracts an interface that users can potentially
implement with their own functionality and also creates an additional DefaultScrollStateDetector that now
contains the default implementation to be used when no custom implementation has been specified.
Changelog
Allow for custom ScrollStateDetector implementations in HorizontalScrollSpec and VerticalScrollSpec.
Test Plan
This change has been tested via unit tests