Added inline tree attributes

Summary:
This is temporary solution to get to parity with the old plugin. In future would like to make this more flexible on the desktop side

Additionally getData was renamed to getAttributes for consistency

Reviewed By: lblasa

Differential Revision: D41845248

fbshipit-source-id: 50e94a7712f5d42938229134e212cef5d379475d
This commit is contained in:
Luke De Feo
2022-12-12 07:28:37 -08:00
committed by Facebook GitHub Bot
parent 97cca42822
commit 1a9724d790
22 changed files with 107 additions and 26 deletions

View File

@@ -72,7 +72,9 @@ class DebugComponentDescriptor(val register: DescriptorRegister) : NodeDescripto
private val StateId =
MetadataRegister.register(MetadataRegister.TYPE_ATTRIBUTE, NAMESPACE, "Litho State")
override fun getData(node: DebugComponent): MaybeDeferred<Map<MetadataId, InspectableObject>> {
override fun getAttributes(
node: DebugComponent
): MaybeDeferred<Map<MetadataId, InspectableObject>> {
return Deferred {
val attributeSections = mutableMapOf<MetadataId, InspectableObject>()
@@ -101,4 +103,17 @@ class DebugComponentDescriptor(val register: DescriptorRegister) : NodeDescripto
override fun getTags(node: DebugComponent): Set<String> = setOf(BaseTags.Declarative, LithoTag)
override fun getSnapshot(node: DebugComponent, bitmap: Bitmap?): Bitmap? = null
override fun getInlineAttributes(node: DebugComponent): Map<String, String> {
val attributes = mutableMapOf<String, String>()
val key = node.key
val testKey = node.testKey
if (key != null && key.trim { it <= ' ' }.length > 0) {
attributes["key"] = key
}
if (testKey != null && testKey.trim { it <= ' ' }.length > 0) {
attributes["testKey"] = testKey
}
return attributes
}
}

View File

@@ -36,7 +36,7 @@ object LithoViewDescriptor : ChainedDescriptor<LithoView>() {
MetadataRegister.register(
MetadataRegister.TYPE_ATTRIBUTE, NAMESPACE, "isIncrementalMountEnabled")
override fun onGetData(
override fun onGetAttributes(
node: LithoView,
attributeSections: MutableMap<MetadataId, InspectableObject>
) {

View File

@@ -25,7 +25,7 @@ object TextDrawableDescriptor : ChainedDescriptor<TextDrawable>() {
private val TextAttributeId =
MetadataRegister.register(MetadataRegister.TYPE_ATTRIBUTE, NAMESPACE, "text")
override fun onGetData(
override fun onGetAttributes(
node: TextDrawable,
attributeSections: MutableMap<MetadataId, InspectableObject>
) {