Skip to content

Commit

Permalink
add source set for BorderRadiiDrawableUtils on 0.75
Browse files Browse the repository at this point in the history
  • Loading branch information
jakex7 committed Sep 19, 2024
1 parent 3428f75 commit 0acae32
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/react-native-reanimated/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ android {
// BorderRadiiDrawableUtils
if (REACT_NATIVE_MINOR_VERSION <= 74) {
srcDirs += "src/reactNativeVersionPatch/BorderRadiiDrawableUtils/74"
} else if (REACT_NATIVE_MINOR_VERSION <= 75) {
srcDirs += "src/reactNativeVersionPatch/BorderRadiiDrawableUtils/75"
} else {
srcDirs += "src/reactNativeVersionPatch/BorderRadiiDrawableUtils/latest"
}
Expand Down
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);
}
}
}

0 comments on commit 0acae32

Please sign in to comment.