refs #5652 Botones dinámicos

This commit is contained in:
Sergio De la torre 2023-09-19 07:20:32 +02:00
parent d93e34e13b
commit 400aa04046
1 changed files with 40 additions and 31 deletions

View File

@ -7,73 +7,81 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomListDialogBinding import es.verdnatura.databinding.ComponentCustomListDialogBinding
//import kotlinx.android.synthetic.main.component_custom_list_dialog.* //import kotlinx.android.synthetic.main.component_custom_list_dialog.*
class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme) { class CustomDialogList(context: Context) : Dialog(context, R.style.DialogTheme) {
private var binding: ComponentCustomListDialogBinding = ComponentCustomListDialogBinding.inflate(layoutInflater) private var binding: ComponentCustomListDialogBinding =
ComponentCustomListDialogBinding.inflate(layoutInflater)
init { init {
setContentView(binding.root) setContentView(binding.root)
//setContentView(R.layout.component_custom_list_dialog) //setContentView(R.layout.component_custom_list_dialog)
} }
fun getRecyclerView() : RecyclerView { fun getRecyclerView(): RecyclerView {
return binding.itemRecyclerview return binding.itemRecyclerview
//return item_recyclerview //return item_recyclerview
} }
fun getEditText() : TextInputEditText { fun getEditText(): TextInputEditText {
return binding.customDialogValue return binding.customDialogValue
//return custom_dialog_value //return custom_dialog_value
} }
fun getEditTextTwo() : TextInputEditText { fun getEditTextTwo(): TextInputEditText {
return binding.customDialogValueTwo return binding.customDialogValueTwo
//return custom_dialog_value_two //return custom_dialog_value_two
} }
fun getValue() : String { fun getValue(): String {
return binding.customDialogValue.text.toString() return binding.customDialogValue.text.toString()
//return custom_dialog_value.text.toString() //return custom_dialog_value.text.toString()
} }
fun setValue(value : String): CustomDialogList{ fun setValue(value: String): CustomDialogList {
binding.customDialogValue.setText(value) binding.customDialogValue.setText(value)
binding.textinputlayoutUsername.visibility=View.VISIBLE binding.textinputlayoutUsername.visibility = View.VISIBLE
/*custom_dialog_value.setText(value) /*custom_dialog_value.setText(value)
textinputlayout_username.visibility = View.VISIBLE*/ textinputlayout_username.visibility = View.VISIBLE*/
return this return this
} }
fun getValueTwo() : String { fun setValueVisibility(modifier: Int) {
binding.textinputlayoutUsername.visibility = modifier
}
fun getValueTwo(): String {
return binding.customDialogValueTwo.text.toString() return binding.customDialogValueTwo.text.toString()
//return custom_dialog_value_two.text.toString() //return custom_dialog_value_two.text.toString()
} }
fun setValueTwo(value : String): CustomDialogList{ fun setValueTwo(value: String): CustomDialogList {
binding.customDialogValueTwo.setText(value) binding.customDialogValueTwo.setText(value)
binding.textinputlayoutTwo.visibility=View.VISIBLE binding.textinputlayoutTwo.visibility = View.VISIBLE
/* custom_dialog_value_two.setText(value) /* custom_dialog_value_two.setText(value)
textinputlayout_two.visibility = View.VISIBLE*/ textinputlayout_two.visibility = View.VISIBLE*/
return this return this
} }
fun setTitle(title: String): CustomDialogList { fun setTitle(title: String): CustomDialogList {
binding.customDialogTitle.visibility=View.VISIBLE binding.customDialogTitle.visibility = View.VISIBLE
binding.customDialogTitle.text=title binding.customDialogTitle.text = title
/* custom_dialog_title.visibility = View.VISIBLE /* custom_dialog_title.visibility = View.VISIBLE
custom_dialog_title.text = title*/ custom_dialog_title.text = title*/
return this return this
} }
fun setDescription(title: String): CustomDialogList { fun setDescription(title: String): CustomDialogList {
binding.customDialogDescription.visibility=View.VISIBLE binding.customDialogDescription.visibility = View.VISIBLE
binding.customDialogDescription.text=title binding.customDialogDescription.text = title
/*custom_dialog_description.visibility = View.VISIBLE /*custom_dialog_description.visibility = View.VISIBLE
custom_dialog_description.text = title*/ custom_dialog_description.text = title*/
@ -83,8 +91,8 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogList { fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
binding.customDialogButtonOk.visibility=View.VISIBLE binding.customDialogButtonOk.visibility = View.VISIBLE
binding.customDialogButtonOk.text=text binding.customDialogButtonOk.text = text
/*custom_dialog_button_ok.visibility = View.VISIBLE /*custom_dialog_button_ok.visibility = View.VISIBLE
custom_dialog_button_ok.text = text custom_dialog_button_ok.text = text
@ -95,8 +103,8 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList { fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogList {
binding.customDialogButtonKo.visibility=View.VISIBLE binding.customDialogButtonKo.visibility = View.VISIBLE
binding.customDialogButtonKo.text=text binding.customDialogButtonKo.text = text
/*custom_dialog_button_ko.visibility = View.VISIBLE /*custom_dialog_button_ko.visibility = View.VISIBLE
custom_dialog_button_ko.text = text*/ custom_dialog_button_ko.text = text*/
binding.customDialogButtonKo.setOnClickListener { onButtonClicked() } binding.customDialogButtonKo.setOnClickListener { onButtonClicked() }
@ -104,36 +112,37 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
return this return this
} }
fun setHintValue(text:String): CustomDialogList{ fun setHintValue(text: String): CustomDialogList {
binding.customDialogValue.hint=text binding.customDialogValue.hint = text
// custom_dialog_value.hint = text // custom_dialog_value.hint = text
return this return this
} }
fun setHintValueTwo(text:String): CustomDialogList{ fun setHintValueTwo(text: String): CustomDialogList {
binding.customDialogValueTwo.hint=text binding.customDialogValueTwo.hint = text
//custom_dialog_value_two.hint = text //custom_dialog_value_two.hint = text
return this return this
} }
fun setTextTwoGone():CustomDialogList{ fun setTextTwoGone(): CustomDialogList {
binding.textinputlayoutTwo.visibility = View.GONE binding.textinputlayoutTwo.visibility = View.GONE
//textinputlayout_two.visibility = View.GONE //textinputlayout_two.visibility = View.GONE
return this return this
} }
fun hideDialog():CustomDialogList{ fun hideDialog(): CustomDialogList {
binding.customDialogValue.visibility = View.GONE binding.customDialogValue.visibility = View.GONE
//custom_dialog_value.visibility = View.GONE //custom_dialog_value.visibility = View.GONE
return this return this
} }
fun hideDescription():CustomDialogList{ fun hideDescription(): CustomDialogList {
binding.customDialogDescription.visibility = View.GONE binding.customDialogDescription.visibility = View.GONE
return this return this
} }
fun hideTextInput():CustomDialogList{
fun hideTextInput(): CustomDialogList {
binding.textinputlayoutUsername.visibility = View.INVISIBLE binding.textinputlayoutUsername.visibility = View.INVISIBLE
return this return this