package com.duben.microtribe.ui.widgets

import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import com.duben.microtribe.R

/**
 * 授权弹窗
 */
class PowerDialog2(context: Context, private val listener: DialogListener) :
    Dialog(context, R.style.dialog) {
    private val lp: WindowManager.LayoutParams
    private val tv_dialogper_agreement: TextView
    private val tv_dialogper_policy: TextView
    private val btn_dialogper_back: TextView
    private val btn_dialogper_next: TextView

    init {
        setContentView(R.layout.dialog_powe2)
        // 设置window属性
        lp = window!!.attributes
        lp.gravity = Gravity.CENTER
        lp.width = WindowManager.LayoutParams.MATCH_PARENT
        lp.windowAnimations = R.style.DialogAnimBottom
        //		lp.dimAmount = 0; // 去背景遮盖
        // lp.alpha = 1.0f;//透明效果
        window!!.attributes = lp

        // 设置外部不可关闭
        setCancelable(false)
        setCanceledOnTouchOutside(false)
        setOnKeyListener { _, i, _ ->
            i == KeyEvent.KEYCODE_BACK
        }

        // 查找View
        tv_dialogper_agreement =
            findViewById<View>(R.id.tv_dialogper_agreement) as TextView
        tv_dialogper_policy =
            findViewById<View>(R.id.tv_dialogper_policy) as TextView
        btn_dialogper_back =
            findViewById<View>(R.id.btn_dialogper_back) as TextView
        btn_dialogper_next =
            findViewById<View>(R.id.btn_dialogper_next) as TextView
        tv_dialogper_policy.setOnClickListener(listener)
        tv_dialogper_agreement.setOnClickListener(listener)
        btn_dialogper_back.setOnClickListener(listener)
        btn_dialogper_next.setOnClickListener(listener)
    }
}