<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright 2019, The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<!-- Wrapping the layout into /layout to make it available with data binding. -->
<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 to make available to the XML via data binding. In this case,
     the whole ViewModel, so that we can access the LiveData,
     click handlers, and state variables. -->
    <data>

        <variable
            name="sleepQualityViewModel"
            type="com.example.android.trackmysleepquality.sleepquality.SleepQualityViewModel" />
    </data>

    <!-- Start of the visible fragment layout using ConstraintLayout -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".sleepquality.SleepQualityFragment">

        <TextView
            android:id="@+id/title_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/margin"
            android:layout_marginTop="@dimen/margin"
            android:layout_marginBottom="@dimen/triple_margin"
            android:fontFamily="@font/roboto"
            android:text="@string/how_was_hour_sleep"
            android:textSize="@dimen/title_text_size"
            app:layout_constraintBottom_toTopOf="@+id/quality_zero_image"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/quality_zero_image"
            android:layout_width="@dimen/icon_size"
            android:layout_height="@dimen/icon_size"
            android:layout_marginStart="@dimen/margin"
            android:layout_marginTop="@dimen/margin"
            android:contentDescription="@string/quality_0"
            android:onClick="@{() -> sleepQualityViewModel.onSetSleepQuality(0)}"
            app:layout_constraintEnd_toStartOf="@+id/quality_one_image"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/title_text"
            app:srcCompat="@drawable/ic_sleep_0" />

        <ImageView
            android:id="@+id/quality_one_image"
            android:layout_width="@dimen/icon_size"
            android:layout_height="@dimen/icon_size"
            android:contentDescription="@string/quality_1"
            android:onClick="@{() -> sleepQualityViewModel.onSetSleepQuality(1)}"
            app:layout_constraintBottom_toBottomOf="@+id/quality_zero_image"
            app:layout_constraintEnd_toStartOf="@+id/quality_two_image"
            app:layout_constraintStart_toEndOf="@+id/quality_zero_image"
            app:srcCompat="@drawable/ic_sleep_1" />

        <ImageView
            android:id="@+id/quality_two_image"
            android:layout_width="@dimen/icon_size"
            android:layout_height="@dimen/icon_size"
            android:layout_marginEnd="@dimen/margin"
            android:contentDescription="@string/quality_2"
            android:onClick="@{() -> sleepQualityViewModel.onSetSleepQuality(2)}"
            app:layout_constraintBottom_toBottomOf="@+id/quality_one_image"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/quality_one_image"
            app:srcCompat="@drawable/ic_sleep_2" />

        <ImageView
            android:id="@+id/quality_three_image"
            android:layout_width="@dimen/icon_size"
            android:layout_height="@dimen/icon_size"
            android:layout_marginStart="@dimen/margin"
            android:layout_marginTop="@dimen/margin"
            android:layout_marginBottom="@dimen/margin"
            android:contentDescription="@string/quality_3"
            android:onClick="@{() -> sleepQualityViewModel.onSetSleepQuality(3)}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/quality_four_image"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/quality_zero_image"
            app:layout_constraintVertical_bias="0.0"
            app:srcCompat="@drawable/ic_sleep_3" />

        <ImageView
            android:id="@+id/quality_four_image"
            android:layout_width="@dimen/icon_size"
            android:layout_height="@dimen/icon_size"
            android:contentDescription="@string/quality_4"
            android:onClick="@{() -> sleepQualityViewModel.onSetSleepQuality(4)}"
            app:layout_constraintBottom_toBottomOf="@+id/quality_three_image"
            app:layout_constraintEnd_toStartOf="@+id/quality_five_image"
            app:layout_constraintStart_toEndOf="@+id/quality_three_image"
            app:layout_constraintTop_toTopOf="@+id/quality_three_image"
            app:srcCompat="@drawable/ic_sleep_4" />

        <ImageView
            android:id="@+id/quality_five_image"
            android:layout_width="@dimen/icon_size"
            android:layout_height="@dimen/icon_size"
            android:layout_marginEnd="@dimen/margin"
            android:contentDescription="@string/quality_5"
            android:onClick="@{() -> sleepQualityViewModel.onSetSleepQuality(5)}"
            app:layout_constraintBottom_toBottomOf="@+id/quality_four_image"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/quality_four_image"
            app:layout_constraintTop_toTopOf="@+id/quality_four_image"
            app:srcCompat="@drawable/ic_sleep_5" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>
