From 63848bdde5459273d442635735f7a475bff8dbb5 Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Wed, 18 Oct 2017 12:46:43 -0700 Subject: [PATCH] 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 --- .../ActivityIndicator/ActivityIndicator.js | 38 +++++++++++-------- .../ProgressBarAndroid.android.js | 21 +--------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 3a47a3d8f4f9b3..1ed1a7ebcc3e2d 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -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 ( - - {Platform.OS === 'ios' ? ( - - ) : ( - - )} + + ); } @@ -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, + }}, ); } diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js index de5e0e52e35c40..21fc5185a611bd 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -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 ; + return ; } } -const AndroidProgressBar = requireNativeComponent( - 'AndroidProgressBar', - ProgressBarAndroid, - { - nativeOnly: { - animating: true, - }, - } -); - module.exports = ProgressBarAndroid;