-
Notifications
You must be signed in to change notification settings - Fork 420
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
feat: make pager controlled #693
base: master
Are you sure you want to change the base?
Conversation
* feat(iOS): change Fabric implementation to UIScrollView * fix: fix offset values in vertical orientation * feat: add initialPage props support * feat: add RTL language support * feat: add pageMargin prop support * fix: fix typescript error * feat: remove React.cloneElement * feat(ios): add getPageOffset method * fix: fix styles in old example * fix: behavior on page remove
Co-authored-by: Piotr Trocki <[email protected]>
* feat: rewrite old arch to use UIScrollView * feat: update example styles * fix: sending event on scrollViewDidEndDecelerating * feat: properly calculate width using orientation * fix: change way of disabing scroll * feat: rename to RNCPagerView * fix: removing last page * fix: remove unused properties, set animated
@@ -24,6 +24,8 @@ export type OnPageScrollStateChangedEventData = Readonly<{ | |||
}>; | |||
|
|||
export interface NativeProps extends ViewProps { | |||
page?: Int32; |
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.
Could you extract those props to a separate interface?
android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativepagerview/PagerViewViewManagerImpl.kt
Show resolved
Hide resolved
val view = PagerViewViewManagerImpl.getViewPager(host) | ||
Assertions.assertNotNull(view) | ||
Assertions.assertNotNull(pageIndex) | ||
val childCount = view.adapter?.itemCount |
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.
val childCount = view.adapter?.itemCount | |
val childCount = view.adapter?.itemCount ?: -1 |
Assertions.assertNotNull(pageIndex) | ||
val childCount = view.adapter?.itemCount | ||
val animated = PagerViewViewManagerImpl.animated | ||
val canScroll = childCount != null && childCount > 0 && pageIndex >= 0 && pageIndex < childCount |
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.
val canScroll = childCount != null && childCount > 0 && pageIndex >= 0 && pageIndex < childCount | |
val canScroll = childCount > 0 && pageIndex >= 0 && pageIndex < childCount |
RN this PR is on hold, bc the sync mechanism in case of failure does not work |
Summary
This PR makes Pager View a controlled component, giving users the ability to control the current page with new
page
andanimated
properties.It also changes all examples to use the controlled version of Pager View, as this will be the recommended way of using it.
This feature will only be available from version
7.x.x
Compatibility
Checklist
README.md