Skip to content

Commit

Permalink
Add bounds to fragment
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Luke De Feo authored and facebook-github-bot committed Jul 31, 2023
1 parent 6b74f66 commit 1de033c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ class FragmentFrameworkDescriptor(val register: DescriptorRegister) :
return node.javaClass.simpleName
}

override fun onGetBounds(node: android.app.Fragment): Bounds? = Bounds(0, 0, 0, 0)
override fun onGetBounds(node: android.app.Fragment): Bounds {
return node.view?.let {
val descriptor = register.descriptorForClassUnsafe(it.javaClass)
return descriptor.getBounds(it)
}
?: Bounds(0, 0, 0, 0)
}

override fun onGetChildren(node: android.app.Fragment): List<Any> =
node.view?.let { view -> listOf(view) } ?: listOf()
node.view?.let { view ->
listOf(OffsetChild.zero(view, register.descriptorForClassUnsafe(view.javaClass)))
}
?: listOf()

override fun onGetAttributes(
node: android.app.Fragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ class FragmentSupportDescriptor(val register: DescriptorRegister) :
return node.javaClass.simpleName
}

override fun onGetBounds(node: Fragment): Bounds = Bounds(0, 0, 0, 0)
override fun onGetBounds(node: Fragment): Bounds {
return node.view?.let {
val descriptor = register.descriptorForClassUnsafe(it.javaClass)
return descriptor.getBounds(it)
}
?: Bounds(0, 0, 0, 0)
}

override fun onGetChildren(node: androidx.fragment.app.Fragment): List<Any> {
val view = node.view
return if (view != null && node.isVisible) {
listOf(view)
listOf(OffsetChild.zero(view, register.descriptorForClassUnsafe(view.javaClass)))
} else {
listOf()
}
Expand Down

0 comments on commit 1de033c

Please sign in to comment.