Skip to content

Commit b60fa63

Browse files
Brian Vaughnfacebook-github-bot
authored andcommitted
Removed ProgressBarAndroid.android deprecation warning
Reviewed By: hramos Differential Revision: D6092598 fbshipit-source-id: 24282a923cf45e749cf33f8a5b7a49995e7fadfe
1 parent 30b057f commit b60fa63

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

Libraries/Components/ActivityIndicator/ActivityIndicator.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
const ColorPropType = require('ColorPropType');
1515
const NativeMethodsMixin = require('NativeMethodsMixin');
1616
const Platform = require('Platform');
17-
const React = require('React');
17+
const ProgressBarAndroid = require('ProgressBarAndroid');
1818
const PropTypes = require('prop-types');
19+
const React = require('React');
1920
const StyleSheet = require('StyleSheet');
2021
const View = require('View');
2122
const ViewPropTypes = require('ViewPropTypes');
@@ -135,16 +136,20 @@ const ActivityIndicator = createReactClass({
135136
break;
136137
}
137138

139+
const nativeProps = {
140+
...props,
141+
style: sizeStyle,
142+
styleAttr: 'Normal',
143+
indeterminate: true,
144+
};
145+
138146
return (
139-
<View
140-
onLayout={onLayout}
141-
style={[styles.container, style]}>
142-
<RCTActivityIndicator
143-
{...props}
144-
style={sizeStyle}
145-
styleAttr="Normal"
146-
indeterminate
147-
/>
147+
<View onLayout={onLayout} style={[styles.container, style]}>
148+
{Platform.OS === 'ios' ? (
149+
<RCTActivityIndicator {...nativeProps} />
150+
) : (
151+
<ProgressBarAndroid {...nativeProps} />
152+
)}
148153
</View>
149154
);
150155
}
@@ -169,18 +174,7 @@ if (Platform.OS === 'ios') {
169174
var RCTActivityIndicator = requireNativeComponent(
170175
'RCTActivityIndicatorView',
171176
ActivityIndicator,
172-
{nativeOnly: {activityIndicatorViewStyle: true}},
173-
);
174-
} else if (Platform.OS === 'android') {
175-
var RCTActivityIndicator = requireNativeComponent(
176-
'AndroidProgressBar',
177-
ActivityIndicator,
178-
// Ignore props that are specific to non inderterminate ProgressBar.
179-
{nativeOnly: {
180-
indeterminate: true,
181-
progress: true,
182-
styleAttr: true,
183-
}},
177+
{ nativeOnly: { activityIndicatorViewStyle: true } }
184178
);
185179
}
186180

Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
*/
1111
'use strict';
1212

13-
const ActivityIndicator = require('ActivityIndicator');
1413
const ColorPropType = require('ColorPropType');
1514
const PropTypes = require('prop-types');
1615
const React = require('React');
1716
const ReactNative = require('ReactNative');
1817
const ViewPropTypes = require('ViewPropTypes');
1918

19+
const requireNativeComponent = require('requireNativeComponent');
20+
2021
const STYLE_ATTRIBUTES = [
2122
'Horizontal',
2223
'Normal',
@@ -78,6 +79,10 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
7879
* - LargeInverse
7980
*/
8081
styleAttr: PropTypes.oneOf(STYLE_ATTRIBUTES),
82+
/**
83+
* Whether to show the ProgressBar (true, the default) or hide it (false).
84+
*/
85+
animating: PropTypes.bool,
8186
/**
8287
* If the progress bar will show indeterminate progress. Note that this
8388
* can only be false if styleAttr is Horizontal.
@@ -99,21 +104,23 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
99104

100105
static defaultProps = {
101106
styleAttr: 'Normal',
102-
indeterminate: true
107+
indeterminate: true,
108+
animating: true,
103109
};
104110

105-
componentDidMount() {
106-
if (this.props.indeterminate && this.props.styleAttr !== 'Horizontal') {
107-
console.warn(
108-
'Circular indeterminate `ProgressBarAndroid`' +
109-
'is deprecated. Use `ActivityIndicator` instead.'
110-
);
111-
}
112-
}
113-
114111
render() {
115-
return <ActivityIndicator {...this.props} animating={true} />;
112+
return <AndroidProgressBar {...this.props} />;
116113
}
117114
}
118115

116+
const AndroidProgressBar = requireNativeComponent(
117+
'AndroidProgressBar',
118+
ProgressBarAndroid,
119+
{
120+
nativeOnly: {
121+
animating: true,
122+
},
123+
}
124+
);
125+
119126
module.exports = ProgressBarAndroid;

0 commit comments

Comments
 (0)