Simple antd types for each inspectable type

Summary:
Replace draft inspectors with read-only components.

This is a first step into having a richer UI. At the moment, these are read-only components but will likely be extended in the future as to allow editing of values.

Reviewed By: LukeDefeo

Differential Revision: D40345016

fbshipit-source-id: a6aef5861474b4aa8353c00ef257ab17b4cff00e
This commit is contained in:
Lorenzo Blasa
2022-10-25 03:09:00 -07:00
committed by Facebook GitHub Bot
parent 9721993576
commit bb3b1cecef
21 changed files with 1106 additions and 149 deletions

View File

@@ -9,7 +9,6 @@ package com.facebook.flipper.plugins.uidebugger.descriptors
import android.app.Activity
import com.facebook.flipper.plugins.uidebugger.core.FragmentTracker
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
object ActivityDescriptor : ChainedDescriptor<Activity>() {
@@ -27,9 +26,4 @@ object ActivityDescriptor : ChainedDescriptor<Activity>() {
return children
}
override fun onGetData(
node: Activity,
attributeSections: MutableMap<String, InspectableObject>
) {}
}

View File

@@ -26,7 +26,7 @@ object DrawableDescriptor : ChainedDescriptor<Drawable>() {
props["alpha"] = InspectableValue.Number(node.alpha, true)
val bounds = node.bounds
props["bounds"] = InspectableValue.SpaceBox(SpaceBox.fromRect(bounds))
props["bounds"] = InspectableValue.Bounds(Bounds.fromRect(bounds))
attributeSections["Drawable"] = InspectableObject(props.toMap())
}

View File

@@ -7,7 +7,6 @@
package com.facebook.flipper.plugins.uidebugger.descriptors
import android.os.Build
import android.os.Bundle
import com.facebook.flipper.plugins.uidebugger.model.Inspectable
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
@@ -26,19 +25,17 @@ object FragmentFrameworkDescriptor : ChainedDescriptor<android.app.Fragment>() {
node: android.app.Fragment,
attributeSections: MutableMap<String, InspectableObject>
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
val args: Bundle = node.arguments
val args: Bundle = node.arguments
val props = mutableMapOf<String, Inspectable>()
for (key in args.keySet()) {
when (val value = args[key]) {
is Number -> props[key] = InspectableValue.Number(value)
is Boolean -> props[key] = InspectableValue.Boolean(value)
is String -> props[key] = InspectableValue.Text(value)
}
val props = mutableMapOf<String, Inspectable>()
for (key in args.keySet()) {
when (val value = args[key]) {
is Number -> props[key] = InspectableValue.Number(value)
is Boolean -> props[key] = InspectableValue.Boolean(value)
is String -> props[key] = InspectableValue.Text(value)
}
attributeSections["Fragment"] = InspectableObject(props.toMap())
}
attributeSections["Fragment"] = InspectableObject(props.toMap())
}
}

View File

