<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) Kuba Szczodrzyński 2019-11-11.
  -->

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <data>
        <import type="android.view.View"/>
        <import type="pl.szczodrzynski.edziennik.App"/>
        <variable
            name="lesson"
            type="pl.szczodrzynski.edziennik.data.db.modules.timetable.LessonFull" />
        <variable name="oldSubjectName" type="String" />
        <variable name="subjectName" type="String" />
        <variable name="oldTeacherName" type="String" />
        <variable name="teacherName" type="String" />
        <variable name="oldClassroom" type="String" />
        <variable name="classroom" type="String" />
        <variable name="oldTeamName" type="String" />
        <variable name="teamName" type="String" />
    </data>
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="16dp"
            android:paddingTop="24dp"
            android:paddingRight="16dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:baselineAligned="false"
                android:orientation="horizontal">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_weight="1">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{oldSubjectName}"
                        android:textIsSelectable="true"
                        android:textAppearance="@style/NavView.TextView.Medium"
                        android:textColor="?android:textColorTertiary"
                        android:visibility="@{oldSubjectName == null ? View.GONE : View.VISIBLE}"
                        app:strikeThrough="@{true}"
                        tools:text="pracownia urządzeń techniki komputerowej" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{subjectName}"
                        android:textIsSelectable="true"
                        android:textAppearance="@style/NavView.TextView.Title"
                        android:visibility="@{subjectName == null ? View.GONE : View.VISIBLE}"
                        tools:text="pracownia urządzeń techniki komputerowej" />

                    <TextView
                        android:id="@+id/lessonDate"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textIsSelectable="true"
                        android:textAppearance="@style/NavView.TextView.Subtitle"
                        tools:text="czwartek, 14 listopada 2019"
                        tools:visibility="visible" />

                </LinearLayout>

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

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@string/dialog_lesson_details_number"
                        android:visibility="@{lesson.displayLessonNumber == null ? View.GONE : View.VISIBLE}"/>

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="sans-serif-light"
                        android:text="@{lesson.displayLessonNumber.toString()}"
                        android:textSize="36sp"
                        android:visibility="@{lesson.displayLessonNumber == null ? View.GONE : View.VISIBLE}"
                        tools:text="4" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@{lesson.displayStartTime.stringHM + ` - ` + lesson.displayEndTime.stringHM}"
                        tools:text="14:55 - 15:40" />

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/shiftedLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginRight="8dp"
                android:baselineAligned="false"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/shiftedText"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textSize="16sp"
                    android:textStyle="italic"
                    tools:text="Lekcja przeniesiona na czwartek, 17 października" />

                <Button
                    android:id="@+id/shiftedGoTo"
                    style="@style/Widget.MaterialComponents.Button.OutlinedButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/dialog_lesson_go_to_button" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginRight="8dp"
                android:baselineAligned="false"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginEnd="8dp"
                    android:layout_marginRight="8dp"
                    android:orientation="vertical"
                    android:visibility="@{teacherName != null || oldTeacherName != null ? View.VISIBLE : View.GONE}">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@string/dialog_lesson_details_teacher" />
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@{oldTeacherName}"
                        android:textIsSelectable="true"
                        android:singleLine="true"
                        android:visibility="@{oldTeacherName != null ? View.VISIBLE : View.GONE}"
                        app:strikeThrough="@{true}"
                        tools:text="Janósz Kowalski" />
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@{teacherName}"
                        android:textIsSelectable="true"
                        android:visibility="@{teacherName != null ? View.VISIBLE : View.GONE}"
                        tools:text="Janósz Kowalski" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:visibility="@{teamName != null || oldTeamName != null ? View.VISIBLE : View.GONE}">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@string/dialog_lesson_details_team" />
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@{oldTeamName}"
                        android:textIsSelectable="true"
                        android:visibility="@{oldTeamName != null ? View.VISIBLE : View.GONE}"
                        app:strikeThrough="@{true}"
                        tools:text="013 informatyczna" />
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@{teamName}"
                        android:textIsSelectable="true"
                        android:visibility="@{teamName != null ? View.VISIBLE : View.GONE}"
                        tools:text="013 informatyczna" />
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:baselineAligned="false"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:visibility="@{classroom != null || oldClassroom != null ? View.VISIBLE : View.GONE}">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@string/dialog_lesson_details_classroom" />
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@{oldClassroom}"
                        android:textIsSelectable="true"
                        android:visibility="@{oldClassroom != null ? View.VISIBLE : View.GONE}"
                        app:strikeThrough="@{true}"
                        tools:text="013 informatyczna" />
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@{classroom}"
                        android:textIsSelectable="true"
                        android:visibility="@{classroom != null ? View.VISIBLE : View.GONE}"
                        tools:text="013 informatyczna" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:visibility="@{App.devMode ? View.VISIBLE : View.GONE}">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:textAppearance="@style/NavView.TextView.Helper"
                        android:text="@string/dialog_lesson_details_id" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="0dp"
                        android:text="@{Long.toString(lesson.id)}"
                        android:textIsSelectable="true"
                        tools:text="12345" />
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/eventsNoData"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:paddingTop="16dp"
                android:paddingBottom="16dp"
                android:orientation="vertical"
                android:visibility="gone"
                tools:visibility="visible">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:drawableTop="@drawable/ic_no_events"
                    android:drawablePadding="16dp"
                    android:fontFamily="sans-serif-light"
                    android:text="@string/dialog_lesson_no_events"
                    android:textSize="24sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/dialog_no_events_hint"
                    android:gravity="center"
                    android:textStyle="italic"/>

            </LinearLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/eventsView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:clipToPadding="false"
                tools:visibility="visible"
                tools:listitem="@layout/event_list_item" />

        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
</layout>
