react-native-macos/React/Views
Guilherme Iscaro 14b0ed4c5d Do not override ActivityIndicator color when setting its size (#25849)
Summary:
The activityIndicatorViewStyle property overrides the previous set color
if it's changed. Depending on the property set order you may end in a state
that the color property will never be respected since it first sets
the color and then the activityIndicatorViewStyle property (which overrides
the color property). In order to prevent this problem
before setting the new activityIndicatorViewStyle save the old
color and override it after activityIndicatorViewStyle is set. Thus
always respecting the user's color.

## Changelog

[iOS] [Fixed] - Do not override ActivityIndicator color when setting its size
Pull Request resolved: https://github.com/facebook/react-native/pull/25849

Test Plan:
Using the code below on iOS notice that the last ActivityIndicator will always have its color set to white while te testID is provided

### Without the patch
Notice the white -> blue transition when disabling the testID

![broken](https://user-images.githubusercontent.com/984610/61999339-16c2ed80-b095-11e9-80f7-81c38eca761a.gif)

### With the patch
Color remains unchanged

![working](https://user-images.githubusercontent.com/984610/61999338-1165a300-b095-11e9-9cb6-e45999db1544.gif)

```javascript
import React from "react";
import { View, StyleSheet, ActivityIndicator, Button } from "react-native";

const App = () => {
  const [enableTestID, onSetEnableTestID] = React.useState(true);
  const onPress = React.useCallback(() => {
    onSetEnableTestID(!enableTestID);
  }, [enableTestID]);
  return (
    <View style={styles.container}>
      <ActivityIndicator size="large" color="red" />
      <ActivityIndicator size="small" color="red" />
      <ActivityIndicator size="small" />
      <ActivityIndicator color="green" />
      <ActivityIndicator
        key={enableTestID.toString()}
        size="large"
        color="blue"
        testID={enableTestID ? 'please work' : undefined}
      />
      <Button
        title={enableTestID ? 'Disable testID' : 'enable testID'}
        onPress={onPress}
      />
    </View>
  );
};

export default App;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    justifyContent: "center",
    backgroundColor: "black"
  },
});

```

Closes https://github.com/facebook/react-native/issues/25319

Reviewed By: cpojer

Differential Revision: D16559929

Pulled By: sammy-SC

fbshipit-source-id: ac6fd572b9f91ee5a2cbe46f8c46c1f46a1ba8b3
2019-07-30 04:31:24 -07:00
..
SafeAreaView Fixes SafeAreaView when set emulateUnlessSupported on safeArea supported devices (#24615) 2019-04-29 10:02:58 -07:00
ScrollView Fix typos (#25770) 2019-07-23 03:23:11 -07:00
RCTActivityIndicatorView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTActivityIndicatorView.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTActivityIndicatorViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTActivityIndicatorViewManager.m Do not override ActivityIndicator color when setting its size (#25849) 2019-07-30 04:31:24 -07:00
RCTAnimationType.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTAutoInsetsProtocol.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBorderDrawing.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBorderDrawing.m Fix typos (#25770) 2019-07-23 03:23:11 -07:00
RCTBorderStyle.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTComponent.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTComponentData.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTComponentData.m BREAKING - RCTEvent improvements, remove deprecated [sendInputEventWithName:body:] (#15894) 2019-03-27 11:20:22 -07:00
RCTConvert+CoreLocation.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTConvert+CoreLocation.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTConvert+Transform.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTConvert+Transform.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTDatePicker.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTDatePicker.m Fixed minuteInterval invalid in time mode (#23923) 2019-03-15 11:34:20 -07:00
RCTDatePickerManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTDatePickerManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTFont.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTFont.mm Add ultrabold pairs for font weight (#24948) 2019-05-31 03:08:36 -07:00
RCTLayout.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTLayout.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTMaskedView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTMaskedView.m Fix xcode warnings (#23565) 2019-02-20 18:46:23 -08:00
RCTMaskedViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTMaskedViewManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModalHostView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModalHostView.m Removed autoresizing mask for modal host container view (#25150) 2019-06-05 05:02:52 -07:00
RCTModalHostViewController.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModalHostViewController.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModalHostViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTModalHostViewManager.m Fix onDismiss in Modal 2019-07-29 11:19:30 -07:00
RCTPicker.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTPicker.m Fix 50 xcode warnings (#23553) 2019-02-20 10:17:26 -08:00
RCTPickerManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTPickerManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTPointerEvents.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTProgressViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTProgressViewManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTRefreshControl.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTRefreshControl.m Fix setting the contentOffset value when refresh ends (#24191) 2019-04-01 12:54:36 -07:00
RCTRefreshControlManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTRefreshControlManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTRootShadowView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTRootShadowView.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSegmentedControl.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSegmentedControl.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSegmentedControlManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSegmentedControlManager.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTShadowView+Internal.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTShadowView+Internal.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTShadowView+Layout.h Fix typos (#25770) 2019-07-23 03:23:11 -07:00
RCTShadowView+Layout.m Fix typos (#25770) 2019-07-23 03:23:11 -07:00
RCTShadowView.h Back out "[RN][iOS] Remove definition of viewIsDescendantOf method in RN iOS code" 2019-07-10 20:56:39 -07:00
RCTShadowView.m Back out "[RN][iOS] Remove definition of viewIsDescendantOf method in RN iOS code" 2019-07-10 20:56:39 -07:00
RCTSlider.h Switch Slider onSlidingComplete event to a non-bubbling event on iOS to match Android 2019-05-16 10:51:07 -07:00
RCTSlider.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSliderManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSliderManager.m Switch Slider onSlidingComplete event to a non-bubbling event on iOS to match Android 2019-05-16 10:51:07 -07:00
RCTSwitch.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSwitch.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSwitchManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTSwitchManager.m Unify native props 2019-01-07 15:39:21 -08:00
RCTTVView.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTTVView.m Removed method call to RCTRootView::setReactPreferredFocusedView as ... (#21596) 2019-01-22 07:33:44 -08:00
RCTTextDecorationLineType.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTView.h Move accessibilityActions property to UIView+React (#25015) 2019-05-24 15:33:43 -07:00
RCTView.m Move accessibilityActions property to UIView+React (#25015) 2019-05-24 15:33:43 -07:00
RCTViewManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTViewManager.m Fix typos (#25770) 2019-07-23 03:23:11 -07:00
RCTWrapperViewController.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTWrapperViewController.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
UIView+Private.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
UIView+React.h Fix typos (#25770) 2019-07-23 03:23:11 -07:00
UIView+React.m Fix typos (#25770) 2019-07-23 03:23:11 -07:00