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: https://github.com/facebook/react-native/pull/22134

Differential Revision: D12930719

Pulled By: TheSavior

fbshipit-source-id: 9519f31b7af27f0497e42fd51f18c19be3692823
This commit is contained in:
nd-02110114 2018-11-05 15:25:01 -08:00 committed by Facebook Github Bot
parent f9050e0908
commit 636e146c4a
1 changed files with 28 additions and 8 deletions

View File

@ -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,7 +77,7 @@ 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
@ -65,7 +85,7 @@ type Props = $ReadOnly<{|
* 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);
}