package com.gh.gamecenter.forum.home.follow

import android.content.Context
import android.graphics.Canvas
import android.graphics.Path
import android.util.AttributeSet
import androidx.core.content.ContextCompat
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.core.utils.DisplayUtils

class FollowClippedView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : androidx.appcompat.widget.AppCompatImageView(context, attrs, defStyleAttr) {

    override fun onDraw(canvas: Canvas) {
        val path = Path()
        path.addRect(
            0f,
            0f,
            width.toFloat(),
            (DisplayUtils.getStatusBarHeight(resources) + 52f.dip2px() + 56f.dip2px()).toFloat(),
            Path.Direction.CW
        )
        canvas.clipPath(path)

        canvas.drawColor(ContextCompat.getColor(context, com.gh.gamecenter.common.R.color.ui_background))
        super.onDraw(canvas)
    }
}