package com.example.defenseapplication.view

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import com.example.defenseapplication.R
import com.example.defenseapplication.databinding.DialogAutoModeNoticeBinding

class AutoModeNoticeDialog(context: Context) : Dialog(context) {

    private lateinit var binding: DialogAutoModeNoticeBinding
    private var onConfirmListener: (() -> Unit)? = null

    fun setOnConfirmListener(listener: () -> Unit) {
        this.onConfirmListener = listener
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DialogAutoModeNoticeBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val window = window
        window?.let {
            val params = it.attributes
            params.gravity = Gravity.BOTTOM
            params.width = WindowManager.LayoutParams.MATCH_PARENT
            params.height = WindowManager.LayoutParams.WRAP_CONTENT
            it.attributes = params
            it.setBackgroundDrawableResource(R.drawable.round_bg)
        }

        binding.btnConfirm.setOnClickListener {
            onConfirmListener?.invoke()
            dismiss()
        }
    }
}