mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 14:13:26 +00:00
Expose layout border to java
Reviewed By: astreet Differential Revision: D4543284 fbshipit-source-id: 6030915fc6f758e785a688f94c8ffbec7fbac8b8
This commit is contained in:
parent
aac7b19a7c
commit
21475e58b3
@ -86,6 +86,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
@DoNotStrip
|
||||
private float mPaddingBottom = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderLeft = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderTop = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderRight = 0;
|
||||
@DoNotStrip
|
||||
private float mBorderBottom = 0;
|
||||
@DoNotStrip
|
||||
private int mLayoutDirection = 0;
|
||||
|
||||
private native long jni_YGNodeNew();
|
||||
@ -633,6 +641,26 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutBorder(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return mBorderLeft;
|
||||
case TOP:
|
||||
return mBorderTop;
|
||||
case RIGHT:
|
||||
return mBorderRight;
|
||||
case BOTTOM:
|
||||
return mBorderBottom;
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mBorderRight : mBorderLeft;
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mBorderLeft : mBorderRight;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaDirection getLayoutDirection() {
|
||||
return YogaDirection.fromInt(mLayoutDirection);
|
||||
|
@ -84,6 +84,7 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
|
||||
float getLayoutHeight();
|
||||
float getLayoutMargin(YogaEdge edge);
|
||||
float getLayoutPadding(YogaEdge edge);
|
||||
float getLayoutBorder(YogaEdge edge);
|
||||
YogaDirection getLayoutDirection();
|
||||
YogaOverflow getOverflow();
|
||||
void setOverflow(YogaOverflow overflow);
|
||||
|
@ -40,6 +40,11 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
static auto paddingRightField = obj->getClass()->getField<jfloat>("mPaddingRight");
|
||||
static auto paddingBottomField = obj->getClass()->getField<jfloat>("mPaddingBottom");
|
||||
|
||||
static auto borderLeftField = obj->getClass()->getField<jfloat>("mBorderLeft");
|
||||
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
||||
static auto borderRightField = obj->getClass()->getField<jfloat>("mBorderRight");
|
||||
static auto borderBottomField = obj->getClass()->getField<jfloat>("mBorderBottom");
|
||||
|
||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||
@ -55,6 +60,11 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||
obj->setFieldValue(paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||
|
||||
obj->setFieldValue(borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||
obj->setFieldValue(borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||
|
||||
YGTransferLayoutDirection(root, obj);
|
||||
|
||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user