From e10c222dee78ef7ff9ba082db22efe204b9c49ac Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Tue, 10 Aug 2021 11:29:10 -0700 Subject: [PATCH] hook up PlatformColorParser to RCTPlatformColorUtils Summary: Changelog: [Internal] in this diff, we iterate through the list of color passed down in the props, and write the RGBA value of the first valid UIColor Reviewed By: sammy-SC Differential Revision: D30110297 fbshipit-source-id: c6730110129d0fe1f784fa89cd26b46d3dda7f28 --- .../graphics/platform/ios/PlatformColorParser.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h b/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h index ad512693369..3437b280760 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h +++ b/ReactCommon/react/renderer/graphics/platform/ios/PlatformColorParser.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -17,13 +18,16 @@ namespace react { inline ColorComponents parsePlatformColor( const PropsParserContext &context, const RawValue &value) { - // TODO T87791134: implement parsing of PlatformColor for iOS - float alpha = 0; - float red = 0; - float green = 0; - float blue = 0; + if (value.hasType>()) { + auto items = (better::map)value; + if (items.find("semantic") != items.end() && + items.at("semantic").hasType>()) { + auto semanticItems = (std::vector)items.at("semantic"); + return RCTPlatformColorComponentsFromSemanticItems(semanticItems); + } + } - return {red, green, blue, alpha}; + return {0, 0, 0, 0}; } } // namespace react