feat parkingShelving #refs 6382

This commit is contained in:
Sergio De la torre 2024-06-18 12:41:44 +02:00
parent b796623e13
commit bf20906042
2 changed files with 40 additions and 28 deletions

View File

@ -41,6 +41,15 @@ fun EditText.toInt(): Int {
return this.text.toString().toInt() return this.text.toString().toInt()
} }
fun String.isParking(): Boolean {
val regex = Regex("[\\S-\\S]{5,}")
return regex.matches(this)
}
fun String.isShelving(): Boolean {
val regex = Regex("\\S{0,4}")
return regex.matches(this)
}
fun EditText.toLong(): Long { fun EditText.toLong(): Long {
return this.text.toString().toLong() return this.text.toString().toLong()
} }

View File

@ -1,10 +1,13 @@
package es.verdnatura.presentation.view.feature.delivery.adapters package es.verdnatura.presentation.view.feature.delivery.adapters
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.ItemExpeditionSummaryRowBinding import es.verdnatura.databinding.ItemExpeditionSummaryRowBinding
import es.verdnatura.presentation.common.AdapterCallback
import es.verdnatura.presentation.common.OnAddressRowClickListener import es.verdnatura.presentation.common.OnAddressRowClickListener
import es.verdnatura.presentation.common.OnItemImageLoadRowClickListener import es.verdnatura.presentation.common.OnItemImageLoadRowClickListener
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
@ -12,10 +15,10 @@ import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSumm
class ExpeditionSummaryAdapter( class ExpeditionSummaryAdapter(
private val items: List<ExpeditionInfoSummary>, private val items: List<ExpeditionInfoSummary>,
private val onAddressRowClickListener: OnAddressRowClickListener, private val onAddressRowClickListener: OnAddressRowClickListener,
private val onItemImageLoadRowClickListener: OnItemImageLoadRowClickListener private val onItemImageLoadRowClickListener: OnItemImageLoadRowClickListener,
private val adapterCallBack: AdapterCallback
) : RecyclerView.Adapter<ExpeditionSummaryAdapter.ItemHolder>() { ) : RecyclerView.Adapter<ExpeditionSummaryAdapter.ItemHolder>() {
private var positionSelected: Int = -1
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder( return ItemHolder(
ItemExpeditionSummaryRowBinding.inflate( ItemExpeditionSummaryRowBinding.inflate(
@ -34,10 +37,7 @@ class ExpeditionSummaryAdapter(
onAddressRowClickListener.onAddressRowClickListener(items[position]) onAddressRowClickListener.onAddressRowClickListener(items[position])
} }
/* holder.binding.txtConsignatario.setOnClickListener {
onAddressRowClickListener.onAddressRowClickListener(items[position])
}
*/
} }
inner class ItemHolder( inner class ItemHolder(
@ -47,36 +47,39 @@ class ExpeditionSummaryAdapter(
fun bind(item: ExpeditionInfoSummary) { fun bind(item: ExpeditionInfoSummary) {
binding.apply { binding.apply {
if (item.delivery != item.total) { val color = getColorBackground(item)
fondo.setBackgroundColor( fondo.setBackgroundColor(color)
res.getColor(R.color.verdnatura_pumpkin_light)
)
} else {
fondo.setBackgroundColor(res.getColor(R.color.verdnatura_black))
}
if (item.delivered == item.total) {
fondo.setBackgroundColor(res.getColor(R.color.verdnatura_black))
}
showExp.setOnClickListener { showExp.setOnClickListener {
onItemImageLoadRowClickListener.onItemImageLoadRowClickListener(item) onItemImageLoadRowClickListener.onItemImageLoadRowClickListener(item)
} }
//tarea 7278
/*binding.imgItemSelected.visibility = if (adapterCallBack.getPosition() == absoluteAdapterPosition) {
if (positionSelected == absoluteAdapterPosition) { val border = GradientDrawable()
View.VISIBLE border.shape = GradientDrawable.RECTANGLE
} else { border.setStroke(2, Color.WHITE)
View.GONE border.setColor(color)
}*/ fondo.background = border
}
this.item = item this.item = item
} }
} }
}
fun changePositionSelected(position: Int) { private fun getColorBackground(item: ExpeditionInfoSummary): Int {
notifyItemChanged(positionSelected) var color: Int
positionSelected = position if (item.delivery != item.total) {
notifyItemChanged(position) color = res.getColor(R.color.verdnatura_pumpkin_light)
} else {
color = res.getColor(R.color.verdnatura_black)
}
if (item.delivered == item.total) {
color = res.getColor(R.color.verdnatura_black)
}
return color
}
} }
} }