package com.gamedog.vididin.main.fragments.task

import android.app.Activity
import androidx.core.view.isVisible
import com.ama.core.architecture.util.setOnClickBatch
import com.ama.core.architecture.widget.BindingDialog
import com.gamedog.vididin.VidiConst
import com.gamedog.vididin.router.Router
import com.viddin.videos.free.databinding.DialogDailySignSuccessBinding as ViewBinding


class DailySignSuccessDialog(activity: Activity) : BindingDialog<ViewBinding>(activity, ViewBinding::inflate) {

    init {
        build()
    }

    private fun build() {
        with()
        setCenter()
        setCanCancel(false)
        setMaskValue(0.9f)
        setWidthRatio(0.93)


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

    private fun gotoWatchAdPage() {
        Router.WatchAd.startActivity(mActivity, VidiConst.WATCH_AD_FOR_DAILY_SIGN_SINGLE)
    }

    fun initData(goldNum: Int?, showAdBut: Boolean) : DailySignSuccessDialog {
        mBinding.tvGoldNum.text = "+$goldNum"
        mBinding.tvGoldNumBut.text = "+$goldNum"
        mBinding.flAction.isVisible = showAdBut
        return this
    }


}

