Skip to content

Commit

Permalink
PlatformColors: add missing clearColor for iOS (#30054)
Browse files Browse the repository at this point in the history
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

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Added] - PlatformColors: add missing `clearColor`

Pull Request resolved: #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
  • Loading branch information
Simek authored and facebook-github-bot committed Oct 12, 2020
1 parent eb7701c commit b7167c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit b7167c2

Please sign in to comment.