-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add source set for BorderRadiiDrawableUtils on 0.75
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...nPatch/BorderRadiiDrawableUtils/75/com/swmansion/reanimated/BorderRadiiDrawableUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.swmansion.reanimated; | ||
|
||
import android.graphics.drawable.Drawable; | ||
import android.view.View; | ||
import com.facebook.react.uimanager.LengthPercentage; | ||
import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable; | ||
import com.facebook.react.uimanager.style.ComputedBorderRadius; | ||
|
||
public class BorderRadiiDrawableUtils { | ||
public static ReactNativeUtils.BorderRadii getBorderRadii(View view) { | ||
Drawable background = view.getBackground(); | ||
if (background instanceof CSSBackgroundDrawable) { | ||
CSSBackgroundDrawable drawable = (CSSBackgroundDrawable) background; | ||
LengthPercentage uniform = drawable.getBorderRadius().getUniform(); | ||
float full = uniform != null ? uniform.resolve(view.getWidth(), view.getHeight()) : Float.NaN; | ||
ComputedBorderRadius computedBorderRadius = drawable.getComputedBorderRadius(); | ||
return new ReactNativeUtils.BorderRadii( | ||
full, | ||
computedBorderRadius.getTopLeft(), | ||
computedBorderRadius.getTopRight(), | ||
computedBorderRadius.getBottomLeft(), | ||
computedBorderRadius.getBottomRight()); | ||
} else { | ||
return new ReactNativeUtils.BorderRadii(0, 0, 0, 0, 0); | ||
} | ||
} | ||
} |