Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Android/ColorProps: ColorProps with value null should be defaultColor instead of transparent #29830

Closed
wants to merge 12 commits into from
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,21 @@ public BoxedIntPropSetter(ReactPropGroup prop, Method setter, int index) {
}
}

private static class BoxedColorPropSetter extends PropSetter {

public BoxedColorPropSetter(ReactProp prop, Method setter) {
super(prop, "mixed", setter);
}

@Override
protected @Nullable Object getValueOrDefault(Object value, Context context) {
if (value != null) {
return ColorPropConverter.getColor(value, context);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google-java-format suggested changes:

@@ -337 +337 @@
-          return ColorPropConverter.getColor(value, context);
+        return ColorPropConverter.getColor(value, context);

}
return null;
}
}

/*package*/ static Map<String, String> getNativePropsForView(
Class<? extends ViewManager> viewManagerTopClass,
Class<? extends ReactShadowNode> shadowNodeTopClass) {
Expand Down Expand Up @@ -418,7 +433,7 @@ private static PropSetter createPropSetter(
return new BoxedBooleanPropSetter(annotation, method);
} else if (propTypeClass == Integer.class) {
if ("Color".equals(annotation.customType())) {
return new ColorPropSetter(annotation, method);
return new BoxedColorPropSetter(annotation, method);
}
return new BoxedIntPropSetter(annotation, method);
} else if (propTypeClass == ReadableArray.class) {
Expand Down