<?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">

    <data>

        <variable
            name="view"
            type="it.integry.integrywmsnative.gest.login.LoginActivity" />
    </data>


    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/colorPrimarySurface"
        android:gravity="center">

        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="32dp"
            app:cardCornerRadius="16dp">

            <ScrollView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true">

                <androidx.appcompat.widget.LinearLayoutCompat
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingLeft="24dp"
                    android:paddingTop="56dp"
                    android:paddingRight="24dp"
                    android:gravity="center_horizontal">

                    <androidx.appcompat.widget.AppCompatImageView
                        android:layout_width="wrap_content"
                        android:layout_height="72dp"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginBottom="24dp"
                        android:adjustViewBounds="true"
                        android:src="@drawable/logo_integry_testo" />

                    <!-- Username Label -->
                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/TextInputLayout.OutlinePrimary"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="8dp"
                        app:errorText="@{view.usernameError}"
                        app:hintTextAppearance="@style/hint_text">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/input_username"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:minWidth="300dp"
                            android:hint="Username"
                            android:inputType="textEmailAddress"
                            app:binding="@{view.username}" />
                    </com.google.android.material.textfield.TextInputLayout>

                    <!-- Password Label -->
                    <com.google.android.material.textfield.TextInputLayout
                        style="@style/TextInputLayout.OutlinePrimary"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="8dp"
                        app:errorText="@{view.passwordError}"
                        app:hintTextAppearance="@style/hint_text"
                        app:passwordToggleEnabled="true">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/input_password"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:minWidth="300dp"
                            android:hint="Password"
                            android:inputType="textPassword"
                            app:binding="@{view.password}" />
                    </com.google.android.material.textfield.TextInputLayout>

                    <androidx.appcompat.widget.AppCompatCheckBox
                        android:id="@+id/login_checkbox_custom_server"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:enabled="@{view.customSettingsCheckboxEnabled}"
                        android:text="@string/action_customize_server_settings"
                        app:checked="@{view.customSettingsCheckboxChecked}" />

                    <net.cachapa.expandablelayout.ExpandableLayout
                        android:id="@+id/login_layout_server_details"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingTop="6dp"
                        android:paddingBottom="12dp"
                        app:el_duration="400"
                        app:el_expanded_bind="@{view.customSettingsCheckboxChecked}">

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

                            <!--Host Label-->
                            <com.google.android.material.textfield.TextInputLayout
                                style="@style/TextInputLayout.OutlinePrimary"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="8dp"
                                app:errorText="@{view.codAziendaError}"
                                app:hintTextAppearance="@style/hint_text">

                                <com.google.android.material.textfield.TextInputEditText
                                    android:id="@+id/input_cod_azienda"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:hint="Codice azienda"
                                    android:inputType="text"
                                    app:binding="@{view.codAzienda}" />
                            </com.google.android.material.textfield.TextInputLayout>

                        </LinearLayout>

                    </net.cachapa.expandablelayout.ExpandableLayout>


                    <com.google.android.material.button.MaterialButton
                        android:id="@+id/btn_login"
                        style="@style/Widget.Material3.Button.UnelevatedButton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="24dp"
                        android:layout_marginBottom="24dp"
                        android:minWidth="170dp"
                        android:enabled="@{view.loginButtonEnabled}"
                        android:text="@string/login"
                        app:onClick="@{() -> view.login()}" />


                </androidx.appcompat.widget.LinearLayoutCompat>
            </ScrollView>
        </androidx.cardview.widget.CardView>
    </androidx.appcompat.widget.LinearLayoutCompat>
</layout>