package com.sketch.art.trace.dialog

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.art.trace.databinding.DialogLayoutBinding
import com.sketch.art.trace.listener.OnDialogClickListener

class DialogSelect(private var listener: OnDialogClickListener)  : DialogFragment() {

   private lateinit var binding:DialogLayoutBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DialogLayoutBinding.inflate(layoutInflater)
        binding.llCamera.setOnClickListener {
            dismiss()
            listener.onClickCamera()
        }
        binding.llGallery.setOnClickListener {
            dismiss()
            listener.onClickGallery()
        }
        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(android.R.color.transparent) // 去除默认背景
            setGravity(Gravity.CENTER)
        }
    }

}