2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2015-03-23 20:35:08 +00:00
|
|
|
* 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.
|
2015-02-20 04:10:52 +00:00
|
|
|
*
|
|
|
|
* @providesModule ActivityIndicatorIOS
|
2015-03-25 19:55:10 +00:00
|
|
|
* @flow
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var NativeMethodsMixin = require('NativeMethodsMixin');
|
2015-03-04 22:04:52 +00:00
|
|
|
var NativeModules = require('NativeModules');
|
2015-02-20 04:10:52 +00:00
|
|
|
var PropTypes = require('ReactPropTypes');
|
|
|
|
var React = require('React');
|
|
|
|
var StyleSheet = require('StyleSheet');
|
|
|
|
var View = require('View');
|
|
|
|
|
2015-04-22 04:07:17 +00:00
|
|
|
var requireNativeComponent = require('requireNativeComponent');
|
|
|
|
var verifyPropTypes = require('verifyPropTypes');
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
var GRAY = '#999999';
|
|
|
|
|
2015-03-25 19:55:10 +00:00
|
|
|
type DefaultProps = {
|
|
|
|
animating: boolean;
|
|
|
|
color: string;
|
2015-04-26 09:22:34 +00:00
|
|
|
hidesWhenStopped: boolean;
|
|
|
|
size: 'small' | 'large';
|
2015-03-25 19:55:10 +00:00
|
|
|
};
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
var ActivityIndicatorIOS = React.createClass({
|
|
|
|
mixins: [NativeMethodsMixin],
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
/**
|
|
|
|
* Whether to show the indicator (true, the default) or hide it (false).
|
|
|
|
*/
|
|
|
|
animating: PropTypes.bool,
|
|
|
|
/**
|
|
|
|
* The foreground color of the spinner (default is gray).
|
|
|
|
*/
|
|
|
|
color: PropTypes.string,
|
2015-04-26 09:22:34 +00:00
|
|
|
/**
|
|
|
|
* Whether the indicator should hide when not animating (true by default).
|
|
|
|
*/
|
|
|
|
hidesWhenStopped: PropTypes.bool,
|
2015-03-18 04:40:17 +00:00
|
|
|
/**
|
|
|
|
* Size of the indicator. Small has a height of 20, large has a height of 36.
|
|
|
|
*/
|
2015-03-04 22:04:52 +00:00
|
|
|
size: PropTypes.oneOf([
|
2015-03-18 04:40:17 +00:00
|
|
|
'small',
|
2015-03-04 22:04:52 +00:00
|
|
|
'large',
|
|
|
|
]),
|
2015-02-20 04:10:52 +00:00
|
|
|
},
|
|
|
|
|
2015-03-25 19:55:10 +00:00
|
|
|
getDefaultProps: function(): DefaultProps {
|
2015-02-20 04:10:52 +00:00
|
|
|
return {
|
|
|
|
animating: true,
|
|
|
|
color: GRAY,
|
2015-04-26 09:22:34 +00:00
|
|
|
hidesWhenStopped: true,
|
|
|
|
size: 'small',
|
2015-02-20 04:10:52 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2015-04-26 09:22:34 +00:00
|
|
|
var {style, ...props} = this.props;
|
|
|
|
var sizeStyle = (this.props.size === 'large') ? styles.sizeLarge : styles.sizeSmall;
|
2015-02-20 04:10:52 +00:00
|
|
|
return (
|
2015-04-26 09:22:34 +00:00
|
|
|
<View style={[styles.container, sizeStyle, style]}>
|
|
|
|
<RCTActivityIndicatorView {...props} />
|
2015-02-20 04:10:52 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
|
|
|
sizeSmall: {
|
|
|
|
height: 20,
|
|
|
|
},
|
|
|
|
sizeLarge: {
|
|
|
|
height: 36,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-26 09:22:34 +00:00
|
|
|
var RCTActivityIndicatorView = requireNativeComponent(
|
|
|
|
'RCTActivityIndicatorView',
|
2015-04-22 04:07:17 +00:00
|
|
|
null
|
|
|
|
);
|
|
|
|
if (__DEV__) {
|
|
|
|
var nativeOnlyProps = {activityIndicatorViewStyle: true};
|
|
|
|
verifyPropTypes(
|
|
|
|
ActivityIndicatorIOS,
|
2015-04-26 09:22:34 +00:00
|
|
|
RCTActivityIndicatorView.viewConfig,
|
2015-04-22 04:07:17 +00:00
|
|
|
nativeOnlyProps
|
|
|
|
);
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
module.exports = ActivityIndicatorIOS;
|