Hidden attributes

Summary:
These are attributes that are:
1.  Not common across frameworks
2. Not in every node
3. Will not be visualised via inspectable attribute mechansism

Currently we will use them for bloks but they should be useful for other features down the road

Reviewed By: lblasa

Differential Revision: D45048025

fbshipit-source-id: c258d0a384a2b09abb642778e68da178899fa9eb
This commit is contained in:
Luke De Feo
2023-04-18 08:01:50 -07:00
committed by Facebook GitHub Bot
parent c2fc54057a
commit 53aca9a661
3 changed files with 9 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ import com.facebook.flipper.plugins.uidebugger.model.Bounds
import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
import com.facebook.flipper.plugins.uidebugger.model.MetadataId
import com.facebook.flipper.plugins.uidebugger.util.MaybeDeferred
import kotlinx.serialization.json.JsonObject
/*
Descriptors are an extension point used during traversal to extract data out of arbitrary
@@ -62,7 +63,7 @@ interface NodeDescriptor<T> {
* parameter. If a bitmap is provided, it will be used by the canvas to draw on it. Otherwise, a
* bitmap will be created.
*/
fun getSnapshot(node: T, bitmap: Bitmap?): Bitmap?
fun getSnapshot(node: T, bitmap: Bitmap?): Bitmap? = null
/**
* If you have overlapping children this indicates which child is active / on top, we will only
@@ -86,5 +87,7 @@ interface NodeDescriptor<T> {
/**
* These are shown inline in the tree view on the desktop, will likely be removed in the future
*/
fun getInlineAttributes(node: T): Map<String, String> = mutableMapOf()
fun getInlineAttributes(node: T): Map<String, String> = mapOf()
fun getHiddenAttributes(node: T): JsonObject? = null
}

View File

@@ -8,6 +8,7 @@
package com.facebook.flipper.plugins.uidebugger.model
import com.facebook.flipper.plugins.uidebugger.descriptors.Id
import kotlinx.serialization.json.JsonObject
@kotlinx.serialization.Serializable
data class Node(
@@ -17,6 +18,7 @@ data class Node(
val name: String,
val attributes: Map<MetadataId, InspectableObject>,
val inlineAttributes: Map<String, String>,
val hiddenAttributes: JsonObject?,
val bounds: Bounds,
val tags: Set<String>,
val children: List<Id>,

View File

@@ -65,6 +65,7 @@ class PartialLayoutTraversal(
descriptor.getName(node),
emptyMap(),
emptyMap(),
null,
descriptor.getBounds(node),
emptySet(),
emptyList(),
@@ -108,6 +109,7 @@ class PartialLayoutTraversal(
descriptor.getName(node),
attrs,
descriptor.getInlineAttributes(node),
descriptor.getHiddenAttributes(node),
bounds,
tags,
childrenIds,