mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
Fabric: Complete implementation of layoutMetricsFromYogaNode
Summary: That was simply incomplete. Reviewed By: fkgozali Differential Revision: D7330336 fbshipit-source-id: c495c7f61d8e551fa963bfa6cc0408343eb8439b
This commit is contained in:
parent
a5a34565e0
commit
ff288b7416
@ -15,10 +15,18 @@ namespace facebook {
|
|||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
Float fabricFloatFromYogaFloat(float value) {
|
Float fabricFloatFromYogaFloat(float value) {
|
||||||
|
if (value == YGUndefined) {
|
||||||
|
return Undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return (Float)value;
|
return (Float)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float yogaFloatFromFabricFloat(Float value) {
|
float yogaFloatFromFabricFloat(Float value) {
|
||||||
|
if (value == Undefined) {
|
||||||
|
return YGUndefined;
|
||||||
|
}
|
||||||
|
|
||||||
return (float)value;
|
return (float)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,11 +52,35 @@ LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) {
|
|||||||
YGLayout layout = yogaNode.getLayout();
|
YGLayout layout = yogaNode.getLayout();
|
||||||
|
|
||||||
layoutMetrics.frame = Rect {
|
layoutMetrics.frame = Rect {
|
||||||
Point {fabricFloatFromYogaFloat(layout.position[0]), fabricFloatFromYogaFloat(layout.position[1])},
|
Point {
|
||||||
Size {fabricFloatFromYogaFloat(layout.dimensions[0]), fabricFloatFromYogaFloat(layout.dimensions[1])}
|
fabricFloatFromYogaFloat(layout.position[YGEdgeLeft]),
|
||||||
|
fabricFloatFromYogaFloat(layout.position[YGEdgeTop])
|
||||||
|
},
|
||||||
|
Size {
|
||||||
|
fabricFloatFromYogaFloat(layout.dimensions[YGDimensionWidth]),
|
||||||
|
fabricFloatFromYogaFloat(layout.dimensions[YGDimensionHeight])
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Add more.
|
layoutMetrics.borderWidth = EdgeInsets {
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeLeft]),
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeTop]),
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeRight]),
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeBottom])
|
||||||
|
};
|
||||||
|
|
||||||
|
layoutMetrics.contentInsets = EdgeInsets {
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeLeft] + layout.padding[YGEdgeLeft]),
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeTop] + layout.padding[YGEdgeTop]),
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeRight] + layout.padding[YGEdgeRight]),
|
||||||
|
fabricFloatFromYogaFloat(layout.border[YGEdgeBottom] + layout.padding[YGEdgeBottom])
|
||||||
|
};
|
||||||
|
|
||||||
|
layoutMetrics.displayType =
|
||||||
|
yogaNode.getStyle().display == YGDisplayNone ? None : Flex;
|
||||||
|
|
||||||
|
layoutMetrics.layoutDirection =
|
||||||
|
layout.direction == YGDirectionRTL ? RightToLeft : LeftToRight;
|
||||||
|
|
||||||
return layoutMetrics;
|
return layoutMetrics;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user