<?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>
        <import type="it.integry.integrywmsnative.R" />
        <import type="android.view.View" />
        <import type="it.integry.integrywmsnative.core.utility.UtilityString" />
        <import type="it.integry.integrywmsnative.core.utility.UtilityNumber" />

        <variable
            name="item"
            type="it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromMtbAartListItemModel" />
    </data>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="8dp"
        android:layout_marginVertical="4dp"
        android:background="@drawable/bg_checked_layout"
        android:onClick="@{() -> item.selected.toggle()}"
        android:padding="8dp"
        app:backgroundTintResID="@{item.selected.get() ? R.color.bg_checked_layout : android.R.color.transparent}">

        <androidx.appcompat.widget.AppCompatCheckBox
            android:id="@+id/checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:minWidth="0dp"
            android:minHeight="0dp"
            app:checked="@{item.selected}" />

        <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/linearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toStartOf="@id/qta_box"
            android:layout_toEndOf="@id/checkbox"
            android:layout_marginStart="8dp"
            android:orientation="vertical">


            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">


                <androidx.appcompat.widget.AppCompatTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@{item.codMart}"
                    android:textColor="@color/colorPrimary"
                    android:textSize="14sp"
                    android:textStyle="bold"
                    tools:text="COD MART" />


                <androidx.appcompat.widget.AppCompatTextView
                    style="@style/AppTheme.NewMaterial.Text.Small"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:background="@drawable/badge_round_corner"
                    android:backgroundTint="@color/orange_600"
                    android:paddingStart="6dp"
                    android:paddingEnd="6dp"
                    android:text="@{UtilityNumber.decimalToString(item.peso) + item.pesoUntMis}"
                    android:textColor="@android:color/white"
                    android:textSize="14sp"
                    android:textStyle="bold"
                    android:visibility="@{item.peso != null ? View.VISIBLE : View.GONE}"
                    tools:text="PESO KG" />

            </RelativeLayout>

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{item.diacod}"
                android:textColor="@color/red_600"
                android:textSize="14sp"
                android:textStyle="bold"
                android:visibility="@{UtilityString.isNullOrEmpty(item.diacod) ? View.GONE : View.VISIBLE}"
                tools:text="DIACOD" />


            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:maxLines="2"
                android:text="@{item.descrizione}"
                android:textColor="@android:color/black"
                android:textSize="16sp"
                tools:text="Descrizione lunga articolo" />


        </androidx.appcompat.widget.LinearLayoutCompat>


        <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/qta_box"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_centerVertical="true"
            android:layout_marginStart="12dp"
            android:gravity="center_horizontal"
            android:background="@drawable/badge_round_corner"
            android:backgroundTint="@color/colorPrimary"
            android:visibility="@{item.qta != null ? View.VISIBLE : View.GONE}">

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:paddingLeft="6dp"
                android:paddingTop="2dp"
                android:paddingRight="6dp"
                android:paddingBottom="2dp"
                android:textAllCaps="true"
                android:textColor="@android:color/white"
                android:textSize="16sp"
                android:textStyle="bold"
                android:text="@{UtilityNumber.decimalToString(item.qta, 2)}"
                tools:text="280.45" />

            <androidx.appcompat.widget.AppCompatTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:paddingLeft="6dp"
                android:paddingTop="2dp"
                android:paddingRight="6dp"
                android:paddingBottom="2dp"
                android:textAllCaps="true"
                android:textColor="@android:color/white"
                android:textSize="16sp"
                android:textStyle="bold"
                android:text="@{item.qtaUntMis}"
                tools:text="CONF" />

        </androidx.appcompat.widget.LinearLayoutCompat>


    </RelativeLayout>
</layout>