package com.base.appzxhy.ui.views

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import com.base.appzxhy.R
import com.base.appzxhy.databinding.DialogReportBinding
import com.base.appzxhy.helper.EventUtils
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog

object ReportProblemDialog {

    fun Context.showReportProblemDialog() {
        val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
        val binding = DialogReportBinding.inflate(LayoutInflater.from(this))
        dialog.setContentView(binding.root)
        dialog.setCanceledOnTouchOutside(true)

        dialog.show()

        val parentView = binding.root.parent as View
        val behavior = BottomSheetBehavior.from(parentView)
        //展开
        behavior.state = BottomSheetBehavior.STATE_EXPANDED

        binding.tvSubmit.setOnClickListener {
            if (binding.edit.text.isNotEmpty()) return@setOnClickListener
            val content = binding.edit.toString()
            EventUtils.event("Report_Problem", "content=$content")
        }
    }
}