package cn.yyxx.eyuangame.core.ui.dialog

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.*
import android.widget.ImageView
import cn.yyxx.support.ResUtils

/**
 * @author #Suyghur.
 * Created on 2021/06/18
 */
class ChooseLoginDialog(context: Context) : Dialog(context) {

    lateinit var typeGoogle: ImageView
        private set
    lateinit var typeFacebook: ImageView
        private set
    lateinit var typeAccount: ImageView
        private set
    lateinit var typeGuest: ImageView
        private set

    init {
        setCanceledOnTouchOutside(false)
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        initView(context)
    }

    private fun initView(context: Context) {

        val view: View = LayoutInflater.from(context).inflate(ResUtils.getResId(context, "yyxx_choose_login_dialog", "layout"), null)
        setContentView(view)

        val attr = window?.attributes as WindowManager.LayoutParams
        //设置dialog 在布局中的位置
        attr.height = ViewGroup.LayoutParams.WRAP_CONTENT
        attr.width = ViewGroup.LayoutParams.WRAP_CONTENT
//        attr.width = DensityUtils.getHeightAndWidth(context)[0] - 150
        attr.gravity = Gravity.CENTER

        typeGoogle = view.findViewById(ResUtils.getResId(context, "yyxx_iv_google", "id"))
        typeFacebook = view.findViewById(ResUtils.getResId(context, "yyxx_iv_facebook", "id"))
        typeAccount = view.findViewById(ResUtils.getResId(context, "yyxx_iv_account", "id"))
        typeGuest = view.findViewById(ResUtils.getResId(context, "yyxx_iv_guest", "id"))
    }
}