package com.qimai.android.widget

import android.content.Context
import android.graphics.Point
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import com.qimai.android.tools.dpTopx
import com.qimai.android.tools.getScreenWidth
import com.qimai.android.widgetlib.popup.AbsQMBasePopup

/**
 *   created by wangwei   ON 2019-11-06  email:wangwei_5521@163.com
 *   @version 1.1.1
 *   @Description
 **/
class TestWindow constructor(var ctx: Context, var anchor: View) : AbsQMBasePopup(ctx) {
    override fun onShowEnd() {
        dimBehind(0.5f)
    }


    override fun config(): WindowConfig {

        val   content = LayoutInflater.from(ctx).inflate(R.layout.qm_alert_content, null)
        return AbsQMBasePopup.WindowConfig().apply {
            mContentView = content
            mAnchorView = anchor
            mWindowWidth = getScreenWidth(ctx) - ctx.dpTopx(30.0f)
            mGravity = Gravity.CENTER
            isOutsideTouchable = false
        }
    }

    override fun onShowBegin(contentView: View): Point {
        contentView.findViewById<TextView>(R.id.alert_confirm)
            .setOnClickListener {
                dismiss()
            }
        return Point(0, 0)
    }


}