<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>

        <import type="android.view.View" />
        <import type="it.integry.integrywmsnative.core.utility.UtilityDate" />
        <import type="it.integry.integrywmsnative.core.utility.UtilityString" />

        <variable
            name="item"
            type="it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO" />

    </data>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:paddingStart="8dp"
        android:paddingTop="12dp"
        android:paddingEnd="8dp"
        android:paddingBottom="12dp">


        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/badge1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/badge_round_corner"
            android:backgroundTint="@color/colorPrimary"
            android:paddingLeft="8dp"
            android:paddingTop="2dp"
            android:paddingRight="8dp"
            android:paddingBottom="2dp"
            android:text="@{&quot;Numero &quot; + item.idInventario.toString()}"
            android:textColor="@android:color/white"
            android:textStyle="bold"
            tools:text="Numero 670" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/badge2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/badge_round_corner"
            android:backgroundTint="@color/red_400"
            android:layout_marginStart="8dp"
            android:paddingLeft="8dp"
            android:paddingTop="2dp"
            android:paddingRight="8dp"
            android:paddingBottom="2dp"
            android:layout_toEndOf="@+id/badge1"
            android:text="@string/new_item"
            android:textColor="@android:color/white"
            android:visibility="@{item.isNew() ? View.VISIBLE : View.GONE}"
            android:textStyle="bold" />


        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/date"
            style="@style/AppTheme.NewMaterial.Text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_toEndOf="@+id/badge2"
            android:text="@{UtilityDate.formatDate(item.dataInventario, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)}"
            android:textAlignment="textEnd"
            android:textColor="@color/colorPrimaryGray"
            android:textSize="14sp"
            tools:text="13 Apr 2022" />


        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/causale"
            style="@android:style/TextAppearance.Small"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/badge1"
            android:layout_marginTop="4dp"
            android:layout_marginEnd="4dp"
            android:layout_toStartOf="@id/zona"
            android:ellipsize="end"
            android:singleLine="true"
            tools:text="Causale tal dei tali"
            android:text="@{item.causale}"
            android:visibility="@{UtilityString.isNullOrEmpty(item.causale) ? View.GONE : View.VISIBLE}"/>


        <androidx.appcompat.widget.AppCompatTextView
            style="@android:style/TextAppearance.Small"
            android:alpha="0.6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/causale"
            android:layout_marginTop="2dp"
            android:layout_marginEnd="4dp"
            android:layout_toStartOf="@id/zona"
            android:ellipsize="end"
            android:singleLine="true"
            android:text="@string/not_synchronized"
            app:reverse_visibility="@{item.syncronized}"/>


        <androidx.appcompat.widget.AppCompatTextView
            style="@android:style/TextAppearance.Small"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/causale"
            android:layout_marginTop="4dp"
            android:layout_marginEnd="4dp"
            android:layout_toStartOf="@id/zona"
            android:ellipsize="end"
            android:singleLine="true"
            android:text="@{&quot;Sincronizzato il &quot; + UtilityDate.formatDate(item.remoteSyncDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)}"
            app:visibility="@{item.syncronized}" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/zona"
            style="@style/AppTheme.NewMaterial.Text.Badge"
            android:textSize="12sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/date"
            android:layout_alignParentEnd="true"
            android:layout_marginTop="4dp"
            android:text="@{item.zona}"
            app:visibility="@{UtilityString.isNullOrEmpty(item.zona) ? View.GONE : View.VISIBLE}"
            android:textAllCaps="true"
            tools:text="fresco" />
    </RelativeLayout>

</layout>