Update ReactPropertyProcessor to handle new color objects

Summary:
D19837753 updated the native platforms to support complex color objects however the diff failed to build when going through this code path (as we do at Facebook).

This updates the automatic PropSetter classes to go through the new Color handler.

Changelog:
[Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: mdvacca

Differential Revision: D20169335

fbshipit-source-id: 8eb9c8b48b1840832b3aec9ffcb83c3cf614ce0e
This commit is contained in:
Eli White
2020-03-02 15:07:50 -08:00
committed by Facebook Github Bot
parent 8643b5560e
commit ce0edca620
@@ -348,7 +348,7 @@ public class ReactPropertyProcessor extends AbstractProcessor {
if (BOXED_PRIMITIVES.contains(propertyInfo.propertyType)) {
builder.add("value == null ? null : ");
}
getPropertyExtractor(propertyInfo, builder);
getPropertyExtractor(info, propertyInfo, builder);
builder.addStatement(")");
builder.addStatement("break").unindent();
@@ -359,7 +359,7 @@ public class ReactPropertyProcessor extends AbstractProcessor {
}
private static CodeBlock.Builder getPropertyExtractor(
PropertyInfo info, CodeBlock.Builder builder) {
ClassInfo classInfo, PropertyInfo info, CodeBlock.Builder builder) {
TypeName propertyType = info.propertyType;
if (propertyType.equals(STRING_TYPE)) {
return builder.add("($L)value", STRING_TYPE);
@@ -394,7 +394,18 @@ public class ReactPropertyProcessor extends AbstractProcessor {
return builder.add("value == null ? $Lf : ((Double)value).floatValue()", defaultFloat);
}
}
if (propertyType.equals(TypeName.INT)) {
if ("Color".equals(info.mProperty.customType())) {
switch (classInfo.getType()) {
case VIEW_MANAGER:
return builder.add(
"$T.getColor(value, view.getContext())",
com.facebook.react.bridge.ColorPropConverter.class);
case SHADOW_NODE:
return builder.add(
"$T.getColor(value, node.getThemedContext())",
com.facebook.react.bridge.ColorPropConverter.class);
}
} else if (propertyType.equals(TypeName.INT)) {
return builder.add(
"value == null ? $L : ((Double)value).intValue()", info.mProperty.defaultInt());
}