@@ -48,60 +48,44 @@ object ViewDescriptor : ChainedDescriptor<View>() {
) {
val props = mutableMapOf<String, Inspectable>()
props["size"] = InspectableValue.Size(Size(node.width, node.height), mutable = true)
props["alpha"] = InspectableValue.Number(node.alpha, mutable = true)
props["visibility"] = VisibilityMapping.toInspectable(node.visibility, mutable = false)
fromDrawable(node.background)?.let { background -> props["background"] = background }
node.tag
?.let { InspectableValue.fromAny(it, mutable = false) }
?.let { tag -> props.put("tag", tag) }
props["keyedTags"] = InspectableObject(getViewTags(node))
props["layoutParams"] = getLayoutParams(node)
props["state"] =
InspectableObject(
mapOf(
"enabled" to InspectableValue.Boolean(node.isEnabled, mutable = false),
"activated" to InspectableValue.Boolean(node.isActivated, mutable = false),
"focused" to InspectableValue.Boolean(node.isFocused, mutable = false),
"selected" to InspectableValue.Boolean(node.isSelected, mutable = false)))
props["bounds"] =
InspectableValue.SpaceBox(SpaceBox(node.top, node.right, node.bottom, node.left))
props["padding"] =
InspectableValue.SpaceBox(
SpaceBox(node.paddingTop, node.paddingRight, node.paddingBottom, node.paddingLeft))
props["rotation"] =
InspectableValue.Coordinate3D(Coordinate3D(node.rotationX, node.rotationY, node.rotation))
props["scale"] = InspectableValue.Coordinate(Coordinate(node.scaleX, node.scaleY))
props["pivot"] = InspectableValue.Coordinate(Coordinate(node.pivotX, node.pivotY))
val positionOnScreen = IntArray(2)
node.getLocationOnScreen(positionOnScreen)
props["globalPosition"] =
InspectableValue.Coordinate(Coordinate(positionOnScreen[0], positionOnScreen[1]))
val localVisible = Rect()
node.getLocalVisibleRect(localVisible)
props["localVisible"] =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
props["position"] = InspectableValue.Coordinate3D(Coordinate3D(node.x, node.y, node.z))
} else {
props["position"] = InspectableValue.Coordinate(Coordinate(node.x, node.y))
}
props["globalPosition"] =
InspectableValue.Coordinate(Coordinate(positionOnScreen[0], positionOnScreen[1]))
props["size"] = InspectableValue.Size(Size(node.width, node.height), mutable = true)
props["bounds"] = InspectableValue.Bounds(Bounds(node.left, node.top, node.right, node.bottom))
props["padding"] =
InspectableValue.SpaceBox(
SpaceBox(node.paddingTop, node.paddingRight, node.paddingBottom, node.paddingLeft))
props["localVisibleRect"] =
InspectableObject(
mapOf(
"position" to InspectableValue.Coordinate(Coordinate(localVisible.left, node.top)),
"size" to InspectableValue.Size(Size(node.width, node.height))),
)
props["rotation"] =
InspectableValue.Coordinate3D(Coordinate3D(node.rotationX, node.rotationY, node.rotation))
props["scale"] = InspectableValue.Coordinate(Coordinate(node.scaleX, node.scaleY))
props["pivot"] = InspectableValue.Coordinate(Coordinate(node.pivotX, node.pivotY))
props["layoutParams"] = getLayoutParams(node)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
props["layoutDirection"] = LayoutDirectionMapping.toInspectable(node.layoutDirection, false)
props["textDirection"] = TextDirectionMapping.toInspectable(node.textDirection, false)
props["textAlignment"] = TextAlignmentMapping.toInspectable(node.textAlignment, false)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
props["elevation"] = InspectableValue.Number(node.elevation)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -113,16 +97,40 @@ object ViewDescriptor : ChainedDescriptor<View>() {
InspectableValue.Coordinate(Coordinate(node.translationX, node.translationY))
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
props["position"] = InspectableValue.Coordinate3D(Coordinate3D(node.x, node.y, node.z))
} else {
props["position"] = InspectableValue.Coordinate(Coordinate(node.x, node.y))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
props["elevation"] = InspectableValue.Number(node.elevation)
}
props["visibility"] = VisibilityMapping.toInspectable(node.visibility, mutable = false)
fromDrawable(node.background)?.let { background -> props["background"] = background }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
fromDrawable(node.foreground)?.let { foreground -> props["foreground"] = foreground }
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
props["alpha"] = InspectableValue.Number(node.alpha, mutable = true)
}
props["state"] =
InspectableObject(
mapOf(
"enabled" to InspectableValue.Boolean(node.isEnabled, mutable = false),
"activated" to InspectableValue.Boolean(node.isActivated, mutable = false),
"focused" to InspectableValue.Boolean(node.isFocused, mutable = false),
"selected" to InspectableValue.Boolean(node.isSelected, mutable = false)))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
props["textDirection"] = TextDirectionMapping.toInspectable(node.textDirection, false)
props["textAlignment"] = TextAlignmentMapping.toInspectable(node.textAlignment, false)
}
node.tag
?.let { InspectableValue.fromAny(it, mutable = false) }
?.let { tag -> props.put("tag", tag) }
props["keyedTags"] = InspectableObject(getViewTags(node))
attributeSections["View"] = InspectableObject(props.toMap())
}
@@ -297,6 +305,7 @@ object ViewDescriptor : ChainedDescriptor<View>() {
object :
EnumMapping<Int>(
mapOf(
"NONE" to -1,
"NO_GRAVITY" to Gravity.NO_GRAVITY,
"LEFT" to Gravity.LEFT,
"TOP" to Gravity.TOP,