refs #6574 feat:ui
This commit is contained in:
parent
ea305d5812
commit
b91712ea9e
|
@ -10,18 +10,17 @@ import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHisto
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
class HistoricoAdapter (
|
||||
class HistoricoAdapter(
|
||||
private val items: List<ItemHistoricoVO>
|
||||
): RecyclerView.Adapter<HistoricoAdapter.ItemHolder> () {
|
||||
|
||||
) : RecyclerView.Adapter<HistoricoAdapter.ItemHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||
return ItemHolder(
|
||||
ItemHistoricoRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||
ItemHistoricoRowBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount() =items.size
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
|
@ -29,7 +28,7 @@ class HistoricoAdapter (
|
|||
|
||||
inner class ItemHolder(
|
||||
val binding: ItemHistoricoRowBinding
|
||||
) : RecyclerView.ViewHolder(binding.root){
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
private val res = binding.root.context.resources
|
||||
fun bind(item: ItemHistoricoVO) {
|
||||
binding.apply {
|
||||
|
@ -38,14 +37,22 @@ class HistoricoAdapter (
|
|||
val sdf = SimpleDateFormat(res.getString(R.string.dateFormat))
|
||||
val currentDate = sdf.format(Date())
|
||||
|
||||
historicoDate.setBackgroundColor(ContextCompat.getColor(historicoDate.context, if (currentDate == item.shipped){R.color.verdnatura_pumpkin_orange}else{
|
||||
R.color.verdnatura_black_5
|
||||
}))
|
||||
historicoDate.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
historicoDate.context, if (currentDate == item.shipped) {
|
||||
R.color.verdnatura_pumpkin_orange
|
||||
} else {
|
||||
R.color.verdnatura_black_5
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
item?.invalue?.let {
|
||||
inQuantity.setBackgroundColor(ContextCompat.getColor(historicoDate.context,
|
||||
if (it > 0) R.color.verdnatura_dark_green_verdnatura else R.color.verdnatura_white))
|
||||
val color = if (item.invalue != null && item.invalue!! > 0) {
|
||||
R.color.verdnatura_dark_green_verdnatura
|
||||
} else {
|
||||
R.color.verdnatura_black_5
|
||||
}
|
||||
inQuantity.setBackgroundColor(ContextCompat.getColor(historicoDate.context, color))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue