package cn.muchinfo.rma.view.autoWidget

import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import com.qmuiteam.qmui.util.QMUIResHelper
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButtonDrawable

fun Context.getAttrColor(attr: Int): Int = QMUIResHelper.getAttrColor(this, attr)

fun createCommonRoundBg(): Drawable = createRoundRectDrawable("#ffffff", 10)
fun createCommonBlueRoundBg(): Drawable = createRoundRectDrawable("#31a5ff", 10)
fun createCommonTopRoundBg(color: String = "#ffa531", corner: Int = 24): Drawable = QMUIRoundButtonDrawable().apply {
    setIsRadiusAdjustBounds(false)
    setColor(Color.parseColor(color))
    val autoCorner = autoSize(corner).toFloat()
    val zero = 0.toFloat()
    cornerRadii = floatArrayOf(autoCorner, autoCorner, autoCorner, autoCorner, zero, zero, zero, zero)
}

fun createCommonCenterBg(color: String = "#ffa531"): Drawable = QMUIRoundButtonDrawable().apply {
    setIsRadiusAdjustBounds(false)
    setColor(Color.parseColor(color))
    cornerRadius = 0.toFloat()
}

fun createCommonBottomRoundBg(color: String = "#ffa531", corner: Int = 24): Drawable = QMUIRoundButtonDrawable().apply {
    setIsRadiusAdjustBounds(false)
    setColor(Color.parseColor(color))
    val autoCorner = autoSize(corner).toFloat()
    val zero = 0.toFloat()
    cornerRadii = floatArrayOf(zero, zero, zero, zero, autoCorner, autoCorner, autoCorner, autoCorner)
}