refs #6413 feat:refactor Ubicador

This commit is contained in:
Sergio De la torre 2024-02-27 09:44:48 +01:00
parent cb80d58006
commit 3afe9de1c9
3 changed files with 316 additions and 3 deletions

View File

@ -0,0 +1,144 @@
package es.verdnatura.presentation.view.component
import android.app.Dialog
import android.content.Context
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import com.google.android.material.textfield.TextInputEditText
import es.verdnatura.R
import es.verdnatura.databinding.ComponentCustomUbicadorDialogNewBinding
class CustomDialogUbicadorNew(context: Context) : Dialog(context, R.style.DialogTheme) {
private var binding: ComponentCustomUbicadorDialogNewBinding =
ComponentCustomUbicadorDialogNewBinding.inflate(layoutInflater)
init {
setContentView(binding.root)
}
fun setTitle(title: String): CustomDialogUbicadorNew {
binding.customDialogTitle.visibility = View.VISIBLE
binding.customDialogTitle.text = title
return this
}
fun setItemValue(value: String): CustomDialogUbicadorNew {
binding.customDialogItem.setText(value)
binding.customDialogItem.visibility = View.VISIBLE
return this
}
fun getItemValue(): String {
return binding.customDialogItem.text.toString()
}
fun getEditItem(): TextInputEditText {
return binding.customDialogItem
}
fun setEtiquetaValue(value: String?): CustomDialogUbicadorNew {
binding.customDialogEtiquetas.setText(value ?: "")
binding.customDialogEtiquetas.visibility = View.VISIBLE
return this
}
fun setUnits(title: String): CustomDialogUbicadorNew {
binding.customDialogUnits.visibility = View.VISIBLE
binding.customDialogUnits.setText(title)
return this
}
fun getUnitsValue(): String {
return binding.customDialogUnits.text.toString()
}
fun getUnitsItem(): TextInputEditText {
return binding.customDialogUnits
}
fun getEtiquetaValue(): String {
return binding.customDialogEtiquetas.text.toString()
}
fun getEtiquetaItem(): TextInputEditText {
return binding.customDialogEtiquetas
}
fun setPackingValue(value: String): CustomDialogUbicadorNew {
binding.customDialogPacking.setText(value)
binding.customDialogPacking.visibility = View.VISIBLE
return this
}
fun getPackingValue(): String {
return binding.customDialogPacking.text.toString()
}
fun getPackingItem(): TextInputEditText {
return binding.customDialogPacking
}
fun setVisibleValue(value: String): CustomDialogUbicadorNew {
binding.customDialogVisible.setText(value)
binding.customDialogVisible.visibility = View.VISIBLE
return this
}
fun getVisibleValue(): String {
return binding.customDialogVisible.text.toString()
}
fun getVisibleItem(): TextInputEditText {
return binding.customDialogVisible
}
fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicadorNew {
binding.customDialogButtonOk.visibility = View.VISIBLE
binding.customDialogButtonOk.text = text
binding.customDialogButtonOk.setOnClickListener { onButtonClicked() }
return this
}
fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogUbicadorNew {
binding.customDialogButtonKo.visibility = View.VISIBLE
binding.customDialogButtonKo.text = text
binding.customDialogButtonKo.setOnClickListener { onButtonClicked() }
return this
}
fun addTextWatcher(editText: TextInputEditText, listener: (CharSequence?) -> Unit) {
editText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable?) {
listener(s)
}
})
}
}

View File

@ -72,9 +72,6 @@
android:textColorHint="@android:color/darker_gray" android:textColorHint="@android:color/darker_gray"
app:hintEnabled="false"> app:hintEnabled="false">
>
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_value_two" android:id="@+id/custom_dialog_value_two"
style="@style/DefaultButton.NormalButton" style="@style/DefaultButton.NormalButton"

View File

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/DialogTheme"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_margin_1"
app:cardBackgroundColor="@color/verdnatura_black_8"
app:cardCornerRadius="@dimen/dialog_radius">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/default_layout_margin">
<TextView
android:id="@+id/custom_dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_min"
android:layout_marginBottom="@dimen/layout_margin_min"
android:textAlignment="center"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"
android:textStyle="bold"
android:visibility="gone"
tools:text="¿Estás seguro de que deseas eliminar el dispositivo de celia?"
tools:visibility="visible" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_layout_margin"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_item"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="@string/itemfk"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_packing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_layout_margin"
android:layout_weight="1"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_packing"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="Packing"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_layout_margin"
android:layout_weight="1"
android:visibility="invisible"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_units"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="Unidades"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray"
android:visibility="invisible"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_etiquetas"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_layout_margin"
android:layout_weight="1"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_etiquetas"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="@string/Etiquetas"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_layout_margin"
android:layout_weight="1"
android:textColorHint="@android:color/darker_gray">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_visible"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="@string/Visible"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<Button
android:id="@+id/custom_dialog_button_ok"
style="@style/DefaultButton.NormalButton"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_layout_margin"
android:visibility="gone"
tools:text="@string/delete"
tools:visibility="visible" />
<Button
android:id="@+id/custom_dialog_button_ko"
style="@style/DefaultButton.TransparentButton"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_layout_margin"
android:layout_marginBottom="@dimen/default_layout_margin"
android:visibility="gone"
tools:text="@string/cancel"
tools:visibility="visible" />
</LinearLayout>
</androidx.cardview.widget.CardView>