package es.verdnatura.presentation.view.component


import android.app.Dialog
import android.content.Context
import android.view.View
import android.widget.TextView
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomDialogBinding

//import kotlinx.android.synthetic.main.component_custom_dialog.*

private lateinit var binding: ComponentCustomDialogBinding
private lateinit var custom_dialog_title: TextView
private lateinit var custom_dialog_description: TextView
private lateinit var custom_dialog_button_ok: TextView
private lateinit var custom_dialog_button_ko: TextView

class CustomDialogMainActivity(context: Context) : Dialog(context, R.style.DialogTheme) {

    init {
//sergio: de momento se deja el componentDialogMainActivity porque no acaba de funciona bien
// con el viewbinding del customDialog

      /*  setContentView(R.layout.component_custom_dialog)

        custom_dialog_title = findViewById(R.id.custom_dialog_title)
        custom_dialog_description = findViewById(R.id.custom_dialog_description)
        custom_dialog_button_ok = findViewById(R.id.custom_dialog_button_ok)
        custom_dialog_button_ko = findViewById(R.id.custom_dialog_button_ko)*/

          binding = ComponentCustomDialogBinding.inflate(layoutInflater)
          setContentView(binding.root)
    }

    fun setTitle(title: String): CustomDialogMainActivity {
       /* custom_dialog_title.visibility = View.VISIBLE
        custom_dialog_title.text = title*/
         binding.customDialogTitle.visibility = View.VISIBLE
         binding.customDialogTitle.text = title

        return this
    }

    fun setDescription(description: String): CustomDialogMainActivity {
       /* custom_dialog_description.visibility = View.VISIBLE
        custom_dialog_description.text = description
        */
        binding.customDialogDescription.visibility = View.VISIBLE
        binding.customDialogDescription.text = description
        return this
    }

    fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogMainActivity {
       /* custom_dialog_button_ok.visibility = View.VISIBLE
        custom_dialog_button_ok.text = text
        custom_dialog_button_ok.setOnClickListener { onButtonClicked() }*/
          binding.customDialogButtonOk.visibility = View.VISIBLE
          binding.customDialogButtonOk.text = text
          binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }
        return this
    }

    fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogMainActivity {
       /* custom_dialog_button_ko.visibility = View.VISIBLE
        custom_dialog_button_ko.text = text
        custom_dialog_button_ko.setOnClickListener { onButtonClicked() }*/
         binding.customDialogButtonKo.visibility = View.VISIBLE
         binding.customDialogButtonKo.text = text
         binding.customDialogButtonKo.setOnClickListener { onButtonClicked() }
        return this
    }

}