<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2018.
  ~
  ~ This file is part of MovieDB.
  ~
  ~ MovieDB is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ (at your option) any later version.
  ~
  ~ MovieDB is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~ along with MovieDB.  If not, see <http://www.gnu.org/licenses/>.
  -->

<android.support.design.widget.CoordinatorLayout 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="org.notabug.lifeuser.moviedb.activity.DetailActivity">

    <org.notabug.lifeuser.moviedb.NotifyingScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <requestFocus />

            <ImageView
                android:id="@+id/movieImage"
                android:layout_width="match_parent"
                android:layout_height="240dp"
                android:background="@color/colorPrimary"
                android:contentDescription="@string/movie_image_description"
                android:scaleType="centerCrop" />

            <RelativeLayout
                android:id="@+id/movieDetails"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/movieImage"
                android:layout_margin="16dp">

                <LinearLayout
                    android:id="@+id/linearMovieDetails"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <ImageView
                        android:id="@+id/moviePoster"
                        android:layout_width="125dp"
                        android:layout_height="200dp"
                        android:contentDescription="@string/image_description" />

                    <View
                        android:layout_width="10dp"
                        android:layout_height="wrap_content" />

                    <LinearLayout
                        android:id="@+id/showDetails"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <TextView
                            android:id="@+id/movieTitle"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textColor="@color/colorBlack"
                            android:textSize="20sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/movieGenres"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content" />

                        <TextView
                            android:id="@+id/movieStartDate"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:visibility="gone" />

                        <TextView
                            android:id="@+id/movieFinishDate"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:visibility="gone" />

                        <TextView
                            android:id="@+id/movieRewatched"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:visibility="gone" />

                        <TextView
                            android:id="@+id/movieEpisodes"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:visibility="gone" />

                        <RatingBar
                            android:id="@+id/movieRating"
                            style="?android:attr/ratingBarStyleSmall"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="5dip"
                            android:numStars="5"
                            android:rating="3.5" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/editShowDetails"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:visibility="gone">

                        <TableLayout
                            android:id="@+id/dateDetailsLayout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            android:shrinkColumns="0,1">

                            <TableRow
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@string/show_category" />

                                <Spinner
                                    android:id="@+id/categories"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:entries="@array/categories" />
                            </TableRow>

                            <TableRow
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:orientation="horizontal">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@string/start_date" />

                                <Button
                                    android:id="@+id/startDateButton"
                                    style="@style/ColoredButton"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:drawableEnd="@drawable/ic_calendar"
                                    android:drawablePadding="5dip"
                                    android:drawableRight="@drawable/ic_calendar"
                                    android:onClick="selectDate"
                                    android:tag="start_date" />

                            </TableRow>

                            <TableRow
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:orientation="horizontal">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@string/finish_date" />

                                <Button
                                    android:id="@+id/endDateButton"
                                    style="@style/ColoredButton"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:drawableEnd="@drawable/ic_calendar"
                                    android:drawablePadding="5dip"
                                    android:drawableRight="@drawable/ic_calendar"
                                    android:onClick="selectDate"
                                    android:tag="end_date" />

                            </TableRow>

                            <TableRow
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginBottom="5dip"
                                    android:text="@string/times_watched" />

                                <EditText
                                    android:id="@+id/timesWatched"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginEnd="4dip"
                                    android:layout_marginStart="4dip"
                                    android:background="@drawable/edit_text_box"
                                    android:digits="0123456789"
                                    android:gravity="center_horizontal"
                                    android:hint="@string/times_watched_default"
                                    android:inputType="number"
                                    android:paddingBottom="3dip"
                                    android:paddingTop="3dip"
                                    android:text="@string/times_watched_default" />

                            </TableRow>

                            <TableRow
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="3dip"
                                android:orientation="vertical"
                                android:visibility="gone">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginBottom="5dip"
                                    android:text="@string/episodes_seen" />

                                <EditText
                                    android:id="@+id/episodesSeen"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginEnd="4dip"
                                    android:layout_marginStart="4dip"
                                    android:layout_weight="1"
                                    android:background="@drawable/edit_text_box"
                                    android:digits="0123456789"
                                    android:gravity="center_horizontal"
                                    android:hint="@string/episodes_seen_default"
                                    android:inputType="number"
                                    android:paddingBottom="3dip"
                                    android:paddingTop="3dip"
                                    android:text="@string/episodes_seen_default" />

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_weight="1" />

                            </TableRow>

                            <TableRow
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="3dip"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginBottom="5dip"
                                    android:text="@string/rating" />

                                <EditText
                                    android:id="@+id/showRating"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginEnd="4dip"
                                    android:layout_marginStart="4dip"
                                    android:layout_weight="1"
                                    android:background="@drawable/edit_text_box"
                                    android:digits="0123456789"
                                    android:gravity="center_horizontal"
                                    android:hint="@string/show_rating_default"
                                    android:inputType="number"
                                    android:paddingBottom="3dip"
                                    android:paddingTop="3dip"
                                    android:text="@string/show_rating_default" />
                            </TableRow>

                        </TableLayout>

                    </LinearLayout>

                </LinearLayout>

                <ImageView
                    android:id="@+id/editIcon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_below="@id/linearMovieDetails"
                    android:contentDescription="@string/edit_icon_description"
                    android:onClick="editDetails"
                    android:padding="10dip"
                    android:src="@drawable/ic_edit_black_24dp"
                    android:visibility="gone" />

            </RelativeLayout>

            <View
                android:id="@+id/firstDivider"
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:layout_below="@id/movieDetails"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:background="?android:attr/listDivider" />

            <TextView
                android:id="@+id/movieDescription"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/firstDivider"
                android:layout_margin="16dp" />

            <TextView
                android:id="@+id/castTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/movieDescription"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:text="@string/cast_title"
                android:textSize="16sp" />

            <View
                android:id="@+id/secondDivider"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/castTitle"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:background="?android:attr/listDivider" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/castRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/secondDivider"
                android:background="@android:color/transparent"
                android:scrollbars="none" />

            <TextView
                android:id="@+id/crewTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/castRecyclerView"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:text="@string/crew_title"
                android:textSize="16sp" />

            <View
                android:id="@+id/thirdDivider"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/crewTitle"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:background="?android:attr/listDivider" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/crewRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/thirdDivider"
                android:background="@android:color/transparent"
                android:scrollbars="none" />

            <TextView
                android:id="@+id/similarMovieTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/crewRecyclerView"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:text="@string/recommendations_title"
                android:textSize="16sp" />

            <View
                android:id="@+id/fourthDivider"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@id/similarMovieTitle"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:background="?android:attr/listDivider" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/movieRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/fourthDivider"
                android:scrollbars="none" />

        </RelativeLayout>

    </org.notabug.lifeuser.moviedb.NotifyingScrollView>

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@android:color/transparent"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>
