package com.gamedog.vididin.features.zero.dialogs



import android.app.Activity
import com.ama.core.architecture.util.setOnClickBatch
import com.ama.core.architecture.widget.BindingDialog
import com.gamedog.vididin.beans.ZeroBuyItem
import com.gamedog.vididin.manager.ZeroManager
import com.viddin.videos.free.databinding.DialogZeroBuyWinBinding as ViewBinding


class ZeroBuyWinDialog(context: Activity, private val item: ZeroBuyItem) : BindingDialog<ViewBinding>(context, ViewBinding::inflate) {

    init {
        build()
    }


    private fun build() {
        with()
        setCenter()
        setMaskValue(0.8f)
        setCanCancel(false)

        mBinding.run {
            setOnClickBatch(ivClose, rlAction) {
                when (this) {
                    ivClose ->  {
                        dismiss()
                    }

                    rlAction -> {
                        handleWithdraw(item)
                        dismiss()
                    }
                }
            }

            tvTitleSub.text = item.title
            tvPurchaseReward.text = item.price
        }



    }

    private fun handleWithdraw(item: ZeroBuyItem) {
        ZeroManager.instance().addWinWithdrawItem(item)
        ZeroManager.instance().startWithdrawProcess(mActivity, item)
    }


}

