From 8694713832213386822e35564930d79e727522a5 Mon Sep 17 00:00:00 2001 From: Jett Hsieh Date: Wed, 6 Nov 2024 03:48:42 -0800 Subject: [PATCH] Add LithoVisibilityEventsController Summary: Added a quick way to see if there is a LithoVisibilityEventsController set to a Component Tree Reviewed By: adityasharat Differential Revision: D65483784 fbshipit-source-id: cdbe55ed62fe3e20c1903ec09d8176e5315425af --- .../descriptors/ComponentTreeDescriptor.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/android/plugins/litho/src/main/java/com/facebook/flipper/plugins/uidebugger/litho/descriptors/ComponentTreeDescriptor.kt b/android/plugins/litho/src/main/java/com/facebook/flipper/plugins/uidebugger/litho/descriptors/ComponentTreeDescriptor.kt index c321616b6d2..84b97500577 100644 --- a/android/plugins/litho/src/main/java/com/facebook/flipper/plugins/uidebugger/litho/descriptors/ComponentTreeDescriptor.kt +++ b/android/plugins/litho/src/main/java/com/facebook/flipper/plugins/uidebugger/litho/descriptors/ComponentTreeDescriptor.kt @@ -40,6 +40,10 @@ class ComponentTreeDescriptor(val register: DescriptorRegister) : NodeDescriptor private val ComponentTreeId = MetadataRegister.register(MetadataRegister.TYPE_ATTRIBUTE, "treeConfiguration", "id") + private val LithoVisibilityEventsControllerId = + MetadataRegister.register( + MetadataRegister.TYPE_ATTRIBUTE, NAMESPACE, "LithoVisibilityEventsController") + private val qualifiedName = ComponentTree::class.qualifiedName ?: "" override fun getId(node: ComponentTree): Id = node.id @@ -83,10 +87,28 @@ class ComponentTreeDescriptor(val register: DescriptorRegister) : NodeDescriptor attributeSections[ConfigurationSectionId] = InspectableObject(getLithoConfigurationAttributes(node)) + attributeSections[LithoVisibilityEventsControllerId] = + InspectableObject(getLithoVisibilityEventsControllerAttributes(node)) + attributeSections } } + private fun getLithoVisibilityEventsControllerAttributes( + tree: ComponentTree + ): Map { + val lithoVisibilityEventsController = tree.getLithoVisibilityEventsController() + val metadataId = + MetadataRegister.register( + MetadataRegister.TYPE_ATTRIBUTE, + "LithoVisibilityEventsController", + "LithoVisibilityEventsController") + + return mapOf( + metadataId to + InspectableValue.Unknown(lithoVisibilityEventsController?.toString() ?: "null")) + } + private fun getLithoConfigurationAttributes(tree: ComponentTree): Map { val (configurationInstance, configurationFields) = getConfigurationFieldsAndValuesUsingReflection(tree)