package rememberic

import android.app.Activity
import android.view.Gravity
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.widget.ConstraintLayout
import com.easy.clean.databinding.OverseasicBinding


class Euphoricic(
    val activity: Activity,
) {

    val dialog = AlertDialog.Builder(activity).create()
    val binding = OverseasicBinding.inflate(LayoutInflater.from(activity))

    var action: (() -> Unit)? = null

    fun showDialog() {
        dialog.setView(binding.root)
        dialog.setCancelable(true)
        dialog.setCanceledOnTouchOutside(true)

        dialog.show()


        val params = dialog.window?.attributes
        params?.width = ConstraintLayout.LayoutParams.MATCH_PARENT
        params?.height = ConstraintLayout.LayoutParams.WRAP_CONTENT
        params?.gravity = Gravity.BOTTOM
        dialog.window?.attributes = params
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        binding.traditionalistic.setOnClickListener {
            dialog.dismiss()
        }
        binding.ghostwriteric.setOnClickListener {
            dialog.dismiss()
            action?.invoke()
        }
    }
}