package com.hongyegroup.cpt_rewards.ui

import android.content.Intent
import android.os.Bundle
import androidx.databinding.ViewDataBinding
import com.guadou.lib_baselib.base.activity.BaseVDBActivity
import com.guadou.lib_baselib.base.vm.BaseViewModel
import com.guadou.lib_baselib.bean.DataBindingConfig
import com.guadou.lib_baselib.engine.toastSuccess
import com.guadou.lib_baselib.utils.CommUtils
import com.hongyegroup.cpt_rewards.BR
import com.hongyegroup.cpt_rewards.R
import com.hongyegroup.cpt_rewards.databinding.ActivityRewardsConfirmBinding
import com.hongyegroup.cpt_rewards.widget.PointsPaymentDialog

class RewardsConfirmActivity : BaseVDBActivity<BaseViewModel, ActivityRewardsConfirmBinding>() {

    val mClickProxy by lazy { ClickProxy() }

    companion object {

        fun startInstance() {
            val context = CommUtils.getContext()
            val intent = Intent(context, RewardsConfirmActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }

    }

    override fun init(savedInstanceState: Bundle?) {

    }

    override fun getDataBindingConfig(): DataBindingConfig {

        return DataBindingConfig(R.layout.activity_rewards_confirm)
            .addBindingParams(BR.click, mClickProxy)

    }

    override fun startObserve() {

    }

    /**
     * DataBinding事件处理
     */
    inner class ClickProxy {

        //显示Rewards支付确认弹框
        fun showRewardsConfirmDialog() {


//            start(PromotionRewardsPaymentSuccessFragment.newInstance(null));
//            val total: Int = mPresenter.mCount * mPresenter.mDetailData.point.toInt()

            val pointsPaymentDialog = PointsPaymentDialog(100)

            pointsPaymentDialog.setOnClickPointsPaymentDialogListener(PointsPaymentDialog.OnClickPointsPaymentListener {

                RewardsPaymentSuccessActivity.startInstance()

            })
            pointsPaymentDialog.show(supportFragmentManager, "point_payment_dialog")

        }

    }
}