package com.trace.drawing.people.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.trace.drawing.people.databinding.DialogSelectImageBinding
import com.trace.drawing.people.callbacl.OnSelectCallback

class DialogSelectImage(private var listener: OnSelectCallback)  : DialogFragment() {

   private lateinit var binding:DialogSelectImageBinding

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DialogSelectImageBinding.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)
        }
    }

}