package com.ama.core.architecture.widget

import android.content.Context
import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
import androidx.core.widget.NestedScrollView

class MyScrollView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : NestedScrollView(context, attrs, defStyleAttr) {

    fun scroll2ChildView(child: View) {
        val tempRect = Rect()
        child.getDrawingRect(tempRect)
        offsetDescendantRectToMyCoords(child, tempRect)
        val scrollDelta: Int = computeScrollDeltaToGetChildRectOnScreen(tempRect)
        smoothScrollTo(0, tempRect.top)
    }

}
