package com.dumpster.cleaner.ui.dialog

import android.app.Activity
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.widget.ConstraintLayout
import com.dumpster.cleaner.R
import com.dumpster.cleaner.databinding.DialogNotificationBinding


class NotificationTurnOnDialog(
    val activity: Activity
) {

    val dialog = AlertDialog.Builder(activity).create()
    val binding = DialogNotificationBinding.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?.width = activity.resources.getDimensionPixelSize(R.dimen.dp_295)
        params?.height = ConstraintLayout.LayoutParams.WRAP_CONTENT
//        params?.gravity = Gravity.BOTTOM
        dialog.window?.attributes = params
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        binding.ivClose.setOnClickListener {
            dialog.dismiss()
        }
        binding.tvTurnOn.setOnClickListener {
            dialog.dismiss()
            action?.invoke()
        }
    }
}