package com.gamedog.vididin.features.benefit.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import com.ama.core.architecture.util.setOnClickBatch
import com.gamedog.vididin.databinding.BenefitTaskItemViewBinding


class BenefitTaskItemView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
    private lateinit var mAction: () -> Unit
    private var mBinding: BenefitTaskItemViewBinding


    init {
        mBinding = BenefitTaskItemViewBinding.inflate(LayoutInflater.from(context), this, true)
        mBinding.run {
            setOnClickBatch(tvAction) {
                when (this) {
                    tvAction-> {
                        mAction.invoke()
                    }
                }
            }
        }

        with(mBinding.progressBar) {
            setMax(100)
            setProgress(0)
        }
    }

    fun setActionFun(action: ()->Unit) {
        mAction = action
    }


    fun setProgressInfo(progress: String) {
        mBinding.tvProgressInfo.text = progress
    }




}