mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
Flowtype RefreshControl
Reviewed By: yungsters Differential Revision: D7985835 fbshipit-source-id: 67a27cb99738d99959b1c795af95d0415a84f1b9
This commit is contained in:
parent
4b1ecb6204
commit
891dfc3da4
@ -14,12 +14,16 @@ const ColorPropType = require('ColorPropType');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const ReactNative = require('ReactNative');
|
||||
const PropTypes = require('prop-types');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
const createReactClass = require('create-react-class');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
const AndroidSwipeRefreshLayout = require('UIManager')
|
||||
.AndroidSwipeRefreshLayout;
|
||||
@ -30,6 +34,31 @@ if (Platform.OS === 'android') {
|
||||
var RefreshLayoutConsts = {SIZE: {}};
|
||||
}
|
||||
|
||||
type IOSProps = $ReadOnly<{|
|
||||
tintColor?: ?ColorValue,
|
||||
titleColor?: ?ColorValue,
|
||||
title?: ?string,
|
||||
|}>;
|
||||
|
||||
type AndroidProps = $ReadOnly<{|
|
||||
enabled?: ?boolean,
|
||||
colors?: ?$ReadOnlyArray<ColorValue>,
|
||||
progressBackgroundColor?: ?ColorValue,
|
||||
size?: ?(
|
||||
| typeof RefreshLayoutConsts.SIZE.DEFAULT
|
||||
| typeof RefreshLayoutConsts.SIZE.LARGE
|
||||
),
|
||||
progressViewOffset?: ?number,
|
||||
|}>;
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
...IOSProps,
|
||||
...AndroidProps,
|
||||
onRefresh?: ?Function,
|
||||
refreshing: boolean,
|
||||
|}>;
|
||||
|
||||
/**
|
||||
* This component is used inside a ScrollView or ListView to add pull to refresh
|
||||
* functionality. When the ScrollView is at `scrollY: 0`, swiping down
|
||||
@ -180,6 +209,10 @@ const RefreshControl = createReactClass({
|
||||
},
|
||||
});
|
||||
|
||||
class TypedRefreshControl extends ReactNative.NativeComponent<Props> {
|
||||
static SIZE = RefreshLayoutConsts.SIZE;
|
||||
}
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
var NativeRefreshControl = requireNativeComponent(
|
||||
'RCTRefreshControl',
|
||||
@ -192,4 +225,4 @@ if (Platform.OS === 'ios') {
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = RefreshControl;
|
||||
module.exports = ((RefreshControl: any): Class<TypedRefreshControl>);
|
||||
|
Loading…
x
Reference in New Issue
Block a user