<?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="viewmodel"
            type="it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dialog.EditArticoloDialog" />
    </data>

    <androidx.cardview.widget.CardView
        android:id="@+id/base_root"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="vertical"
        app:cardCornerRadius="12dp"
        app:cardElevation="0dp">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <RelativeLayout
                android:id="@+id/title_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/light_blue_300"
                android:gravity="center_horizontal">

            </RelativeLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="24dp">

                <RelativeLayout
                    android:id="@+id/dialog_actions"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    >

                    <androidx.appcompat.widget.AppCompatTextView
                        android:id="@+id/dialog_title"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="8dp"
                        android:ellipsize="end"
                        android:text="@string/insert_qty"
                        android:paddingTop="6dp"
                        android:paddingBottom="6dp"
                        android:gravity="center"
                        android:textColor="@android:color/primary_text_light"
                        android:textSize="18sp"
                        android:textStyle="bold"/>

                </RelativeLayout>
                <RelativeLayout
                    android:id="@+id/dialog_info"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:id="@+id/cod_mart"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textColor="@color/colorPrimary"
                        android:layout_marginBottom="8dp"
                        android:ellipsize="end"
                        android:text="@{viewmodel.articolo.codMart}"
                        android:textSize="18sp"
                        android:textStyle="bold"
                        tools:text="codMart" />

                    <androidx.appcompat.widget.AppCompatTextView
                        android:id="@+id/descr_art"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/cod_mart"
                        android:ellipsize="end"
                        android:text="@{viewmodel.articolo.descrizione}"
                        android:textSize="16sp"
                        android:textStyle="bold"
                        tools:text="DESCR ART" />
                </RelativeLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:orientation="horizontal">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Unità di misura: "
                        android:textSize="16sp" />

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="4dp"
                        android:text="@{viewmodel.articolo.untMis}"
                        android:textSize="16sp"
                        android:textStyle="bold"
                        tools:text="(UM)" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:orientation="horizontal">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Qta media settimanale: "
                        android:textSize="16sp" />

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="4dp"
                        android:text='@{UtilityNumber.decimalToString(viewmodel.articolo.mediaSett)}'
                        android:textSize="16sp"
                        android:textStyle="bold"
                        tools:text="1150" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:orientation="horizontal">

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Qta per confezione: "
                        android:textSize="16sp" />

                    <androidx.appcompat.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingStart="4dp"
                        android:text='@{UtilityNumber.decimalToString(viewmodel.articolo.qtaCnf)}'
                        android:textSize="16sp"
                        android:textStyle="bold"
                        tools:text="5" />

                </LinearLayout>


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:orientation="vertical">


                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="horizontal"
                        android:weightSum="2">

                        <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/qta_cnf_label"
                            style="@style/TextInputLayout.OutlinePrimary"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginEnd="8dp"
                            android:layout_marginBottom="16dp"
                            android:layout_weight="1"
                            app:layout_constraintEnd_toStartOf="@id/guide_right"
                            app:layout_constraintStart_toStartOf="@id/guide_left"
                            app:layout_constraintTop_toTopOf="parent">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/qta_cnf"
                                style="@style/TextInputEditText.OutlinePrimary"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="@string/packages"
                                android:inputType="number"
                                android:selectAllOnFocus="true" />

                        </com.google.android.material.textfield.TextInputLayout>

                        <com.google.android.material.textfield.TextInputLayout
                            android:id="@+id/qta_tot_label"
                            style="@style/TextInputLayout.OutlinePrimary"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="8dp"
                            android:layout_marginBottom="16dp"
                            android:layout_weight="1"
                            app:layout_constraintEnd_toStartOf="@id/guide_right"
                            app:layout_constraintStart_toStartOf="@id/guide_left"
                            app:layout_constraintTop_toTopOf="parent">

                            <com.google.android.material.textfield.TextInputEditText
                                android:id="@+id/qta_tot"
                                style="@style/TextInputEditText.OutlinePrimary"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="@string/quantity"
                                android:inputType="numberDecimal"
                                android:selectAllOnFocus="true" />

                        </com.google.android.material.textfield.TextInputLayout>
                    </LinearLayout>

                    <androidx.constraintlayout.widget.ConstraintLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp">

                        <androidx.constraintlayout.widget.Guideline
                            android:id="@+id/center_guideline"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            app:layout_constraintGuide_percent="0.5"/>


                        <com.google.android.material.button.MaterialButton
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            style="@style/Button.PrimaryOutline"
                            android:layout_marginLeft="8dp"
                            android:layout_marginRight="8dp"
                            app:layout_constraintTop_toTopOf="parent"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintEnd_toStartOf="@id/center_guideline"
                            android:onClick="@{()->viewmodel.cancel()}"
                            app:strokeColor="@color/colorPrimary"
                            android:text="@string/abort"/>


                        <com.google.android.material.button.MaterialButton
                            android:id="@+id/add_button"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            style="@style/Button.PrimaryFull"
                            android:layout_marginLeft="8dp"
                            android:layout_marginRight="8dp"
                            app:layout_constraintTop_toTopOf="parent"
                            app:layout_constraintStart_toStartOf="@id/center_guideline"
                            app:layout_constraintEnd_toEndOf="parent"
                            android:focusable="true"
                            android:onClick="@{()->viewmodel.saveAndExit()}"
                            android:text="@string/add"/>


                    </androidx.constraintlayout.widget.ConstraintLayout>




                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

    </androidx.cardview.widget.CardView>

</layout>