feat: refs #6869 itemShelvingGet

This commit is contained in:
Sergio De la torre 2024-11-26 10:56:53 +01:00
parent 183b265ba9
commit 7bfd17d1f7
3 changed files with 1499 additions and 0 deletions

View File

@ -0,0 +1,131 @@
package es.verdnatura.presentation.view.feature.ubicador.adapter
import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.ItemUbicationRow6869Binding
import es.verdnatura.presentation.common.OnMoreClickListener6869
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnVisibleClickListener6869
import es.verdnatura.presentation.common.loadUrl
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelving
class UbicadorAdapter6869(
private val items: List<ItemShelving>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
private val onVisibleClickListener: OnVisibleClickListener6869,
private val onMoreClickListener: OnMoreClickListener6869,
private val urlImage: String? = null
) : RecyclerView.Adapter<UbicadorAdapter6869.ItemHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemUbicationRow6869Binding.inflate(LayoutInflater.from(parent.context), parent, false)
)
}
override fun getItemCount() = items.size
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position])
}
inner class ItemHolder(
val binding: ItemUbicationRow6869Binding
) : RecyclerView.ViewHolder(binding.root) {
private val res = binding.root.context.resources
@SuppressLint("SetTextI18n")
fun bind(item: ItemShelving) {
binding.apply {
this.item = item
multiText.text = "${item.stickers}x${item.packing}"
if (urlImage != null) imgItem.loadUrl("http:$urlImage/catalog/200x200/${item.item.id}")
imgItem.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(
PasillerosItemVO(
title =
R.string.itemSearch
), item.item.id.toString()
)
}
layerVisible.setOnClickListener {
onVisibleClickListener.onVisibleClickListener(item)
}
if (item.visible == 0) {
visibleText.setTextColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_brown_grey
)
)
} else {
visibleText.setTextColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_pumpkin_orange
)
)
}
moreImg.setOnClickListener {
onMoreClickListener.onMoreClickListener(item)
}
namelayout.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(
PasillerosItemVO(
title = R.string.itemSearch
), item.item.id.toString()
)
}
if (item.isChecked != null) {
when (item.isChecked) {
0 -> itemRowLayout.setBackgroundColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_red_salix
)
)
in 1..Int.MAX_VALUE ->
if (item.visible == 0) {
itemRowLayout.setBackgroundColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_dark_sky_blue
)
)
} else {
itemRowLayout.setBackgroundColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_dark_green_verdnatura
)
)
}
}
} else {
itemRowLayout.setBackgroundColor(
ContextCompat.getColor(
visibleText.context,
R.color.verdnatura_black_5
)
)
}
}
}
}
}

View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<variable
name="item"
type="es.verdnatura.presentation.view.feature.ubicador.model.ItemShelving" />
</data>
<LinearLayout
android:id="@+id/itemLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/item_row_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/verdnatura_black_5"
android:baselineAligned="false"
android:orientation="horizontal"
android:paddingStart="@dimen/pasilleros_margin_main_menu"
android:paddingTop="@dimen/pasilleros_margin_main_menu"
android:paddingEnd="@dimen/pasilleros_margin_main_menu"
android:paddingBottom="@dimen/pasilleros_margin_main_menu">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/layout_margin_min"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="@dimen/item_image_width"
android:layout_height="@dimen/item_image_width"
android:layout_marginEnd="@dimen/layout_margin_1"
app:cardCornerRadius="100dp">
<ImageView
android:id="@+id/img_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/item" />
</androidx.cardview.widget.CardView>
<LinearLayout
android:id="@+id/namelayout"
style="@style/LayoutClickable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/itemfk_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@{String.valueOf(item.item.id)}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h8"
android:textStyle="bold" />
<TextView
android:id="@+id/longname_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@{item.description}"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h8" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layer_visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/multi_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body2"
android:textStyle="bold"
tools:text="6 x 15" />
<TextView
android:id="@+id/visible_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="@{String.valueOf(item.visible)}"
android:textColor="@color/verdnatura_pumpkin_orange"
android:textSize="@dimen/h6"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="@dimen/item_image_width_min"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/more_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/options"
android:scaleType="center"
android:src="@drawable/ic_more_vert_black_24dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/verdnatura_black_9" />
</LinearLayout>
</layout>