<?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="androidx.core.content.ContextCompat" />

        <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="it.integry.integrywmsnative.R" />

        <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.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="vertical"
        app:cardCornerRadius="12dp"
        app:cardElevation="0dp">

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

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?attr/colorPrimary"
                android:minWidth="550dp"
                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:backgroundTint="@android:color/transparent"
                    android:onClick="@{() -> view.resetValues()}"
                    android:scaleType="fitCenter"
                    android:src="@drawable/ic_erase"
                    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>

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

                <androidx.appcompat.widget.LinearLayoutCompat
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="16dp"
                    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"
                            android:paddingEnd="2dp"
                            tools:layout_weight="0.34">

                            <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"
                                android:singleLine="true"
                                app:binding="@{view.selectedMtbTcol}" />


                        </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"
                            android:layout_weight="0.66"
                            android:hint="@string/production_line"
                            android:paddingStart="2dp"
                            app:visibility="@{view.enabledLineeProd}">

                            <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"
                                android:singleLine="true"
                                app:binding="@{view.selectedLineaProd}" />


                        </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:layout_weight="1"
                            android:enabled="@{view.enabledNumCnf}"
                            android:focusableInTouchMode="false"
                            android:paddingEnd="4dp">

                            <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:enabled="@{view.enabledNumCnf}"
                                android:hint="@string/pcks_x_ped"
                                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: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"
                                android:textColor="@{ContextCompat.getColor(context, view.enabledQtaCnf ? android.R.color.black : R.color.gray_400)}"
                                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:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:enabled="@{view.enabledQtaTot}"
                                android:hint="@string/net_weight"
                                android:inputType="number"
                                android:textColor="@{ContextCompat.getColor(context, view.enabledQtaTot ? android.R.color.black : R.color.gray_400)}"
                                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:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:enabled="@{view.enabledTaraPed}"
                                android:hint="@string/tare_lu"
                                android:imeOptions="actionDone"
                                android:inputType="number"
                                android:textColor="@{ContextCompat.getColor(context, view.enabledTaraPed ? android.R.color.black : R.color.gray_400)}"
                                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:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:enabled="@{view.enabledTaraCol}"
                                android:hint="@string/tare_pckg"
                                android:imeOptions="actionDone"
                                android:inputType="numberDecimal"
                                android:textColor="@{ContextCompat.getColor(context, view.enabledTaraCol ? android.R.color.black : R.color.gray_400)}"
                                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">

                            <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_marginStart="4dp"
                            android:layout_marginEnd="4dp"
                            android:layout_weight="0.4"
                            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="4dp"
                            android:layout_marginEnd="0dp"
                            android:layout_weight="0.45"
                            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>

            </ScrollView>

        </androidx.appcompat.widget.LinearLayoutCompat>

    </androidx.cardview.widget.CardView>

</layout>