mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Expose layout paddding in java api
Reviewed By: passy Differential Revision: D4377069 fbshipit-source-id: 2e0c04104560e1be586562b27b3457576590dc18
This commit is contained in:
parent
d9c35e8952
commit
0cdda4d8d9
@ -69,6 +69,14 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
@DoNotStrip
|
||||
private float mLeft = YogaConstants.UNDEFINED;
|
||||
@DoNotStrip
|
||||
private float mPaddingLeft = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingTop = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingRight = 0;
|
||||
@DoNotStrip
|
||||
private float mPaddingBottom = 0;
|
||||
@DoNotStrip
|
||||
private int mLayoutDirection = 0;
|
||||
|
||||
private native long jni_YGNodeNew();
|
||||
@ -564,6 +572,26 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLayoutPadding(YogaEdge edge) {
|
||||
switch (edge) {
|
||||
case LEFT:
|
||||
return mPaddingLeft;
|
||||
case TOP:
|
||||
return mPaddingTop;
|
||||
case RIGHT:
|
||||
return mPaddingRight;
|
||||
case BOTTOM:
|
||||
return mPaddingBottom;
|
||||
case START:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mPaddingRight : mPaddingLeft;
|
||||
case END:
|
||||
return getLayoutDirection() == YogaDirection.RTL ? mPaddingLeft : mPaddingRight;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaDirection getLayoutDirection() {
|
||||
return YogaDirection.values()[mLayoutDirection];
|
||||
|
@ -81,6 +81,7 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
|
||||
float getLayoutY();
|
||||
float getLayoutWidth();
|
||||
float getLayoutHeight();
|
||||
float getLayoutPadding(YogaEdge edge);
|
||||
YogaDirection getLayoutDirection();
|
||||
YogaOverflow getOverflow();
|
||||
void setOverflow(YogaOverflow overflow);
|
||||
|
@ -30,10 +30,21 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
||||
|
||||
static auto paddingLeftField = obj->getClass()->getField<jfloat>("mPaddingLeft");
|
||||
static auto paddingTopField = obj->getClass()->getField<jfloat>("mPaddingTop");
|
||||
static auto paddingRightField = obj->getClass()->getField<jfloat>("mPaddingRight");
|
||||
static auto paddingBottomField = obj->getClass()->getField<jfloat>("mPaddingBottom");
|
||||
|
||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
||||
|
||||
obj->setFieldValue(paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||
obj->setFieldValue(paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||
obj->setFieldValue(paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||
|
||||
YGTransferLayoutDirection(root, obj);
|
||||
|
||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user