package com.gamedog.vididin.widget


import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.core.view.isVisible
import com.ama.core.architecture.util.ResUtil
import com.gamedog.vididin.R
import com.gamedog.vididin.databinding.DailySignItemBinding
import com.gamedog.vididin.main.fragments.task.RewardDetail
import com.gamedog.vididin.manager.DailySignBean
import com.gamedog.vididin.manager.DailySignDayInfoBean
import kotlin.run

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

    private lateinit var mConfigData: RewardDetail
    private lateinit var mStateData: DailySignDayInfoBean
    private var mBinding: DailySignItemBinding
    private var mIsSelected = false


    init {
        mBinding = DailySignItemBinding.inflate(LayoutInflater.from(context), this, true)
        mBinding.run {

        }
    }



    fun setData(data: RewardDetail, stateData: DailySignDayInfoBean) {
        mConfigData = data
        mStateData = stateData
        mBinding.tvGoldNum.text = "" + mConfigData.value
        mBinding.tvDayNum.text = context.getString(R.string.day) + " "+ mConfigData.day

        mBinding.ivDone.isVisible = mStateData.hasSigned
        mBinding.tvDayNum.isVisible = !mStateData.hasSigned
    }

    fun setLargeWidthMode() {
        mBinding.ivGold.setImageResource(R.mipmap.icon_gold_x3)
        mBinding.ivBg.setImageResource(R.mipmap.bg_biginner_daily_large)
    }

    fun setSelectState(isSelect: Boolean) {
        mIsSelected = isSelect
        if (mIsSelected) {
            mBinding.rlRoot.foreground = ResUtil.getDrawable(R.drawable.bg_daily_sign_day_item)
        } else {
            mBinding.rlRoot.foreground = null
        }
    }

    fun getStateBean(): DailySignDayInfoBean {
        return mStateData
    }


}



