Skip to content

Commit 2d15f50

Browse files
gabrieldonadelkelset
authored andcommitted
Fix Android border clip check (#37828)
Summary: Instead of requiring all types of border color values to be present we should only take into consideration the left, top, right, bottom, and allEdges values and inject block values into colorBottom and colorTop. This PR only addresses the first issue described here (#37753 (comment)) by kelset ## Changelog: [ANDROID] [FIXED] - Fix border clip check Pull Request resolved: #37828 Test Plan: Test through rn-tester if border color is being applied <img width="482" alt="image" src="https://github.com/facebook/react-native/assets/11707729/c8c8772c-da8d-4393-bc3f-5868eca5df15"> Reviewed By: lunaleaps Differential Revision: D46643773 Pulled By: cipolleschi fbshipit-source-id: efb1ea81bf2462c14767a2554880eb7c44989975
1 parent 2760042 commit 2d15f50

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,19 +567,28 @@ private void updatePath() {
567567
int colorRight = getBorderColor(Spacing.RIGHT);
568568
int colorBottom = getBorderColor(Spacing.BOTTOM);
569569
int borderColor = getBorderColor(Spacing.ALL);
570+
570571
int colorBlock = getBorderColor(Spacing.BLOCK);
571572
int colorBlockStart = getBorderColor(Spacing.BLOCK_START);
572573
int colorBlockEnd = getBorderColor(Spacing.BLOCK_END);
573574

575+
if (isBorderColorDefined(Spacing.BLOCK)) {
576+
colorBottom = colorBlock;
577+
colorTop = colorBlock;
578+
}
579+
if (isBorderColorDefined(Spacing.BLOCK_END)) {
580+
colorBottom = colorBlockEnd;
581+
}
582+
if (isBorderColorDefined(Spacing.BLOCK_START)) {
583+
colorTop = colorBlockStart;
584+
}
585+
574586
// Clip border ONLY if its color is non transparent
575587
if (Color.alpha(colorLeft) != 0
576588
&& Color.alpha(colorTop) != 0
577589
&& Color.alpha(colorRight) != 0
578590
&& Color.alpha(colorBottom) != 0
579-
&& Color.alpha(borderColor) != 0
580-
&& Color.alpha(colorBlock) != 0
581-
&& Color.alpha(colorBlockStart) != 0
582-
&& Color.alpha(colorBlockEnd) != 0) {
591+
&& Color.alpha(borderColor) != 0) {
583592

584593
mInnerClipTempRectForBorderRadius.top += borderWidth.top;
585594
mInnerClipTempRectForBorderRadius.bottom -= borderWidth.bottom;

0 commit comments

Comments
 (0)