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
This commit is contained in:
Phillip Pan
2021-08-10 11:30:58 -07:00
committed by Facebook GitHub Bot
parent df65dbb37f
commit e10c222dee
@@ -10,6 +10,7 @@
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/RawProps.h>
#include <react/renderer/graphics/ColorComponents.h>
#include <react/renderer/graphics/RCTPlatformColorUtils.h>
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<better::map<std::string, RawValue>>()) {
auto items = (better::map<std::string, RawValue>)value;
if (items.find("semantic") != items.end() &&
items.at("semantic").hasType<std::vector<std::string>>()) {
auto semanticItems = (std::vector<std::string>)items.at("semantic");
return RCTPlatformColorComponentsFromSemanticItems(semanticItems);
}
}
return {red, green, blue, alpha};
return {0, 0, 0, 0};
}
} // namespace react