Skip to content

Commit

Permalink
fix(android): box shadow and border radius white border resolution (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vallemar committed Mar 17, 2023
1 parent 7eaafa5 commit ea45758
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Binary file modified packages/core/platforms/android/widgets-release.aar
Binary file not shown.
Expand Up @@ -43,12 +43,19 @@ public BoxShadowDrawable(Drawable wrappedDrawable, String value) {
Log.d(TAG, "Constructing BoxShadowDrawable!");

this.shadowLayer = new ShapeDrawable(new RectShape());
this.overlayLayer = this.createOverlayLayer();
this.wrappedLayer = wrappedDrawable;

if(shouldHideOverlayLayer()) {
this.overlayLayer = null;
} else {
this.overlayLayer = this.createOverlayLayer();
}

// add our layers
this.addLayer(shadowLayer);
this.addLayer(overlayLayer);
if(this.overlayLayer != null) {
this.addLayer(overlayLayer);
}
this.addLayer(wrappedLayer);

this.setValue(value);
Expand Down Expand Up @@ -100,7 +107,9 @@ public void setValue(String value) {
if (!Arrays.equals(outerRadius, currentCornerRadii)) {
Log.d(TAG, "Update layer shape");
shadowLayer.setShape(new RoundRectShape(outerRadius, null, null));
overlayLayer.setShape(new RoundRectShape(outerRadius, null, null));
if(overlayLayer != null) {
overlayLayer.setShape(new RoundRectShape(outerRadius, null, null));
}

// update current
currentCornerRadii = outerRadius;
Expand Down Expand Up @@ -148,6 +157,17 @@ private ShapeDrawable createOverlayLayer() {
return shapeDrawable;
}

private boolean shouldHideOverlayLayer() {
if (wrappedLayer instanceof BorderDrawable) {
BorderDrawable bd = (BorderDrawable) this.wrappedLayer;
if (bd.getBackgroundColor() != 0 || bd.getBackgroundBitmap() != null || bd.getBackgroundGradient() != null) {
return true;
}
}

return false;
}

@Override
public String toString() {
return "BoxShadowDrawable { oX:" + offsetX + " oY:" + offsetY + " br:" + blurRadius + " sr:" + spreadRadius + " c:" + shadowColor + " }";
Expand Down

0 comments on commit ea45758

Please sign in to comment.