package com.cheng.blzb.ui.dialog

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.example.base.extensions.onClick
import com.example.base.utils.ScreenUtils
import com.cheng.blzb.R
import com.cheng.blzb.common.Constants
import com.cheng.blzb.databinding.DialogVipLoginTipBinding
import com.cheng.blzb.ui.base.BaseDialog

class VipLoginTipDialog(mFragment: Fragment) : BaseDialog(mFragment.requireContext()){
    private var mOnBackListener: (() -> Unit)? = null     //回调事件

    lateinit var binding: DialogVipLoginTipBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val view = layoutInflater.inflate(R.layout.dialog_vip_login_tip, null)
        setContentView(view)

        val windowParams = window?.attributes
        windowParams?.dimAmount = 0.7f
        windowParams?.width = (ScreenUtils.getWindowSize().x * 0.8).toInt()
        window?.attributes = windowParams

        setCancelable(false)

        binding = DialogVipLoginTipBinding.bind(view)

        binding.tvTitle.typeface = Constants.douyinsansB

        binding.btnOk.onClick {
            mOnBackListener?.invoke()
            dismiss()
        }

    }

    fun setOnSelectListener(listener: (() -> Unit)) {
        mOnBackListener = listener
    }

}