Skip to content

Commit

Permalink
Fix Android border clip check (#37828)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gabrieldonadel authored and kelset committed Jun 13, 2023
1 parent 2760042 commit 2d15f50
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,28 @@ private void updatePath() {
int colorRight = getBorderColor(Spacing.RIGHT);
int colorBottom = getBorderColor(Spacing.BOTTOM);
int borderColor = getBorderColor(Spacing.ALL);

int colorBlock = getBorderColor(Spacing.BLOCK);
int colorBlockStart = getBorderColor(Spacing.BLOCK_START);
int colorBlockEnd = getBorderColor(Spacing.BLOCK_END);

if (isBorderColorDefined(Spacing.BLOCK)) {
colorBottom = colorBlock;
colorTop = colorBlock;
}
if (isBorderColorDefined(Spacing.BLOCK_END)) {
colorBottom = colorBlockEnd;
}
if (isBorderColorDefined(Spacing.BLOCK_START)) {
colorTop = colorBlockStart;
}

// Clip border ONLY if its color is non transparent
if (Color.alpha(colorLeft) != 0
&& Color.alpha(colorTop) != 0
&& Color.alpha(colorRight) != 0
&& Color.alpha(colorBottom) != 0
&& Color.alpha(borderColor) != 0
&& Color.alpha(colorBlock) != 0
&& Color.alpha(colorBlockStart) != 0
&& Color.alpha(colorBlockEnd) != 0) {
&& Color.alpha(borderColor) != 0) {

mInnerClipTempRectForBorderRadius.top += borderWidth.top;
mInnerClipTempRectForBorderRadius.bottom -= borderWidth.bottom;
Expand Down

0 comments on commit 2d15f50

Please sign in to comment.