package com.yidian.bcommon.widget

import android.app.Activity
import android.app.Dialog
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import com.yidian.bcommon.R
import com.yidian.nightmode.widget.YdTextView

class NormalHintDialog(private val activity: Activity, themeResId: Int): Dialog(activity, themeResId) {
    companion object{
        const val DELETE = "delete"
        const val CLEAR = "clear"
    }

    lateinit var tvContent: YdTextView
    lateinit var tvDelete: YdTextView
    private lateinit var tvCancel: YdTextView

    init {
        setDialog()
    }

    private fun setDialog(){
        this.setCanceledOnTouchOutside(false)
        this.setContentView(R.layout.dialog_normal)
        this.setOwnerActivity(activity)
        tvContent = findViewById(R.id.tv_content)
        tvDelete = findViewById(R.id.tv_delete)
        tvCancel = findViewById(R.id.tv_cancel)
        setClickListener()
    }

    private fun setClickListener(){
        tvCancel.setOnClickListener {
            dismiss()
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val params: WindowManager.LayoutParams? = window?.attributes
        params?.width = WindowManager.LayoutParams.MATCH_PARENT
        params?.height = WindowManager.LayoutParams.WRAP_CONTENT
        window?.attributes = params
        window?.attributes?.gravity = Gravity.CENTER
    }
}
