Skip to content

Commit 265af22

Browse files
axinvdfacebook-github-bot
authored andcommitted
Fix android platform border color (#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: #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
1 parent f40bb93 commit 265af22

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

+19-2
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) {
@@ -468,7 +477,11 @@ private static void createPropSetters(
468477
}
469478
} else if (propTypeClass == int.class) {
470479
for (int i = 0; i < names.length; i++) {
471-
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
480+
if ("Color".equals(annotation.customType())) {
481+
props.put(names[i], new ColorPropSetter(annotation, method, i, annotation.defaultInt()));
482+
} else {
483+
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
484+
}
472485
}
473486
} else if (propTypeClass == float.class) {
474487
for (int i = 0; i < names.length; i++) {
@@ -481,7 +494,11 @@ private static void createPropSetters(
481494
}
482495
} else if (propTypeClass == Integer.class) {
483496
for (int i = 0; i < names.length; i++) {
484-
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
497+
if ("Color".equals(annotation.customType())) {
498+
props.put(names[i], new BoxedColorPropSetter(annotation, method, i));
499+
} else {
500+
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
501+
}
485502
}
486503
} else {
487504
throw new RuntimeException(

0 commit comments

Comments
 (0)