package es.verdnatura.presentation.view.component

import android.app.Dialog
import android.content.Context
import android.text.InputType
import android.view.View
import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomEditDialogThreeValuesBinding
import es.verdnatura.databinding.ComponentCustomEditDialogTwoValuesBinding


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

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


    init {

        setContentView(binding.root)


    }

    fun getEditText(): TextInputEditText {

        return binding.customDialogValueOne


    }

    fun getEditTextTwo(): TextInputEditText {

        return binding.customDialogValueTwo

    }

    fun getValue(): String {

        return binding.customDialogValueOne.text.toString()


    }

    fun getValueTwo(): String {

        return binding.customDialogValueTwo.text.toString()

    }
    fun getValueThree(): String {

        return binding.customDialogValueThree.text.toString()

    }

    fun setValue(value: String): CustomDialogInputThreeValues {

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


        return this
    }
    fun setValueTwo(value: String): CustomDialogInputThreeValues {

        binding.customDialogValueTwo.setText(value)
        binding.customDialogValueOne.visibility = View.VISIBLE


        return this
    }
    fun setEnableValue(isEnabled: Boolean): CustomDialogInputThreeValues {

        binding.customDialogValueOne.isEnabled=isEnabled


        return this
    }
    fun setTitle(title: String): CustomDialogInputThreeValues {

        binding.customDialogTitle.visibility = View.VISIBLE
        binding.customDialogTitle.text = title

        return this
    }

    fun setDescription(description: String): CustomDialogInputThreeValues {

        binding.customDialogDescription.visibility = View.VISIBLE
        binding.customDialogDescription.text = description


        return this
    }

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

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

        return this
    }

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

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


        return this
    }


    fun setInfoTex(text:String,text2:String,text3:String){
        binding.customDialogValueOne.hint = text
        binding.customDialogValueTwo.hint = text2
        binding.customDialogValueThree.hint = text3
    }



    fun setInputTextTwoVisibility() {
        binding.textinputlayoutTwo.visibility = View.VISIBLE
    }
    fun setInputTextVisibility(visibility:Int) {
        binding.textinputlayoutTwo.visibility = visibility
    }

    fun setFocusText() {
        binding.customDialogValueOne.requestFocus()
    }

    fun setFocusTextTwo() {
        binding.customDialogValueTwo.requestFocus()
    }
    fun setFocusTextThree() {
        binding.customDialogValueThree.requestFocus()
    }
}