in litho-editor-flipper/src/main/java/com/facebook/litho/editor/flipper/DebugComponentDescriptor.java [294:423]
private static FlipperObject getLayoutData(DebugComponent node) {
final DebugLayoutNode layout = node.getLayoutNode();
if (layout == null) {
return null;
}
final FlipperObject.Builder data = new FlipperObject.Builder();
data.put("<PLAYGROUND>", InspectorValue.immutable("https://yogalayout.com/playground/"));
data.put("background", DataUtils.fromDrawable(layout.getBackground()));
data.put("foreground", DataUtils.fromDrawable(layout.getForeground()));
data.put(
"direction",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaDirection.values()), layout.getLayoutDirection().name())));
data.put(
"flex-direction",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaFlexDirection.values()), layout.getFlexDirection().name())));
data.put(
"justify-content",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaJustify.values()), layout.getJustifyContent().name())));
data.put(
"align-items",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaAlign.values()), layout.getAlignItems().name())));
data.put(
"align-self",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaAlign.values()), layout.getAlignSelf().name())));
data.put(
"align-content",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaAlign.values()), layout.getAlignContent().name())));
data.put(
"position-type",
InspectorValue.mutable(
Picker,
new InspectorValue.Picker(
enumToSet(YogaPositionType.values()), layout.getPositionType().name())));
data.put("flex-grow", fromFloat(layout.getFlexGrow()));
data.put("flex-shrink", fromFloat(layout.getFlexShrink()));
data.put("flex-basis", fromYogaValue(layout.getFlexBasis()));
data.put("width", fromYogaValue(layout.getWidth()));
data.put("min-width", fromYogaValue(layout.getMinWidth()));
data.put("max-width", fromYogaValue(layout.getMaxWidth()));
data.put("height", fromYogaValue(layout.getHeight()));
data.put("min-height", fromYogaValue(layout.getMinHeight()));
data.put("max-height", fromYogaValue(layout.getMaxHeight()));
data.put("aspect-ratio", fromFloat(layout.getAspectRatio()));
data.put(
"margin",
new FlipperObject.Builder()
.put("left", fromYogaValue(layout.getMargin(YogaEdge.LEFT)))
.put("top", fromYogaValue(layout.getMargin(YogaEdge.TOP)))
.put("right", fromYogaValue(layout.getMargin(YogaEdge.RIGHT)))
.put("bottom", fromYogaValue(layout.getMargin(YogaEdge.BOTTOM)))
.put("start", fromYogaValue(layout.getMargin(YogaEdge.START)))
.put("end", fromYogaValue(layout.getMargin(YogaEdge.END)))
.put("horizontal", fromYogaValue(layout.getMargin(YogaEdge.HORIZONTAL)))
.put("vertical", fromYogaValue(layout.getMargin(YogaEdge.VERTICAL)))
.put("all", fromYogaValue(layout.getMargin(YogaEdge.ALL))));
data.put(
"padding",
new FlipperObject.Builder()
.put("left", fromYogaValue(layout.getPadding(YogaEdge.LEFT)))
.put("top", fromYogaValue(layout.getPadding(YogaEdge.TOP)))
.put("right", fromYogaValue(layout.getPadding(YogaEdge.RIGHT)))
.put("bottom", fromYogaValue(layout.getPadding(YogaEdge.BOTTOM)))
.put("start", fromYogaValue(layout.getPadding(YogaEdge.START)))
.put("end", fromYogaValue(layout.getPadding(YogaEdge.END)))
.put("horizontal", fromYogaValue(layout.getPadding(YogaEdge.HORIZONTAL)))
.put("vertical", fromYogaValue(layout.getPadding(YogaEdge.VERTICAL)))
.put("all", fromYogaValue(layout.getPadding(YogaEdge.ALL))));
data.put(
"border",
new FlipperObject.Builder()
.put("left", fromFloat(layout.getBorderWidth(YogaEdge.LEFT)))
.put("top", fromFloat(layout.getBorderWidth(YogaEdge.TOP)))
.put("right", fromFloat(layout.getBorderWidth(YogaEdge.RIGHT)))
.put("bottom", fromFloat(layout.getBorderWidth(YogaEdge.BOTTOM)))
.put("start", fromFloat(layout.getBorderWidth(YogaEdge.START)))
.put("end", fromFloat(layout.getBorderWidth(YogaEdge.END)))
.put("horizontal", fromFloat(layout.getBorderWidth(YogaEdge.HORIZONTAL)))
.put("vertical", fromFloat(layout.getBorderWidth(YogaEdge.VERTICAL)))
.put("all", fromFloat(layout.getBorderWidth(YogaEdge.ALL))));
data.put(
"position",
new FlipperObject.Builder()
.put("left", fromYogaValue(layout.getPosition(YogaEdge.LEFT)))
.put("top", fromYogaValue(layout.getPosition(YogaEdge.TOP)))
.put("right", fromYogaValue(layout.getPosition(YogaEdge.RIGHT)))
.put("bottom", fromYogaValue(layout.getPosition(YogaEdge.BOTTOM)))
.put("start", fromYogaValue(layout.getPosition(YogaEdge.START)))
.put("end", fromYogaValue(layout.getPosition(YogaEdge.END)))
.put("horizontal", fromYogaValue(layout.getPosition(YogaEdge.HORIZONTAL)))
.put("vertical", fromYogaValue(layout.getPosition(YogaEdge.VERTICAL)))
.put("all", fromYogaValue(layout.getPosition(YogaEdge.ALL))));
data.put("hasViewOutput", InspectorValue.immutable(Boolean, layout.hasViewOutput()));
if (layout.hasViewOutput()) {
data.put("alpha", fromFloat(layout.getAlpha()));
data.put("scale", fromFloat(layout.getScale()));
data.put("rotation", fromFloat(layout.getRotation()));
}
return data.build();
}