Permalink
Browse files

Flow strict in ViewPagerAndroid.android.js (#22134)

Summary:
Related to #22100

Turn Flow strict mode on for Libraries/Components/ViewPager/ViewPagerAndroid.android.js

- [x] npm run prettier
- [x] npm run flow-check-ios
- [x] npm run flow-check-android

[GENERAL] [ENHANCEMENT] [Libraries/Components/ViewPager/ViewPagerAndroid.android.js] - Flow strict mode
Pull Request resolved: #22134

Differential Revision: D12930719

Pulled By: TheSavior

fbshipit-source-id: 9519f31b7af27f0497e42fd51f18c19be3692823
  • Loading branch information...
nd-02110114 authored and facebook-github-bot committed Nov 5, 2018
1 parent f9050e0 commit 636e146c4a27990547c81c2d36411d36b2c8e788
Showing with 28 additions and 8 deletions.
  1. +28 −8 Libraries/Components/ViewPager/ViewPagerAndroid.android.js
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
*/

'use strict';
@@ -19,11 +19,31 @@ const requireNativeComponent = require('requireNativeComponent');

const NativeAndroidViewPager = requireNativeComponent('AndroidViewPager');

import type {SyntheticEvent} from 'CoreEventTypes';
import type {ViewStyleProp} from 'StyleSheet';

const VIEWPAGER_REF = 'viewPager';

type Event = Object;
type PageScrollState = 'idle' | 'dragging' | 'settling';

type PageScrollEvent = SyntheticEvent<
$ReadOnly<{|
position: number,
offset: number,
|}>,
>;

type PageScrollStateChangedEvent = SyntheticEvent<
$ReadOnly<{|
pageScrollState: PageScrollState,
|}>,
>;

type PageSelectedEvent = SyntheticEvent<
$ReadOnly<{|
position: number,
|}>,
>;

export type ViewPagerScrollState = $Enum<{
idle: string,
@@ -47,7 +67,7 @@ type Props = $ReadOnly<{|
* Value x means that (1 - x) fraction of the page at "position" index is
* visible, and x fraction of the next page is visible.
*/
onPageScroll?: ?Function,
onPageScroll?: ?(e: PageScrollEvent) => void,

/**
* Function called when the page scrolling state has changed.
@@ -57,15 +77,15 @@ type Props = $ReadOnly<{|
* - settling, meaning that there was an interaction with the page scroller, and the
* page scroller is now finishing it's closing or opening animation
*/
onPageScrollStateChanged?: ?Function,
onPageScrollStateChanged?: ?(e: PageScrollState) => void,

/**
* This callback will be called once ViewPager finish navigating to selected page
* (when user swipes between pages). The `event.nativeEvent` object passed to this
* callback will have following fields:
* - position - index of page that has been selected
*/
onPageSelected?: ?Function,
onPageSelected?: ?(e: PageSelectedEvent) => void,

/**
* Blank space to show between pages. This is only visible while scrolling, pages are still
@@ -194,7 +214,7 @@ class ViewPagerAndroid extends React.Component<Props> {
});
};

_onPageScroll = (e: Event) => {
_onPageScroll = (e: PageScrollEvent) => {
if (this.props.onPageScroll) {
this.props.onPageScroll(e);
}
@@ -203,13 +223,13 @@ class ViewPagerAndroid extends React.Component<Props> {
}
};

_onPageScrollStateChanged = (e: Event) => {
_onPageScrollStateChanged = (e: PageScrollStateChangedEvent) => {
if (this.props.onPageScrollStateChanged) {
this.props.onPageScrollStateChanged(e.nativeEvent.pageScrollState);
}
};

_onPageSelected = (e: Event) => {
_onPageSelected = (e: PageSelectedEvent) => {
if (this.props.onPageSelected) {
this.props.onPageSelected(e);
}

0 comments on commit 636e146

Please sign in to comment.