package es.verdnatura.presentation.view.component

import android.app.Dialog
import android.content.Context
import android.view.View
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomDialogBinding
//import kotlinx.android.synthetic.main.component_custom_dialog.*

//import kotlinx.android.synthetic.main.component_custom_dialog.*
//import es.verdnatura.databinding.ComponentCustomDialogBinding

private lateinit var binding: ComponentCustomDialogBinding

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

    init {

       //setContentView(R.layout.component_custom_dialog)
        //sergio: lo nuevo para quitar synthetic de kotlin

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

    }


    fun setTitle(title: String): CustomDialog {
        /*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): CustomDialog {
        /*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): CustomDialog {
       /* 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): CustomDialog {
      /*  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
    }

}