Removed ProgressBarAndroid.android deprecation warning
Reviewed By: hramos Differential Revision: D6092598 fbshipit-source-id: 24282a923cf45e749cf33f8a5b7a49995e7fadfe
This commit is contained in:
parent
30b057fa9c
commit
b60fa63de8
|
@ -14,8 +14,9 @@
|
||||||
const ColorPropType = require('ColorPropType');
|
const ColorPropType = require('ColorPropType');
|
||||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||||
const Platform = require('Platform');
|
const Platform = require('Platform');
|
||||||
const React = require('React');
|
const ProgressBarAndroid = require('ProgressBarAndroid');
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
|
const React = require('React');
|
||||||
const StyleSheet = require('StyleSheet');
|
const StyleSheet = require('StyleSheet');
|
||||||
const View = require('View');
|
const View = require('View');
|
||||||
const ViewPropTypes = require('ViewPropTypes');
|
const ViewPropTypes = require('ViewPropTypes');
|
||||||
|
@ -135,16 +136,20 @@ const ActivityIndicator = createReactClass({
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nativeProps = {
|
||||||
|
...props,
|
||||||
|
style: sizeStyle,
|
||||||
|
styleAttr: 'Normal',
|
||||||
|
indeterminate: true,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View onLayout={onLayout} style={[styles.container, style]}>
|
||||||
onLayout={onLayout}
|
{Platform.OS === 'ios' ? (
|
||||||
style={[styles.container, style]}>
|
<RCTActivityIndicator {...nativeProps} />
|
||||||
<RCTActivityIndicator
|
) : (
|
||||||
{...props}
|
<ProgressBarAndroid {...nativeProps} />
|
||||||
style={sizeStyle}
|
)}
|
||||||
styleAttr="Normal"
|
|
||||||
indeterminate
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -169,18 +174,7 @@ if (Platform.OS === 'ios') {
|
||||||
var RCTActivityIndicator = requireNativeComponent(
|
var RCTActivityIndicator = requireNativeComponent(
|
||||||
'RCTActivityIndicatorView',
|
'RCTActivityIndicatorView',
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
{nativeOnly: {activityIndicatorViewStyle: true}},
|
{ nativeOnly: { activityIndicatorViewStyle: true } }
|
||||||
);
|
|
||||||
} else if (Platform.OS === 'android') {
|
|
||||||
var RCTActivityIndicator = requireNativeComponent(
|
|
||||||
'AndroidProgressBar',
|
|
||||||
ActivityIndicator,
|
|
||||||
// Ignore props that are specific to non inderterminate ProgressBar.
|
|
||||||
{nativeOnly: {
|
|
||||||
indeterminate: true,
|
|
||||||
progress: true,
|
|
||||||
styleAttr: true,
|
|
||||||
}},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,14 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const ActivityIndicator = require('ActivityIndicator');
|
|
||||||
const ColorPropType = require('ColorPropType');
|
const ColorPropType = require('ColorPropType');
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
const React = require('React');
|
const React = require('React');
|
||||||
const ReactNative = require('ReactNative');
|
const ReactNative = require('ReactNative');
|
||||||
const ViewPropTypes = require('ViewPropTypes');
|
const ViewPropTypes = require('ViewPropTypes');
|
||||||
|
|
||||||
|
const requireNativeComponent = require('requireNativeComponent');
|
||||||
|
|
||||||
const STYLE_ATTRIBUTES = [
|
const STYLE_ATTRIBUTES = [
|
||||||
'Horizontal',
|
'Horizontal',
|
||||||
'Normal',
|
'Normal',
|
||||||
|
@ -78,6 +79,10 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
|
||||||
* - LargeInverse
|
* - LargeInverse
|
||||||
*/
|
*/
|
||||||
styleAttr: PropTypes.oneOf(STYLE_ATTRIBUTES),
|
styleAttr: PropTypes.oneOf(STYLE_ATTRIBUTES),
|
||||||
|
/**
|
||||||
|
* Whether to show the ProgressBar (true, the default) or hide it (false).
|
||||||
|
*/
|
||||||
|
animating: PropTypes.bool,
|
||||||
/**
|
/**
|
||||||
* If the progress bar will show indeterminate progress. Note that this
|
* If the progress bar will show indeterminate progress. Note that this
|
||||||
* can only be false if styleAttr is Horizontal.
|
* can only be false if styleAttr is Horizontal.
|
||||||
|
@ -99,21 +104,23 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
styleAttr: 'Normal',
|
styleAttr: 'Normal',
|
||||||
indeterminate: true
|
indeterminate: true,
|
||||||
|
animating: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if (this.props.indeterminate && this.props.styleAttr !== 'Horizontal') {
|
|
||||||
console.warn(
|
|
||||||
'Circular indeterminate `ProgressBarAndroid`' +
|
|
||||||
'is deprecated. Use `ActivityIndicator` instead.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <ActivityIndicator {...this.props} animating={true} />;
|
return <AndroidProgressBar {...this.props} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AndroidProgressBar = requireNativeComponent(
|
||||||
|
'AndroidProgressBar',
|
||||||
|
ProgressBarAndroid,
|
||||||
|
{
|
||||||
|
nativeOnly: {
|
||||||
|
animating: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = ProgressBarAndroid;
|
module.exports = ProgressBarAndroid;
|
||||||
|
|
Loading…
Reference in New Issue