mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 13:01:13 +00:00
91788d2bbd
Summary:I forgot to add a deprecation warning to PullToRefreshViewAndroid when I worked on RefreshControl. This adds one as well as remove it from the website and remove the UIExplorer example. Now that we have versioned doc I think it is fine to remove deprecated stuff from the website so it is easier for users to know what component they should use. Last thing, I enabled flow in RefreshControl and fixed the one warning. Closes https://github.com/facebook/react-native/pull/6055 Differential Revision: D2959502 Pulled By: mkonicek fb-gh-sync-id: 9b23f84ea35c770bfe2a83d0fd3ec7e439669c33 shipit-source-id: 9b23f84ea35c770bfe2a83d0fd3ec7e439669c33
97 lines
2.5 KiB
JavaScript
97 lines
2.5 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule RefreshControl
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
const React = require('React');
|
|
const Platform = require('Platform');
|
|
const ColorPropType = require('ColorPropType');
|
|
const View = require('View');
|
|
|
|
const requireNativeComponent = require('requireNativeComponent');
|
|
|
|
if (Platform.OS === 'android') {
|
|
var RefreshLayoutConsts = require('NativeModules').UIManager.AndroidSwipeRefreshLayout.Constants;
|
|
} else {
|
|
var RefreshLayoutConsts = {SIZE: {}};
|
|
}
|
|
|
|
/**
|
|
* This component is used inside a ScrollView to add pull to refresh
|
|
* functionality. When the ScrollView is at `scrollY: 0`, swiping down
|
|
* triggers an `onRefresh` event.
|
|
*/
|
|
const RefreshControl = React.createClass({
|
|
statics: {
|
|
SIZE: RefreshLayoutConsts.SIZE,
|
|
},
|
|
|
|
propTypes: {
|
|
...View.propTypes,
|
|
/**
|
|
* Called when the view starts refreshing.
|
|
*/
|
|
onRefresh: React.PropTypes.func,
|
|
/**
|
|
* Whether the view should be indicating an active refresh.
|
|
*/
|
|
refreshing: React.PropTypes.bool,
|
|
/**
|
|
* The color of the refresh indicator.
|
|
* @platform ios
|
|
*/
|
|
tintColor: ColorPropType,
|
|
/**
|
|
* The title displayed under the refresh indicator.
|
|
* @platform ios
|
|
*/
|
|
title: React.PropTypes.string,
|
|
/**
|
|
* Whether the pull to refresh functionality is enabled.
|
|
* @platform android
|
|
*/
|
|
enabled: React.PropTypes.bool,
|
|
/**
|
|
* The colors (at least one) that will be used to draw the refresh indicator.
|
|
* @platform android
|
|
*/
|
|
colors: React.PropTypes.arrayOf(ColorPropType),
|
|
/**
|
|
* The background color of the refresh indicator.
|
|
* @platform android
|
|
*/
|
|
progressBackgroundColor: ColorPropType,
|
|
/**
|
|
* Size of the refresh indicator, see RefreshControl.SIZE.
|
|
* @platform android
|
|
*/
|
|
size: React.PropTypes.oneOf(RefreshLayoutConsts.SIZE.DEFAULT, RefreshLayoutConsts.SIZE.LARGE),
|
|
},
|
|
|
|
render() {
|
|
return <NativeRefreshControl {...this.props} />;
|
|
},
|
|
});
|
|
|
|
if (Platform.OS === 'ios') {
|
|
var NativeRefreshControl = requireNativeComponent(
|
|
'RCTRefreshControl',
|
|
RefreshControl
|
|
);
|
|
} else if (Platform.OS === 'android') {
|
|
var NativeRefreshControl = requireNativeComponent(
|
|
'AndroidSwipeRefreshLayout',
|
|
RefreshControl
|
|
);
|
|
}
|
|
|
|
module.exports = RefreshControl;
|