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

        <variable
            name="view"
            type="it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemEditView" />

        <variable
            name="viewModel"
            type="it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemEditViewModel" />
    </data>

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bottom_sheet_background"
        android:orientation="vertical"
        android:padding="16dp">


        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <androidx.appcompat.widget.LinearLayoutCompat
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:orientation="vertical"
                app:layout_constraintEnd_toStartOf="@id/qta_layout"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/bottom_sheet_actions_title"
                    style="@style/AppTheme.NewMaterial.Text.Medium"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="2"
                    android:paddingStart="0dp"
                    android:paddingEnd="8dp"
                    android:text="@{viewModel.currentItem.descrizioneArticolo}"
                    android:textColor="#444"
                    android:textStyle="bold"
                    tools:text="Descrizione articolo" />

                <androidx.appcompat.widget.AppCompatTextView
                    android:id="@+id/bottom_sheet_actions_subtitle"
                    style="@style/AppTheme.NewMaterial.Text.Small"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@{viewModel.currentItem.codMart}"
                    tools:text="ABF52IL" />

            </androidx.appcompat.widget.LinearLayoutCompat>

            <androidx.appcompat.widget.LinearLayoutCompat
                android:id="@+id/qta_layout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent">


                <androidx.appcompat.widget.LinearLayoutCompat
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        style="@style/AppTheme.NewMaterial.Text.Small"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="end"
                        android:text="@{UtilityNumber.decimalToString(viewModel.currentItem.qta)}"
                        android:textStyle="bold"
                        tools:text="250" />

                    <TextView
                        style="@style/AppTheme.NewMaterial.Text.Small"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="4dp"
                        android:gravity="end"
                        android:text="@{viewModel.currentItem.untMis}"
                        android:textStyle="bold"
                        tools:text="PZ" />

                </androidx.appcompat.widget.LinearLayoutCompat>


                <androidx.appcompat.widget.LinearLayoutCompat
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        style="@style/AppTheme.NewMaterial.Text.Small"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="end"
                        android:text="@{UtilityNumber.decimalToString(viewModel.currentItem.numCnf)}"
                        android:textStyle="bold"
                        tools:text="250" />

                    <TextView
                        style="@style/AppTheme.NewMaterial.Text.Small"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="4dp"
                        android:gravity="end"
                        android:text="@string/unt_mis_col"
                        android:textAllCaps="true"
                        android:textStyle="bold" />

                </androidx.appcompat.widget.LinearLayoutCompat>

            </androidx.appcompat.widget.LinearLayoutCompat>
        </androidx.constraintlayout.widget.ConstraintLayout>


        <androidx.appcompat.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:orientation="horizontal"
            android:weightSum="1">

            <androidx.appcompat.widget.LinearLayoutCompat
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.5"
                android:clickable="true"
                android:enabled="false"
                android:focusable="true"
                android:gravity="center"
                android:orientation="vertical"
                android:background="?attr/selectableItemBackground"
                app:layout_constraintEnd_toStartOf="@id/guideline_action"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:singleClick="@{() -> view.editItem()}"
                app:visibility="@{view.enabledEditButton}">

                <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/bottom_sheet_actions_edit_btn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:duplicateParentState="true"
                    android:padding="16dp"
                    android:scaleX="1.5"
                    android:scaleY="1.5"
                    android:src="@drawable/ic_edit_24dp"
                    android:tint="@color/green_600" />

                <androidx.appcompat.widget.AppCompatTextView
                    style="@style/AppTheme.NewMaterial.Text.Small"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:duplicateParentState="true"
                    android:text="@string/edit" />

            </androidx.appcompat.widget.LinearLayoutCompat>

            <androidx.appcompat.widget.LinearLayoutCompat
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.5"
                android:clickable="true"
                android:focusable="true"
                android:gravity="center"
                android:orientation="vertical"
                android:background="?attr/selectableItemBackground"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="@id/guideline_action"
                app:layout_constraintTop_toTopOf="parent"
                app:singleClick="@{() -> view.deleteItem()}"
                app:visibility="@{view.enabledDeleteButton ? View.VISIBLE : View.GONE}">

                <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/bottom_sheet_actions_delete_btn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="16dp"
                    android:scaleX="1.5"
                    android:scaleY="1.5"
                    android:src="@drawable/ic_delete_24dp"
                    android:tint="@color/red_600" />

                <androidx.appcompat.widget.AppCompatTextView
                    style="@style/AppTheme.NewMaterial.Text.Small"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/delete" />

            </androidx.appcompat.widget.LinearLayoutCompat>


        </androidx.appcompat.widget.LinearLayoutCompat>


    </androidx.appcompat.widget.LinearLayoutCompat>

</layout>