package com.sketch.ar.artdrawing.importImage


import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.sketch.ar.artdrawing.R
import com.sketch.ar.artdrawing.databinding.DialogImportImageTypeBinding

class ImportTypeDialog(private var listener: (type:Int)->Unit)  : DialogFragment() {

   private lateinit var binding: DialogImportImageTypeBinding
   companion object{
       val TYPE_CAMERA = 0

       val TYPE_GAllERY = 1
   }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DialogImportImageTypeBinding.inflate(layoutInflater)
        binding.llCamera.setOnClickListener {
            dismiss()
            listener(TYPE_CAMERA)
        }
        binding.llGallery.setOnClickListener {
            dismiss()
            listener(TYPE_GAllERY)
        }
        return binding.root
    }

    override fun onStart() {
        super.onStart()
        dialog?.window?.apply {
//            val width = (resources.displayMetrics.widthPixels * 0.85).toInt()
            setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
            setBackgroundDrawableResource(R.color.color_transparent)
            setGravity(Gravity.CENTER)
        }
    }

}