package com.ux.video.file.filerecovery.photo

import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.drawable.toDrawable
import androidx.fragment.app.DialogFragment
import com.ux.video.file.filerecovery.databinding.DialogDeleteBinding


/**
 * 删除确认弹窗
 */
class ConfirmDeleteDialogFragment() : DialogFragment() {

    var onClickDelete: (() -> Unit)? = null
    private lateinit var binding: DialogDeleteBinding
    override fun onStart() {
        super.onStart()
        dialog?.window?.apply {
            setLayout(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT
            )
            setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DialogDeleteBinding.inflate(inflater)
        binding.run {
            tvCancel.setOnClickListener { dismiss() }
            tvDelete.setOnClickListener {
                onClickDelete?.invoke()
                dismiss()
            }
        }
        return binding.root
    }
}
