package com.hongyegroup.cpt_ewallet.widget

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import com.guadou.lib_baselib.ext.click
import com.hongyegroup.cpt_ewallet.R
import com.lxj.xpopup.core.CenterPopupView
import com.lxj.xpopup.util.XPopupUtils

/**
 * 提现的免责声明弹窗
 */
@SuppressLint("ViewConstructor")
class WithdrawDisclaimersPopup(
    context: Context,
    private val action: (() -> Unit)? = null,
) : CenterPopupView(context) {

    override fun getImplLayoutId(): Int = R.layout.popup_withdraw_disclanimers

    override fun onCreate() {
        super.onCreate()

        findViewById<View>(R.id.btn_yes).click {
            dismiss()
            action?.invoke()
        }

        findViewById<View>(R.id.btn_no).click {
            dismiss()
        }

        findViewById<View>(R.id.iv_delete).click {
            dismiss()
        }

    }

    //如果不设置可能出现xml的背景圆角无法正常显示
    override fun getMaxWidth(): Int {
        return if (popupInfo.maxWidth == 0) (XPopupUtils.getWindowWidth(context) * 0.99f).toInt() else popupInfo.maxWidth
    }

//    override fun getMaxHeight(): Int {
//        return dp2px(500f)
//    }

}