Skip to content

Commit

Permalink
Revert D6080118: [react-native][PR] Delegate to ProgressBarAndroid fr…
Browse files Browse the repository at this point in the history
…om ActivityIndicator on Android, instead of the other way around

Differential Revision: D6080118

fbshipit-source-id: efd75bbcc07de084213d3791520006090001364d
  • Loading branch information
jingc authored and facebook-github-bot committed Oct 18, 2017
1 parent c1223c5 commit 63848bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 35 deletions.
38 changes: 22 additions & 16 deletions Libraries/Components/ActivityIndicator/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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>
);
}
Expand All @@ -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,
}},
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.
Expand All @@ -105,8 +99,7 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {

static defaultProps = {
styleAttr: 'Normal',
indeterminate: true,
animating: true,
indeterminate: true
};

componentDidMount() {
Expand All @@ -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;

2 comments on commit 63848bd

@brentvatne
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this reverted due to warnings when using ActivityIndicator on Android? there was a follow-up PR to fix that, if so: #16455

cc @bvaughn @ide

@bvaughn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brentvatne see these comments: #16435 (comment)

tl;dr - It's been re-added, with the deprecation removed. (Already landed internally, should sync to GitHub soon)

Please sign in to comment.