Skip to content

Commit 61ebbda

Browse files
axinvdmajkpal
authored andcommitted
Fix android platform border color (facebook#39893)
Summary: If you try to apply PlatformColor to borders on Android app will crash with the next error: "Error while updating property 'borderColor' of a view managed by: RCTView" ## Changelog: [ANDROID] [FIXED] - Fix android crash when apply PlatformColor to borders Pull Request resolved: facebook#39893 Test Plan: In RNTester example, go to APIs -> PlatformColor | Before | After | | ----------- | ----------- | | <img src="https://github.com/facebook/react-native/assets/70860930/66ac2880-53da-4438-bd9a-332f8ea40645" alt="drawing" width="200"/> | <img src="https://github.com/facebook/react-native/assets/70860930/151f58a1-d857-4b3d-9ec6-de74eb065127" alt="drawing" width="200"/> | Reviewed By: NickGerleman Differential Revision: D50011758 Pulled By: javache fbshipit-source-id: ea06c18c6aef4b6731e9b9b87422a1e0d13de208 (cherry picked from commit 265af22)
1 parent 3a4d79e commit 61ebbda

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ public ColorPropSetter(ReactProp prop, Method setter, int defaultValue) {
204204
mDefaultValue = defaultValue;
205205
}
206206

207+
public ColorPropSetter(ReactPropGroup prop, Method setter, int index, int defaultValue) {
208+
super(prop, "mixed", setter, index);
209+
mDefaultValue = defaultValue;
210+
}
211+
207212
@Override
208213
protected Object getValueOrDefault(Object value, Context context) {
209214
if (value == null) {
@@ -331,6 +336,10 @@ public BoxedColorPropSetter(ReactProp prop, Method setter) {
331336
super(prop, "mixed", setter);
332337
}
333338

339+
public BoxedColorPropSetter(ReactPropGroup prop, Method setter, int index) {
340+
super(prop, "mixed", setter, index);
341+
}
342+
334343
@Override
335344
protected @Nullable Object getValueOrDefault(Object value, Context context) {
336345
if (value != null) {
@@ -463,7 +472,11 @@ private static void createPropSetters(
463472
}
464473
} else if (propTypeClass == int.class) {
465474
for (int i = 0; i < names.length; i++) {
466-
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
475+
if ("Color".equals(annotation.customType())) {
476+
props.put(names[i], new ColorPropSetter(annotation, method, i, annotation.defaultInt()));
477+
} else {
478+
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
479+
}
467480
}
468481
} else if (propTypeClass == float.class) {
469482
for (int i = 0; i < names.length; i++) {
@@ -476,7 +489,11 @@ private static void createPropSetters(
476489
}
477490
} else if (propTypeClass == Integer.class) {
478491
for (int i = 0; i < names.length; i++) {
479-
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
492+
if ("Color".equals(annotation.customType())) {
493+
props.put(names[i], new BoxedColorPropSetter(annotation, method, i));
494+
} else {
495+
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
496+
}
480497
}
481498
} else {
482499
throw new RuntimeException(

0 commit comments

Comments
 (0)