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

View File

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