Skip to content

Commit

Permalink
Fix android platform border color (#39893)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
axinvd authored and facebook-github-bot committed Oct 11, 2023
1 parent f40bb93 commit 265af22
Showing 1 changed file with 19 additions and 2 deletions.
Expand Up @@ -204,6 +204,11 @@ public ColorPropSetter(ReactProp prop, Method setter, int defaultValue) {
mDefaultValue = defaultValue;
}

public ColorPropSetter(ReactPropGroup prop, Method setter, int index, int defaultValue) {
super(prop, "mixed", setter, index);
mDefaultValue = defaultValue;
}

@Override
protected Object getValueOrDefault(Object value, Context context) {
if (value == null) {
Expand Down Expand Up @@ -331,6 +336,10 @@ public BoxedColorPropSetter(ReactProp prop, Method setter) {
super(prop, "mixed", setter);
}

public BoxedColorPropSetter(ReactPropGroup prop, Method setter, int index) {
super(prop, "mixed", setter, index);
}

@Override
protected @Nullable Object getValueOrDefault(Object value, Context context) {
if (value != null) {
Expand Down Expand Up @@ -468,7 +477,11 @@ private static void createPropSetters(
}
} else if (propTypeClass == int.class) {
for (int i = 0; i < names.length; i++) {
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
if ("Color".equals(annotation.customType())) {
props.put(names[i], new ColorPropSetter(annotation, method, i, annotation.defaultInt()));
} else {
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
}
}
} else if (propTypeClass == float.class) {
for (int i = 0; i < names.length; i++) {
Expand All @@ -481,7 +494,11 @@ private static void createPropSetters(
}
} else if (propTypeClass == Integer.class) {
for (int i = 0; i < names.length; i++) {
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
if ("Color".equals(annotation.customType())) {
props.put(names[i], new BoxedColorPropSetter(annotation, method, i));
} else {
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
}
}
} else {
throw new RuntimeException(
Expand Down

0 comments on commit 265af22

Please sign in to comment.