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

        <variable
            name="mainViewModel"
            type="com.doverfuelingsolutions.issp.view.LoginActivity.MainViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        style="@style/match"
        android:background="@mipmap/activity_background"
        tools:context=".view.LoginActivity">

        <LinearLayout
            android:id="@+id/loginForm"
            style="@style/fullWidth"
            android:layout_marginStart="200dp"
            android:layout_marginEnd="200dp"
            android:gravity="center"
            android:orientation="vertical"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/fieldAccount"
                style="@style/fullWidth"
                android:hint="@string/account_name"
                app:boxBackgroundColor="@color/white"
                app:startIconCheckable="true"
                app:startIconDrawable="@drawable/ic_user"
                app:startIconTint="@color/input_icon">

                <com.google.android.material.textfield.TextInputEditText
                    style="@style/fullWidth"
                    android:enabled="@{ !mainViewModel.submitting }"
                    android:inputType="text"
                    android:text="@={ mainViewModel.accountName }" />

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

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/fieldPassword"
                style="@style/fullWidth"
                android:layout_marginTop="40dp"
                android:layout_marginBottom="80dp"
                android:hint="@string/password"
                app:boxBackgroundColor="@color/white"
                app:startIconDrawable="@drawable/ic_password"
                app:startIconTint="@color/input_icon">

                <com.google.android.material.textfield.TextInputEditText
                    style="@style/fullWidth"
                    android:enabled="@{ !mainViewModel.submitting }"
                    android:inputType="textPassword"
                    android:text="@={ mainViewModel.password }" />

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

            <Button
                android:id="@+id/buttonLogin"
                style="@style/Widget.MaterialComponents.Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:enabled="@{ !mainViewModel.submitting }"
                android:text="@{ mainViewModel.submitting ? @string/in_login : @string/login }" />
        </LinearLayout>

        <Button
            android:id="@+id/buttonPreference"
            style="@style/Widget.MaterialComponents.Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:layout_marginEnd="40dp"
            android:text="@string/preference"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>