From 1a1dfc158b23b86e193803a5f5733d0f13208ed7 Mon Sep 17 00:00:00 2001 From: David Calhoun <438664+dcalhoun@users.noreply.github.com> Date: Fri, 9 Jul 2021 15:41:48 -0500 Subject: [PATCH] Fix invisible Android activity indicator 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 4591a4a4998525..1c78054a06aa1e 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 00000000000000..a7ec48a1d341fc --- /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', + };