package es.verdnatura.presentation.view.component

import android.app.Dialog
import android.content.Context
import android.view.View
import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomThreeDialogBinding


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

    private var binding: ComponentCustomThreeDialogBinding = ComponentCustomThreeDialogBinding.inflate(layoutInflater)

    init {

        setContentView(binding.root)
        //setContentView(R.layout.component_custom_three_dialog)
    }


    fun setTitle(title: String): CustomDialogThreeButtons {

        binding.customDialogTitle.visibility= View.VISIBLE
        binding.customDialogTitle.text=title
       /* custom_dialog_title.visibility = View.VISIBLE
        custom_dialog_title.text = title*/
        return this
    }

    fun setDescription(description: String): CustomDialogThreeButtons {
        binding.customDialogDescription.visibility= View.VISIBLE
        binding.customDialogDescription.text=description

       /* custom_dialog_description.visibility = View.VISIBLE
        custom_dialog_description.text = description*/
        return this
    }

    fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {

        binding.customDialogButtonOk.visibility = View.VISIBLE
        binding.customDialogButtonOk.text =text
        binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }

      /*  custom_dialog_button_ok.visibility = View.VISIBLE
        custom_dialog_button_ok.text = text
        custom_dialog_button_ok.setOnClickListener { onButtonClicked() }*/
        return this
    }


    fun getValue() : String {
        return binding.customDialogValue.text.toString()
        //return custom_dialog_value.text.toString()
    }

    fun getEditText() : TextInputEditText {
        return binding.customDialogValue
        //return custom_dialog_value
    }
    fun setValue(value : String): CustomDialogThreeButtons{

        binding.customDialogValue.setText(value)
        binding.textinputlayout.visibility = View.VISIBLE
       /* custom_dialog_value.setText(value)
        textinputlayout.visibility = View.VISIBLE*/
        return this
    }

    fun setOkButtonTwo(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {

        binding.customDialogButtonOkTwo.visibility = View.VISIBLE
        binding.customDialogButtonOkTwo.text = text
        binding.customDialogButtonOkTwo.setOnClickListener { onButtonClicked() }

      /*  custom_dialog_button_ok_two.visibility = View.VISIBLE
        custom_dialog_button_ok_two.text = text
        custom_dialog_button_ok_two.setOnClickListener { onButtonClicked() }*/
        return this
    }

    fun setOkButtonThree(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {

        binding.customDialogButtonOkThree.visibility = View.VISIBLE
        binding.customDialogButtonOkThree.text = text
        binding.customDialogButtonOkThree.setOnClickListener { onButtonClicked() }

      /*  custom_dialog_button_ok_three.visibility = View.VISIBLE
        custom_dialog_button_ok_three.text = text
        custom_dialog_button_ok_three.setOnClickListener { onButtonClicked() }*/
        return this
    }

    fun setOkButtonFour(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {
        binding.customDialogButtonOkFour.visibility = View.VISIBLE
        binding.customDialogButtonOkFour.text = text
        binding.customDialogButtonOkFour.setOnClickListener { onButtonClicked() }

       /* custom_dialog_button_ok_four.visibility = View.VISIBLE
        custom_dialog_button_ok_four.text = text
        custom_dialog_button_ok_four.setOnClickListener { onButtonClicked() }*/
        return this
    }

    fun setOkButtonAdd(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {

        binding.customDialogButtonAdd.visibility = View.VISIBLE
        binding.customDialogButtonAdd.text = text
        binding.customDialogButtonAdd.setOnClickListener { onButtonClicked() }

     /*   custom_dialog_button_add.visibility = View.VISIBLE
        custom_dialog_button_add.text = text
        custom_dialog_button_add.setOnClickListener { onButtonClicked() }*/
        return this
    }

    fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogThreeButtons {

        binding.customDialogButtonKo.visibility = View.VISIBLE
        binding.customDialogButtonKo.text = text
        binding.customDialogButtonKo.setOnClickListener { onButtonClicked() }

       /* custom_dialog_button_ko.visibility = View.VISIBLE
        custom_dialog_button_ko.text = text
        custom_dialog_button_ko.setOnClickListener { onButtonClicked() }*/
        return this
    }

    fun setCustomDialogValue(visibility:Int){
        binding.customDialogValue.visibility=visibility
    }
    fun setFocusDialogValue(){
        binding.customDialogValue.requestFocus()
    }
}