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.ComponentCustomUbicadorDialogBinding

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

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

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

    init {

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


    fun setTitle(title: String): CustomDialogUbicador {
        binding.customDialogTitle.visibility= View.VISIBLE
        binding.customDialogTitle.text=title
        /*custom_dialog_title.visibility = View.VISIBLE
        custom_dialog_title.text = title*/
        return this
    }


    fun setItemValue(value : String) : CustomDialogUbicador{
        binding.customDialogItem.setText(value)
        binding.customDialogItem.visibility=View.VISIBLE

        /*custom_dialog_item.setText(value)
        custom_dialog_item.visibility = View.VISIBLE*/
        return this
    }

    fun getItemValue() : String{

        return binding.customDialogItem.text.toString()

      //  return custom_dialog_item.text.toString()
    }

    fun getEditItem() : TextInputEditText {

        return binding.customDialogItem
        //return custom_dialog_item
    }


    fun setEtiquetaValue(value : String) : CustomDialogUbicador{

        binding.customDialogEtiquetas.setText(value)
        binding.customDialogEtiquetas.visibility = View.VISIBLE
       /* custom_dialog_etiquetas.setText(value)
        custom_dialog_etiquetas.visibility = View.VISIBLE*/
        return this
    }

    fun getEtiquetaValue() : String{
        return binding.customDialogEtiquetas.text.toString()
        //return custom_dialog_etiquetas.text.toString()
    }

    fun getEtiquetaItem() : TextInputEditText {

        return binding.customDialogEtiquetas
        //return custom_dialog_etiquetas
    }


    fun setPackingValue(value : String) : CustomDialogUbicador{

        binding.customDialogPacking.setText(value)
        binding.customDialogPacking.visibility = View.VISIBLE

      /*  custom_dialog_packing.setText(value)
        custom_dialog_packing.visibility = View.VISIBLE*/
        return this
    }

    fun setGroupingValue(value:String):CustomDialogUbicador{
        binding.customDialogGrouping.setText(value)
        binding.customDialogGrouping.visibility = View.VISIBLE
        /*custom_dialog_grouping.setText(value)
        custom_dialog_grouping.visibility = View.VISIBLE*/
        return this
    }
    fun getGroupingValue() : String{
        return binding.customDialogGrouping.text.toString()
        //return custom_dialog_grouping.text.toString()
    }

    fun getPackingValue() : String{
        return binding.customDialogPacking.text.toString()
       // return custom_dialog_packing.text.toString()
    }

    fun getPackingItem() : TextInputEditText {
        return binding.customDialogPacking
        //return custom_dialog_packing
    }

    fun setVisibleValue(value : String) : CustomDialogUbicador{

        binding.customDialogVisible.setText(value)
        binding.customDialogVisible.visibility = View.VISIBLE

      /*  custom_dialog_visible.setText(value)
        custom_dialog_visible.visibility = View.VISIBLE*/
        return this
    }

    fun getVisibleValue() : String{

        return binding.customDialogVisible.text.toString()
        //return custom_dialog_visible.text.toString()
    }

    fun getVisibleItem() : TextInputEditText {
        return binding.customDialogVisible

        //return custom_dialog_visible
    }


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

        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 setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicador {

        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
    }

}