Add additional inspectables

Summary:
This change adds support for more inspectables and also introduces more complex types to be used as a value.

This become specially useful for more complex yet primitive types like coordinate, size, bounds, etc.

Reviewed By: LukeDefeo

Differential Revision: D40307885

fbshipit-source-id: 125e832f06d6b31f56eb5405182d1c0d61388930
This commit is contained in:
Lorenzo Blasa
2022-10-18 04:30:51 -07:00
committed by Facebook GitHub Bot
parent f7a624a143
commit 0572808f1a
27 changed files with 417 additions and 132 deletions

View File

@@ -8,13 +8,13 @@
package com.facebook.flipper.plugins.uidebugger.litho.descriptors
import android.graphics.Bitmap
import com.facebook.flipper.plugins.uidebugger.common.InspectableObject
import com.facebook.flipper.plugins.uidebugger.descriptors.BaseTags
import com.facebook.flipper.plugins.uidebugger.descriptors.DescriptorRegister
import com.facebook.flipper.plugins.uidebugger.descriptors.NodeDescriptor
import com.facebook.flipper.plugins.uidebugger.descriptors.OffsetChild
import com.facebook.flipper.plugins.uidebugger.litho.LithoTag
import com.facebook.flipper.plugins.uidebugger.model.Bounds
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
import com.facebook.litho.DebugComponent
class DebugComponentDescriptor(val register: DescriptorRegister) : NodeDescriptor<DebugComponent> {

View File

@@ -7,11 +7,11 @@
package com.facebook.flipper.plugins.uidebugger.litho.descriptors
import com.facebook.flipper.plugins.uidebugger.common.Inspectable
import com.facebook.flipper.plugins.uidebugger.common.InspectableObject
import com.facebook.flipper.plugins.uidebugger.common.InspectableValue
import com.facebook.flipper.plugins.uidebugger.descriptors.ChainedDescriptor
import com.facebook.flipper.plugins.uidebugger.descriptors.SectionName
import com.facebook.flipper.plugins.uidebugger.model.Inspectable
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
import com.facebook.flipper.plugins.uidebugger.model.InspectableValue
import com.facebook.litho.DebugComponent
import com.facebook.litho.LithoView
@@ -19,7 +19,7 @@ object LithoViewDescriptor : ChainedDescriptor<LithoView>() {
override fun onGetName(node: LithoView): String = node.javaClass.simpleName
override fun onGetChildren(node: LithoView): List<Any>? {
override fun onGetChildren(node: LithoView): List<Any> {
val result = mutableListOf<Any>()
val debugComponent = DebugComponent.getRootInstance(node)
if (debugComponent != null) {

View File

@@ -8,9 +8,9 @@
package com.facebook.flipper.plugins.uidebugger.litho.descriptors
import android.graphics.Bitmap
import com.facebook.flipper.plugins.uidebugger.common.InspectableObject
import com.facebook.flipper.plugins.uidebugger.descriptors.*
import com.facebook.flipper.plugins.uidebugger.model.Bounds
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
/** a drawable or view that is mounted, along with the correct descriptor */
class MountedObject(val obj: Any, val descriptor: NodeDescriptor<Any>)
@@ -19,14 +19,16 @@ object MountedObjectDescriptor : NodeDescriptor<MountedObject> {
override fun getBounds(node: MountedObject): Bounds? {
val bounds = node.descriptor.getBounds(node.obj)
/**
* When we ask android for the bounds the x,y offset is w.r.t to the nearest android parent view
* group. From UI debuggers perspective using the raw android offset will double the total
* offset of this native view as the offset is included by the litho components between the
* mounted view and its native parent
*/
return bounds?.copy(x = 0, y = 0)
bounds?.let { b ->
/**
* When we ask android for the bounds the x,y offset is w.r.t to the nearest android parent
* view group. From UI debuggers perspective using the raw android offset will double the
* total offset of this native view as the offset is included by the litho components between
* the mounted view and its native parent
*/
return Bounds(0, 0, b.width, b.height)
}
return null
}
override fun getName(node: MountedObject): String = node.descriptor.getName(node.obj)

View File

@@ -7,11 +7,11 @@
package com.facebook.flipper.plugins.uidebugger.litho.descriptors
import com.facebook.flipper.plugins.uidebugger.common.Inspectable
import com.facebook.flipper.plugins.uidebugger.common.InspectableObject
import com.facebook.flipper.plugins.uidebugger.common.InspectableValue
import com.facebook.flipper.plugins.uidebugger.descriptors.ChainedDescriptor
import com.facebook.flipper.plugins.uidebugger.descriptors.SectionName
import com.facebook.flipper.plugins.uidebugger.model.Inspectable
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
import com.facebook.flipper.plugins.uidebugger.model.InspectableValue
import com.facebook.litho.widget.TextDrawable
object TextDrawableDescriptor : ChainedDescriptor<TextDrawable>() {