Add picker types for Yoga Layout values
Summary: This diff converts several flexbox properties to picker values Reviewed By: colriot Differential Revision: D23396217 fbshipit-source-id: 581a609a5e6da85c40d4a20c81f020e1832f2f4c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ee809fe112
commit
19b5b65081
@@ -10,6 +10,7 @@ package com.facebook.flipper.plugins.litho;
|
|||||||
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Boolean;
|
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Boolean;
|
||||||
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Enum;
|
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Enum;
|
||||||
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Number;
|
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Number;
|
||||||
|
import static com.facebook.flipper.plugins.inspector.InspectorValue.Type.Picker;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -40,6 +41,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -182,14 +184,48 @@ public class DebugComponentDescriptor extends NodeDescriptor<DebugComponent> {
|
|||||||
data.put("background", DataUtils.fromDrawable(layout.getBackground()));
|
data.put("background", DataUtils.fromDrawable(layout.getBackground()));
|
||||||
data.put("foreground", DataUtils.fromDrawable(layout.getForeground()));
|
data.put("foreground", DataUtils.fromDrawable(layout.getForeground()));
|
||||||
|
|
||||||
data.put("direction", InspectorValue.mutable(Enum, layout.getLayoutDirection().toString()));
|
|
||||||
data.put("flex-direction", InspectorValue.mutable(Enum, layout.getFlexDirection().toString()));
|
|
||||||
data.put(
|
data.put(
|
||||||
"justify-content", InspectorValue.mutable(Enum, layout.getJustifyContent().toString()));
|
"direction",
|
||||||
data.put("align-items", InspectorValue.mutable(Enum, layout.getAlignItems().toString()));
|
InspectorValue.mutable(
|
||||||
data.put("align-self", InspectorValue.mutable(Enum, layout.getAlignSelf().toString()));
|
Picker,
|
||||||
data.put("align-content", InspectorValue.mutable(Enum, layout.getAlignContent().toString()));
|
new InspectorValue.Picker(
|
||||||
data.put("position-type", InspectorValue.mutable(Enum, layout.getPositionType().toString()));
|
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-grow", fromFloat(layout.getFlexGrow()));
|
||||||
data.put("flex-shrink", fromFloat(layout.getFlexShrink()));
|
data.put("flex-shrink", fromFloat(layout.getFlexShrink()));
|
||||||
@@ -267,6 +303,14 @@ public class DebugComponentDescriptor extends NodeDescriptor<DebugComponent> {
|
|||||||
return data.build();
|
return data.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <E extends Enum<E>> HashSet<String> enumToSet(Enum<E>[] enums) {
|
||||||
|
final HashSet<String> names = new HashSet<>();
|
||||||
|
for (Enum<E> aEnum : enums) {
|
||||||
|
names.add(aEnum.name());
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static List<Named<FlipperObject>> getPropData(DebugComponent node) throws Exception {
|
private static List<Named<FlipperObject>> getPropData(DebugComponent node) throws Exception {
|
||||||
if (node.canResolve()) {
|
if (node.canResolve()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user