From b7167c23fc052f8d9f8c27a7f4ad9c5cdf51281e Mon Sep 17 00:00:00 2001 From: simek Date: Mon, 12 Oct 2020 02:12:44 -0700 Subject: [PATCH] PlatformColors: add missing clearColor for iOS (#30054) Summary: This small PR adds missing [`clearColor`](https://developer.apple.com/documentation/uikit/uicolor/1621945-clearcolor?language=objc) to the avaiable PlatformColors on iOS. **Please let me know** if you would like to see ["Fixed colors"](https://developer.apple.com/documentation/uikit/uicolor/standard_colors?language=objc) added to the `PlatformColors`. I can address this within this PR or create a separate one. ## Changelog [iOS] [Added] - PlatformColors: add missing `clearColor` Pull Request resolved: https://github.com/facebook/react-native/pull/30054 Test Plan: [(I had to disable the Dark Mode to fix the RNTester readability problems)](https://user-images.githubusercontent.com/719641/94453196-b35cb000-01b0-11eb-8d7d-73d48ceecf53.PNG) Transparent/clear color has been added to the RNTester PlatformColors API example: ![IMG_6782](https://user-images.githubusercontent.com/719641/94453172-ae97fc00-01b0-11eb-9bef-1a1a387ac009.PNG) Reviewed By: shergin Differential Revision: D24241160 Pulled By: sammy-SC fbshipit-source-id: 41fb51677329cc3b3f915d5d08694c07b4ef2cf3 --- React/Base/RCTConvert.m | 5 +++++ .../rn-tester/RNTesterUnitTests/RCTConvert_UIColorTests.m | 2 ++ .../js/examples/PlatformColor/PlatformColorExample.js | 2 ++ 3 files changed, 9 insertions(+) diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index 7ef3b233893ae9..af47b0d353ed1a 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -722,6 +722,11 @@ +(type)type : (id)json \ // iOS 13.0 RCTFallbackARGB : @(0xFFf2f2f7) }, + // Transparent Color + @"clearColor" : @{ + // iOS 13.0 + RCTFallbackARGB : @(0x00000000) + }, } mutableCopy]; // The color names are the Objective-C UIColor selector names, // but Swift selector names are valid as well, so make aliases. diff --git a/packages/rn-tester/RNTesterUnitTests/RCTConvert_UIColorTests.m b/packages/rn-tester/RNTesterUnitTests/RCTConvert_UIColorTests.m index fbb6824885a147..f58047b0af2ba4 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTConvert_UIColorTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTConvert_UIColorTests.m @@ -154,6 +154,8 @@ - (void)testGenerateFallbacks @"systemGray4Color": @(0xFFd1d1d6), @"systemGray5Color": @(0xFFe5e5ea), @"systemGray6Color": @(0xFFf2f2f7), + // Clear Color + @"clearColor": @(0x00000000), }; #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 diff --git a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js index cda369e62e1e76..345b609ac31b30 100644 --- a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js +++ b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js @@ -110,6 +110,8 @@ function PlatformColorsExample() { {label: 'systemGray4', color: PlatformColor('systemGray4')}, {label: 'systemGray5', color: PlatformColor('systemGray5')}, {label: 'systemGray6', color: PlatformColor('systemGray6')}, + // Transparent Color + {label: 'clear', color: PlatformColor('clear')}, ]; } else if (Platform.OS === 'android') { colors = [