From 4f14d6dd996dcc487206a70a2fd4148b809fc947 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Mon, 12 Jul 2021 16:34:43 -0500 Subject: [PATCH] Fix invisible Android activity indicator (#33337) 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. --- .../src/embed/embed-loading.native.js | 11 ++------ patches/react-native+0.64.0.patch | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 patches/react-native+0.64.0.patch diff --git a/packages/block-library/src/embed/embed-loading.native.js b/packages/block-library/src/embed/embed-loading.native.js index 4591a4a499852..1c78054a06aa1 100644 --- a/packages/block-library/src/embed/embed-loading.native.js +++ b/packages/block-library/src/embed/embed-loading.native.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { ActivityIndicator, View, Platform, PlatformColor } from 'react-native'; +import { ActivityIndicator, View } from 'react-native'; /** * WordPress dependencies @@ -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 ( - + ); }; diff --git a/patches/react-native+0.64.0.patch b/patches/react-native+0.64.0.patch new file mode 100644 index 0000000000000..a7ec48a1d341f --- /dev/null +++ b/patches/react-native+0.64.0.patch @@ -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', + };