Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 1de033c

Browse files
Luke De Feofacebook-github-bot
authored andcommitted
Add bounds to fragment
Summary: Previously the bounds was 0, the trick is to steel the offset from the view and then use offsetchild zero so it doesnt get applied twice Reviewed By: lblasa Differential Revision: D47915115 fbshipit-source-id: ff771470dcf1720ca265fc9017ff0ea3b0bc1ca1
1 parent 6b74f66 commit 1de033c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentFrameworkDescriptor.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ class FragmentFrameworkDescriptor(val register: DescriptorRegister) :
2727
return node.javaClass.simpleName
2828
}
2929

30-
override fun onGetBounds(node: android.app.Fragment): Bounds? = Bounds(0, 0, 0, 0)
30+
override fun onGetBounds(node: android.app.Fragment): Bounds {
31+
return node.view?.let {
32+
val descriptor = register.descriptorForClassUnsafe(it.javaClass)
33+
return descriptor.getBounds(it)
34+
}
35+
?: Bounds(0, 0, 0, 0)
36+
}
3137

3238
override fun onGetChildren(node: android.app.Fragment): List<Any> =
33-
node.view?.let { view -> listOf(view) } ?: listOf()
39+
node.view?.let { view ->
40+
listOf(OffsetChild.zero(view, register.descriptorForClassUnsafe(view.javaClass)))
41+
}
42+
?: listOf()
3443

3544
override fun onGetAttributes(
3645
node: android.app.Fragment,

android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentSupportDescriptor.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ class FragmentSupportDescriptor(val register: DescriptorRegister) :
4747
return node.javaClass.simpleName
4848
}
4949

50-
override fun onGetBounds(node: Fragment): Bounds = Bounds(0, 0, 0, 0)
50+
override fun onGetBounds(node: Fragment): Bounds {
51+
return node.view?.let {
52+
val descriptor = register.descriptorForClassUnsafe(it.javaClass)
53+
return descriptor.getBounds(it)
54+
}
55+
?: Bounds(0, 0, 0, 0)
56+
}
5157

5258
override fun onGetChildren(node: androidx.fragment.app.Fragment): List<Any> {
5359
val view = node.view
5460
return if (view != null && node.isVisible) {
55-
listOf(view)
61+
listOf(OffsetChild.zero(view, register.descriptorForClassUnsafe(view.javaClass)))
5662
} else {
5763
listOf()
5864
}

0 commit comments

Comments
 (0)