Revert D6080118: [react-native][PR] Delegate to ProgressBarAndroid from ActivityIndicator on Android, instead of the other way around

Differential Revision: D6080118

fbshipit-source-id: efd75bbcc07de084213d3791520006090001364d
This commit is contained in:
Jing Chen 2017-10-18 12:46:43 -07:00 committed by Facebook Github Bot
parent c1223c5530
commit 63848bdde5
2 changed files with 24 additions and 35 deletions

View File

@ -14,9 +14,8 @@
const ColorPropType = require('ColorPropType');
const NativeMethodsMixin = require('NativeMethodsMixin');
const Platform = require('Platform');
const ProgressBarAndroid = require('ProgressBarAndroid');
const PropTypes = require('prop-types');
const React = require('React');
const PropTypes = require('prop-types');
const StyleSheet = require('StyleSheet');
const View = require('View');
const ViewPropTypes = require('ViewPropTypes');
@ -136,20 +135,16 @@ const ActivityIndicator = createReactClass({
break;
}
const nativeProps = {
...props,
style: sizeStyle,
styleAttr: 'Normal',
indeterminate: true,
};
return (
<View onLayout={onLayout} style={[styles.container, style]}>
{Platform.OS === 'ios' ? (
<RCTActivityIndicator {...nativeProps} />
) : (
<ProgressBarAndroid {...nativeProps} />
)}
<View
onLayout={onLayout}
style={[styles.container, style]}>
<RCTActivityIndicator
{...props}
style={sizeStyle}
styleAttr="Normal"
indeterminate
/>
</View>
);
}
@ -174,7 +169,18 @@ if (Platform.OS === 'ios') {
var RCTActivityIndicator = requireNativeComponent(
'RCTActivityIndicatorView',
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,
}},
);
}

View File

@ -17,8 +17,6 @@ const React = require('React');
const ReactNative = require('ReactNative');
const ViewPropTypes = require('ViewPropTypes');
const requireNativeComponent = require('requireNativeComponent');
const STYLE_ATTRIBUTES = [
'Horizontal',
'Normal',
@ -80,10 +78,6 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
* - LargeInverse
*/
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
* can only be false if styleAttr is Horizontal.
@ -105,8 +99,7 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
static defaultProps = {
styleAttr: 'Normal',
indeterminate: true,
animating: true,
indeterminate: true
};
componentDidMount() {
@ -119,18 +112,8 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
}
render() {
return <AndroidProgressBar {...this.props} />;
return <ActivityIndicator {...this.props} animating={true} />;
}
}
const AndroidProgressBar = requireNativeComponent(
'AndroidProgressBar',
ProgressBarAndroid,
{
nativeOnly: {
animating: true,
},
}
);
module.exports = ProgressBarAndroid;