Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,29 @@ protected Object getValueOrDefault(Object value, Context context) {
}
}

private static class NullableColorPropSetter extends PropSetter {

private final int mDefaultValue;

public NullableColorPropSetter(ReactProp prop, Method setter) {
this(prop, setter, 0);
}

public NullableColorPropSetter(ReactProp prop, Method setter, int defaultValue) {
super(prop, "mixed", setter);
mDefaultValue = defaultValue;
}

@Override
protected Object getValueOrDefault(Object value, Context context) {
if (value == null) {
return null;
}

return ColorPropConverter.getColor(value, context);
}
}

private static class BooleanPropSetter extends PropSetter {

private final boolean mDefaultValue;
Expand Down Expand Up @@ -407,6 +430,9 @@ private static PropSetter createPropSetter(
if ("Color".equals(annotation.customType())) {
return new ColorPropSetter(annotation, method, annotation.defaultInt());
}
if ("NullableColor".equals(annotation.customType())) {
return new NullableColorPropSetter(annotation, method, annotation.defaultInt());
}
return new IntPropSetter(annotation, method, annotation.defaultInt());
} else if (propTypeClass == float.class) {
return new FloatPropSetter(annotation, method, annotation.defaultFloat());
Expand All @@ -420,6 +446,9 @@ private static PropSetter createPropSetter(
if ("Color".equals(annotation.customType())) {
return new ColorPropSetter(annotation, method);
}
if ("NullableColor".equals(annotation.customType())) {
return new NullableColorPropSetter(annotation, method, annotation.defaultInt());
}
return new BoxedIntPropSetter(annotation, method);
} else if (propTypeClass == ReadableArray.class) {
return new ArrayPropSetter(annotation, method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void setLoadingIndicatorSource(ReactImageView view, @Nullable String sour
view.setLoadingIndicatorSource(source);
}

@ReactProp(name = "borderColor", customType = "Color")
@ReactProp(name = "borderColor", customType = "NullableColor")
public void setBorderColor(ReactImageView view, @Nullable Integer borderColor) {
if (borderColor == null) {
view.setBorderColor(Color.TRANSPARENT);
Expand All @@ -154,7 +154,7 @@ public void setBorderColor(ReactImageView view, @Nullable Integer borderColor) {
}
}

@ReactProp(name = "overlayColor", customType = "Color")
@ReactProp(name = "overlayColor", customType = "NullableColor")
public void setOverlayColor(ReactImageView view, @Nullable Integer overlayColor) {
if (overlayColor == null) {
view.setOverlayColor(Color.TRANSPARENT);
Expand Down Expand Up @@ -209,7 +209,7 @@ public void setResizeMethod(ReactImageView view, @Nullable String resizeMethod)
}
}

@ReactProp(name = "tintColor", customType = "Color")
@ReactProp(name = "tintColor", customType = "NullableColor")
public void setTintColor(ReactImageView view, @Nullable Integer tintColor) {
if (tintColor == null) {
view.clearColorFilter();
Expand Down