Skip to content

Commit

Permalink
Fix invisible Android activity indicator (#33337)
Browse files Browse the repository at this point in the history
Apply a patch for the React Native `ActivityIndicator` rendering
invisible on Android. This applies the same patch that was previously
applied to the Embed block to to React Native itself.

The core issue in React Native appears to be [wider reaching](https://git.io/JcNlc), but I chose
to [limit the scope](https://git.io/JcNla) of the patch to the one issue we are currently
facing (i.e. invisible activity indicators), as I was concerned applying
a deeper, untested change introducing regressions elsewhere.
  • Loading branch information
dcalhoun authored Jul 12, 2021
1 parent e7566c7 commit 4f14d6d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/block-library/src/embed/embed-loading.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { ActivityIndicator, View, Platform, PlatformColor } from 'react-native';
import { ActivityIndicator, View } from 'react-native';

/**
* WordPress dependencies
Expand All @@ -19,16 +19,9 @@ const EmbedLoading = () => {
styles[ 'embed-preview__loading--dark' ]
);

const activityIndicatorColor = Platform.select( {
ios: '#999999', // default color on iOS
// ActivityIndicator is blank and does not show up unless explicit color prop is provided.
// See https://github.com/facebook/react-native/pull/30057
android: PlatformColor( '?attr/colorControlActivated' ),
} );

return (
<View style={ style }>
<ActivityIndicator animating color={ activityIndicatorColor } />
<ActivityIndicator animating />
</View>
);
};
Expand Down
25 changes: 25 additions & 0 deletions patches/react-native+0.64.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js
index 52cbda4..3e3b71e 100644
--- a/node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js
+++ b/node_modules/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js
@@ -14,6 +14,7 @@
const Platform = require('../../Utilities/Platform');
const React = require('react');
const StyleSheet = require('../../StyleSheet/StyleSheet');
+const {PlatformColor} = require('../../StyleSheet/PlatformColorValueTypes');
const View = require('../View/View');
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';
@@ -183,7 +184,11 @@ ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
* and run Flow. */
ActivityIndicatorWithRef.defaultProps = {
animating: true,
- color: Platform.OS === 'ios' ? GRAY : null,
+ color: Platform.select({
+ ios: GRAY,
+ android: PlatformColor('?attr/colorControlActivated'),
+ default: null,
+ }),
hidesWhenStopped: true,
size: 'small',
};

0 comments on commit 4f14d6d

Please sign in to comment.