Override bounds for view pager

Summary: For view pager we just want to draw the content in the center

Reviewed By: lblasa

Differential Revision: D40478266

fbshipit-source-id: 4fac7e897a0569fed59ef5810ba15300ebe87b5d
This commit is contained in:
Luke De Feo
2022-10-25 07:10:38 -07:00
committed by Facebook GitHub Bot
parent 62167bb69c
commit 7c3e28272b

View File

@@ -21,6 +21,7 @@ import android.view.ViewGroup
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.core.widget.NestedScrollView import androidx.core.widget.NestedScrollView
import androidx.viewpager.widget.ViewPager
import com.facebook.flipper.plugins.uidebugger.common.* import com.facebook.flipper.plugins.uidebugger.common.*
import com.facebook.flipper.plugins.uidebugger.common.BitmapPool import com.facebook.flipper.plugins.uidebugger.common.BitmapPool
import com.facebook.flipper.plugins.uidebugger.common.EnumMapping import com.facebook.flipper.plugins.uidebugger.common.EnumMapping
@@ -35,13 +36,18 @@ object ViewDescriptor : ChainedDescriptor<View>() {
override fun onGetBounds(node: View): Bounds { override fun onGetBounds(node: View): Bounds {
if (node.parent is ViewPager) {
// override
return Bounds(0, 0, node.width, node.height)
}
var offsetX = 0 var offsetX = 0
var offsetY = 0 var offsetY = 0
if (node.parent is NestedScrollView) { if (node.parent is NestedScrollView) {
/** /**
* when a node is a child of nested scroll view android does not adjust the left/ top as the * when a node is a child of nested scroll view android does not adjust the left/ top as the
* view scrolls. This seems to be unique to nested scroll view so we have this trick to find * view scrolls. This seems to be unique to nested scroll view so we have this trick to find
* its * its actual position.
*/ */
val localVisible = Rect() val localVisible = Rect()
node.getLocalVisibleRect(localVisible) node.getLocalVisibleRect(localVisible)