<?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.UtilityString" />

        <import type="it.integry.integrywmsnative.core.utility.UtilityNumber" />

        <import type="it.integry.integrywmsnative.core.utility.UtilityBigDecimal" />

        <import type="android.view.View" />

        <variable
            name="viewmodel"
            type="it.integry.integrywmsnative.view.dialogs.input_lu_prod.DialogInputLUProdViewModel" />

        <variable
            name="view"
            type="it.integry.integrywmsnative.view.dialogs.input_lu_prod.DialogInputLUProdView" />
    </data>


    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@color/full_white">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:titleTextColor="@android:color/white">

            <androidx.appcompat.widget.AppCompatImageButton
                android:id="@+id/reset_values"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_gravity="end"
                android:adjustViewBounds="true"
                android:scaleType="fitCenter"
                android:src="@drawable/ic_erase"
                android:backgroundTint="@android:color/transparent"
                android:onClick="@{() -> view.resetValues()}"
                android:tint="@android:color/white" />

            <androidx.appcompat.widget.AppCompatImageButton
                android:id="@+id/read_weight_form_device"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_gravity="end"
                android:adjustViewBounds="true"
                android:backgroundTint="@android:color/transparent"
                android:onClick="@{() -> view.readWeightFromDevice()}"
                android:scaleType="fitCenter"
                android:src="@drawable/ic_scale"
                android:tint="@android:color/white" />


        </androidx.appcompat.widget.Toolbar>


        <androidx.appcompat.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="8dp"
            android:layout_marginTop="8dp"
            android:orientation="vertical">


            <androidx.appcompat.widget.AppCompatTextView
                style="@style/AppTheme.NewMaterial.Dialog.DialogTitleText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:text="@{viewmodel.mtbAart.codMart}"
                android:textColor="@color/colorPrimary"
                tools:text="COD MART (Partita mag)" />

            <androidx.appcompat.widget.AppCompatTextView
                style="@style/AppTheme.NewMaterial.Text.Small"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="4dp"
                android:singleLine="false"
                android:text="@{viewmodel.mtbAart.descrizioneEstesa}"
                tools:text="RAD 25 D H/L 200 - 10 EL B BIANCO" />

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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_cod_tcol"
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:layout_weight="@{view.enabledLineeProd ? 0.34f : 1f}"
                    android:hint="@string/lu_type"
                    tools:layout_weight="0.34"
                    android:paddingEnd="2dp">

                    <androidx.appcompat.widget.AppCompatAutoCompleteTextView
                        android:id="@+id/filled_exposed_dropdown_cod_tcol"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:imeOptions="actionNext"
                        android:inputType="textNoSuggestions"
                        android:nextFocusForward="@id/filled_exposed_dropdown_cod_jfas"
                        app:binding="@{view.selectedMtbTcol}"
                        android:singleLine="true" />


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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_cod_jfas"
                    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    app:visibility="@{view.enabledLineeProd}"
                    android:layout_weight="0.66"
                    android:hint="@string/production_line"
                    android:paddingStart="2dp">

                    <androidx.appcompat.widget.AppCompatAutoCompleteTextView
                        android:id="@+id/filled_exposed_dropdown_cod_jfas"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:imeOptions="actionNext"
                        android:inputType="textNoSuggestions"
                        android:nextFocusForward="@id/input_num_cnf_text"
                        app:binding="@{view.selectedLineaProd}"
                        android:singleLine="true" />


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

            </androidx.appcompat.widget.LinearLayoutCompat>


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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_num_cnf_layout"
                    style="@style/TextInputLayout.OutlinePrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:enabled="@{view.enabledNumCnf}"
                    android:focusableInTouchMode="false"
                    android:paddingEnd="4dp"
                    android:layout_weight="1">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/input_num_cnf_text"
                        style="@style/TextInputEditText.OutlinePrimary"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/pcks_x_ped"
                        android:enabled="@{view.enabledNumCnf}"
                        android:inputType="number"
                        android:nextFocusForward="@id/input_peso_lordo_text"
                        app:binding="@{view.currentNumCnf}" />

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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_qta_cnf_layout"
                    style="@style/TextInputLayout.OutlinePrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:enabled="@{view.enabledQtaCnf}"
                    android:focusableInTouchMode="false"
                    android:paddingEnd="4dp">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/input_qta_cnf_text"
                        style="@style/TextInputEditText.OutlinePrimary"
                        android:textColor="@{ContextCompat.getColor(context, view.enabledQtaCnf ? android.R.color.black : R.color.gray_400)}"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:enabled="@{view.enabledQtaCnf}"
                        android:hint="@string/kg_x_pck"
                        android:imeOptions="actionDone"
                        android:inputType="numberDecimal"
                        app:binding="@{view.currentPesoCollo}" />

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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_qta_tot_layout"
                    style="@style/TextInputLayout.OutlinePrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:enabled="@{view.enabledQtaTot}"
                    android:focusableInTouchMode="false"
                    android:imeOptions="actionDone">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/input_qta_tot_text"
                        style="@style/TextInputEditText.OutlinePrimary"
                        android:textColor="@{ContextCompat.getColor(context, view.enabledQtaTot ? android.R.color.black : R.color.gray_400)}"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:enabled="@{view.enabledQtaTot}"
                        android:hint="@string/net_weight"
                        android:inputType="number"
                        app:binding="@{view.currentPesoNetto}" />

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


            </androidx.appcompat.widget.LinearLayoutCompat>

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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_tara_ped_layout"
                    style="@style/TextInputLayout.OutlinePrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:enabled="@{view.enabledTaraPed}"
                    android:focusableInTouchMode="false"
                    android:paddingEnd="4dp"
                    tools:layout_weight="1">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/input_tara_ped_text"
                        style="@style/TextInputEditText.OutlinePrimary"
                        android:textColor="@{ContextCompat.getColor(context, view.enabledTaraPed ? android.R.color.black : R.color.gray_400)}"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:enabled="@{view.enabledTaraPed}"
                        android:hint="@string/tare_lu"
                        android:imeOptions="actionDone"
                        android:inputType="number"
                        app:binding="@{view.currentTaraPed}" />

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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_tara_col_layout"
                    style="@style/TextInputLayout.OutlinePrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:enabled="@{view.enabledTaraCol}"
                    android:focusableInTouchMode="false"
                    android:paddingEnd="4dp">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/input_tara_col_text"
                        style="@style/TextInputEditText.OutlinePrimary"
                        android:textColor="@{ContextCompat.getColor(context, view.enabledTaraCol ? android.R.color.black : R.color.gray_400)}"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:enabled="@{view.enabledTaraCol}"
                        android:hint="@string/tare_pckg"
                        android:imeOptions="actionDone"
                        android:inputType="numberDecimal"
                        app:binding="@{view.currentTaraCol}" />

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

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/input_peso_lordo_layout"
                    style="@style/TextInputLayout.OutlinePrimary"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:enabled="@{view.enabledPesoLordo}"
                    android:focusableInTouchMode="false"
                    android:imeOptions="actionDone"
                    tools:layout_weight="1">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/input_peso_lordo_text"
                        style="@style/TextInputEditText.OutlinePrimary"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/gross_weight"
                        android:inputType="number"
                        app:binding="@{view.currentPesoLordo}" />

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


            </androidx.appcompat.widget.LinearLayoutCompat>


            <androidx.appcompat.widget.LinearLayoutCompat
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="16dp"
                android:gravity="center_horizontal"
                android:orientation="horizontal"
                android:weightSum="1">


                <com.google.android.material.button.MaterialButton
                    android:id="@+id/abort_btn"
                    style="@style/Button.DangerFull"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="8dp"
                    android:layout_weight="0.5"
                    android:onClick="@{() -> view.dismiss()}"
                    android:paddingEnd="3dp"
                    android:text="@string/abort"
                    app:icon="@drawable/ic_close_24dp"
                    app:iconGravity="textStart"
                    app:layout_constraintTop_toTopOf="parent" />


                <com.google.android.material.button.MaterialButton
                    android:id="@+id/save_btn"
                    style="@style/Button.PrimaryFull"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="8dp"
                    android:layout_weight="0.5"
                    android:onClick="@{() -> view.save()}"
                    android:paddingEnd="3dp"
                    android:text="@string/confirm"
                    app:icon="@drawable/ic_save_24"
                    app:iconGravity="textStart"
                    app:layout_constraintTop_toTopOf="parent" />
            </androidx.appcompat.widget.LinearLayoutCompat>

        </androidx.appcompat.widget.LinearLayoutCompat>

    </androidx.appcompat.widget.LinearLayoutCompat>

</layout>