Skip to content

Commit

Permalink
Update ReactPropertyProcessor to handle new color objects
Browse files Browse the repository at this point in the history
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
  • Loading branch information
elicwhite authored and facebook-github-bot committed Mar 2, 2020
1 parent 8643b55 commit ce0edca
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private static CodeBlock generateSetProperty(ClassInfo info, List<PropertyInfo>
if (BOXED_PRIMITIVES.contains(propertyInfo.propertyType)) {
builder.add("value == null ? null : ");
}
getPropertyExtractor(propertyInfo, builder);
getPropertyExtractor(info, propertyInfo, builder);
builder.addStatement(")");

builder.addStatement("break").unindent();
Expand All @@ -359,7 +359,7 @@ private static CodeBlock generateSetProperty(ClassInfo info, List<PropertyInfo>
}

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);
Expand Down Expand Up @@ -394,7 +394,18 @@ private static CodeBlock.Builder getPropertyExtractor(
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());
}
Expand Down

0 comments on commit ce0edca

Please sign in to comment.