<?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="fr.iut.ouafff.ui.utils.Converters" />

        <variable
            name="dogVM"
            type="fr.iut.ouafff.ui.viewmodel.DogViewModel" />
    </data>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/activity_margin"
            tools:context=".ui.activity.DogActivity">

            <androidx.constraintlayout.widget.Barrier
                android:id="@+id/barrier"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:barrierDirection="right"
                app:constraint_referenced_ids="text_overview,text_gender,text_measurement,text_aggressiveness,text_misc" />

            <TextView
                android:id="@+id/text_overview"
                style="@style/CategoryStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/category_overview"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <EditText
                android:id="@+id/edit_dog_name"
                style="@style/EditorFieldStyle"
                android:layout_width="0dp"
                android:hint="@string/hint_dog_name"
                android:importantForAutofill="no"
                android:inputType="textCapWords"
                android:text="@={dogVM.dog.name}"
                app:layout_constraintBaseline_toBaselineOf="@+id/text_overview"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/barrier" />

            <EditText
                android:id="@+id/edit_dog_breed"
                style="@style/EditorFieldStyle"
                android:layout_width="0dp"
                android:hint="@string/hint_dog_breed"
                android:importantForAutofill="no"
                android:inputType="textCapWords"
                android:text="@={dogVM.dog.breed}"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/barrier"
                app:layout_constraintTop_toBottomOf="@+id/edit_dog_name" />

            <TextView
                android:id="@+id/text_gender"
                style="@style/CategoryStyle"
                android:layout_width="wrap_content"
                android:text="@string/category_gender"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/edit_dog_breed" />

            <Spinner
                android:id="@+id/spinner_gender"
                android:layout_width="wrap_content"
                android:layout_height="@dimen/large_space"
                android:entries="@array/array_gender_options"
                android:selectedItemPosition="@={Converters.genderToInt(dogVM.dog.gender)}"
                android:spinnerMode="dropdown"
                app:layout_constraintStart_toEndOf="@id/barrier"
                app:layout_constraintTop_toTopOf="@+id/text_gender" />

            <TextView
                android:id="@+id/text_measurement"
                style="@style/CategoryStyle"
                android:layout_width="wrap_content"
                android:text="@string/category_measurement"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/spinner_gender" />

            <EditText
                android:id="@+id/edit_dog_weight"
                style="@style/EditorFieldStyle"
                android:layout_width="0dp"
                android:hint="@string/hint_dog_weight"
                android:importantForAutofill="no"
                android:inputType="numberDecimal"
                android:text="@={Converters.floatToString(dogVM.dog.weight)}"
                app:layout_constraintBaseline_toBaselineOf="@+id/text_measurement"
                app:layout_constraintEnd_toStartOf="@id/label_weight_unit"
                app:layout_constraintStart_toEndOf="@id/barrier" />

            <TextView
                android:id="@+id/label_weight_unit"
                style="@style/EditorUnitsStyle"
                android:layout_width="wrap_content"
                android:text="@string/unit_dog_weight"
                app:layout_constraintBaseline_toBaselineOf="@+id/text_measurement"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/edit_dog_weight" />

            <TextView
                android:id="@+id/text_aggressiveness"
                style="@style/CategoryStyle"
                android:layout_width="wrap_content"
                android:text="@string/category_aggressiveness"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/edit_dog_weight" />

            <RatingBar
                android:id="@+id/ratingbar_aggressiveness"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:numStars="3"
                android:rating="@={(float) dogVM.dog.aggressiveness}"
                android:stepSize="1"
                app:layout_constraintStart_toEndOf="@id/barrier"
                app:layout_constraintTop_toTopOf="@+id/text_aggressiveness" />

            <TextView
                android:id="@+id/text_misc"
                style="@style/CategoryStyle"
                android:layout_width="wrap_content"
                android:layout_marginTop="@dimen/large_space"
                android:text="@string/category_misc"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/ratingbar_aggressiveness" />

            <TextView
                android:id="@+id/text_dog_owner"
                style="@style/EditorTextStyle"
                android:layout_width="0dp"
                android:hint="@string/hint_dog_owner"
                android:text="@{dogVM.ownerLiveData}"
                app:drawableEndCompat="@drawable/ic_person"
                app:drawableRightCompat="@drawable/ic_person"
                app:layout_constraintBaseline_toBaselineOf="@+id/text_misc"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/barrier" />

            <TextView
                android:id="@+id/text_dog_admission_date"
                style="@style/EditorTextStyle"
                android:layout_width="0dp"
                android:hint="@string/hint_dog_admission_date"
                android:paddingTop="@dimen/medium_space"
                android:text="@{Converters.dateToString(context, dogVM.admissionDateLiveData)}"
                app:drawableEndCompat="@drawable/ic_time"
                app:drawableRightCompat="@drawable/ic_time"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@id/barrier"
                app:layout_constraintTop_toBottomOf="@+id/text_dog_owner" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>
</layout>