Generalised mounted object and descriptor into offset child
Summary: There are other situations where we want to overide the offset than for litho mounted views Reviewed By: lblasa Differential Revision: D40021833 fbshipit-source-id: 1411a4a67e88f6893bb38e36fb6a81eead3edd1a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c9983edb1a
commit
221f7ac1e5
@@ -16,7 +16,6 @@ object UIDebuggerLithoSupport {
|
||||
|
||||
fun addDescriptors(register: DescriptorRegister) {
|
||||
register.register(LithoView::class.java, LithoViewDescriptor)
|
||||
register.register(MountedObject::class.java, MountedObjectDescriptor)
|
||||
register.register(DebugComponent::class.java, DebugComponentDescriptor(register))
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ class DescriptorRegister {
|
||||
mapping.register(ViewPager::class.java, ViewPagerDescriptor)
|
||||
mapping.register(Drawable::class.java, DrawableDescriptor)
|
||||
mapping.register(ColorDrawable::class.java, ColorDrawableDescriptor)
|
||||
mapping.register(OffsetChild::class.java, OffsetChildDescriptor)
|
||||
mapping.register(android.app.Fragment::class.java, FragmentFrameworkDescriptor)
|
||||
mapping.register(androidx.fragment.app.Fragment::class.java, FragmentSupportDescriptor)
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.flipper.plugins.uidebugger.descriptors
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.facebook.flipper.plugins.uidebugger.common.InspectableObject
|
||||
import com.facebook.flipper.plugins.uidebugger.model.Bounds
|
||||
|
||||
/** a drawable or view that is mounted, along with the correct descriptor */
|
||||
class OffsetChild(val child: Any, val descriptor: NodeDescriptor<Any>, val x: Int, val y: Int) {
|
||||
companion object {
|
||||
fun zero(child: Any, descriptor: NodeDescriptor<Any>) = OffsetChild(child, descriptor, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
object OffsetChildDescriptor : NodeDescriptor<OffsetChild> {
|
||||
|
||||
override fun getBounds(node: OffsetChild): Bounds? {
|
||||
val bounds = node.descriptor.getBounds(node.child)
|
||||
return bounds?.copy(x = node.x, y = node.y)
|
||||
}
|
||||
|
||||
override fun getName(node: OffsetChild): String = node.descriptor.getName(node.child)
|
||||
|
||||
override fun getChildren(node: OffsetChild): List<Any> = node.descriptor.getChildren(node.child)
|
||||
|
||||
override fun getActiveChild(node: OffsetChild): Any? = node.descriptor.getActiveChild(node.child)
|
||||
|
||||
override fun getData(node: OffsetChild): Map<SectionName, InspectableObject> =
|
||||
node.descriptor.getData(node.child)
|
||||
|
||||
override fun getTags(node: OffsetChild): Set<String> = node.descriptor.getTags(node.child)
|
||||
override fun getSnapshot(node: OffsetChild, bitmap: Bitmap?): Bitmap? =
|
||||
node.descriptor.getSnapshot(node.child, bitmap)
|
||||
}
|
||||
Reference in New Issue
Block a user