package cn.yyxx.eyuancomm.impl.channel.huawei

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 2022/01/27
 */
class HuaweiLoginDialog(context: Context) : Dialog(context) {

    lateinit var ivHw: ImageView
    lateinit var ivGoogle: ImageView
    lateinit var ivFacebook: ImageView

    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_hw_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.gravity = Gravity.CENTER

        ivHw = view.findViewById(ResUtils.getResId(context, "yyxx_iv_hw", "id"))
        ivGoogle = view.findViewById(ResUtils.getResId(context, "yyxx_iv_google", "id"))
        ivFacebook = view.findViewById(ResUtils.getResId(context, "yyxx_iv_facebook", "id"))

//        setOnKeyListener(this)
    }


//    override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent): Boolean {
//        return keyCode == KeyEvent.KEYCODE_BACK && event.repeatCount == 0
//    }
}

