@@ -214,6 +214,29 @@ protected Object getValueOrDefault(Object value, Context context) {
214214 }
215215 }
216216
217+ private static class NullableColorPropSetter extends PropSetter {
218+
219+ private final int mDefaultValue ;
220+
221+ public NullableColorPropSetter (ReactProp prop , Method setter ) {
222+ this (prop , setter , 0 );
223+ }
224+
225+ public NullableColorPropSetter (ReactProp prop , Method setter , int defaultValue ) {
226+ super (prop , "mixed" , setter );
227+ mDefaultValue = defaultValue ;
228+ }
229+
230+ @ Override
231+ protected Object getValueOrDefault (Object value , Context context ) {
232+ if (value == null ) {
233+ return null ;
234+ }
235+
236+ return ColorPropConverter .getColor (value , context );
237+ }
238+ }
239+
217240 private static class BooleanPropSetter extends PropSetter {
218241
219242 private final boolean mDefaultValue ;
@@ -407,6 +430,9 @@ private static PropSetter createPropSetter(
407430 if ("Color" .equals (annotation .customType ())) {
408431 return new ColorPropSetter (annotation , method , annotation .defaultInt ());
409432 }
433+ if ("NullableColor" .equals (annotation .customType ())) {
434+ return new NullableColorPropSetter (annotation , method , annotation .defaultInt ());
435+ }
410436 return new IntPropSetter (annotation , method , annotation .defaultInt ());
411437 } else if (propTypeClass == float .class ) {
412438 return new FloatPropSetter (annotation , method , annotation .defaultFloat ());
@@ -420,6 +446,9 @@ private static PropSetter createPropSetter(
420446 if ("Color" .equals (annotation .customType ())) {
421447 return new ColorPropSetter (annotation , method );
422448 }
449+ if ("NullableColor" .equals (annotation .customType ())) {
450+ return new NullableColorPropSetter (annotation , method , annotation .defaultInt ());
451+ }
423452 return new BoxedIntPropSetter (annotation , method );
424453 } else if (propTypeClass == ReadableArray .class ) {
425454 return new ArrayPropSetter (annotation , method );
0 commit comments