package com.ux.video.file.filerecovery.main

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.DialogPermissionBinding


class PermissionDialogFragment(val onClickAllow: () -> Unit) : DialogFragment() {

    private lateinit var binding: DialogPermissionBinding
    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 = DialogPermissionBinding.inflate(inflater)
        binding.run {
            cancel.setOnClickListener { dismiss() }
            allow.setOnClickListener {
                onClickAllow()
                dismiss()
            }
        }
        return binding.root
    }
}
