<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:id="@+id/recent_manga_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="?attr/background">

    <FrameLayout
        android:id="@+id/end_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/md_green_800"
        android:layout_gravity="top"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/read"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_gravity="end|center"
            android:layout_marginEnd="21dp"
            android:contentDescription="@string/read"
            android:src="@drawable/ic_eye_24dp"
            app:tint="@color/md_white_1000" />
    </FrameLayout>

    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/front_view"
        android:animateLayoutChanges="true"
        android:layout_width="match_parent"
        android:clipToPadding="false"
        android:clipChildren="false"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center_vertical"
        android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/main_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:clipChildren="false"
            android:layout_gravity="center_vertical"
            android:background="@drawable/list_item_selector"
            android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height">

            <FrameLayout
                android:id="@+id/card_layout"
                android:layout_width="60dp"
                android:layout_height="80dp"
                android:layout_marginStart="12dp"
                android:layout_marginTop="6dp"
                android:layout_marginBottom="6dp"
                app:layout_constrainedHeight="true"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.0">

                <com.google.android.material.card.MaterialCardView
                    android:id="@+id/card"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center">

                    <ImageView
                        android:id="@+id/cover_thumbnail"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:adjustViewBounds="true"
                        android:background="?attr/background"
                        android:foreground="?android:attr/selectableItemBackground"
                        android:maxHeight="60dp"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        tools:ignore="ContentDescription"
                        tools:src="@mipmap/ic_launcher" />

                </com.google.android.material.card.MaterialCardView>
            </FrameLayout>

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/title"
                style="?textAppearanceTitleMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="12dp"
                android:layout_marginTop="2dp"
                android:layout_marginEnd="16dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:textColor="?attr/colorOnBackground"
                app:layout_constrainedWidth="true"
                app:layout_constraintBottom_toTopOf="@id/subtitle"
                app:layout_constraintVertical_chainStyle="packed"

                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:flow_verticalBias="0.0"
                app:layout_constraintStart_toEndOf="@id/card_layout"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="New Chapters" />

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/subtitle"
                style="?textAppearanceBodyMedium"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="16dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:singleLine="true"
                android:textColor="?attr/colorOnBackground"
                app:layout_constrainedWidth="true"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="@+id/title"
                app:layout_constraintTop_toBottomOf="@+id/title"
                app:layout_constraintBottom_toTopOf="@id/body"
                tools:text="Manga title" />

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/body"
                style="@style/TextAppearance.BodyMedium.ReducedSpace"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="6dp"
                android:ellipsize="end"
                android:maxLines="2"
                android:textColor="?android:attr/textColorSecondary"
                app:layout_constrainedWidth="true"
                app:layout_constraintBottom_toTopOf="@id/space"
                app:layout_constraintEnd_toStartOf="@id/button_layout"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="@+id/title"
                app:layout_constraintTop_toBottomOf="@id/subtitle"
                app:layout_constraintVertical_bias="0.0"
                tools:text="Last Read Chapter 4\n3 Days ago" />

            <Space
                android:id="@+id/space"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                app:layout_constraintBottom_toTopOf="@id/bottom_line"
                app:layout_constraintTop_toBottomOf="@id/body" />

            <com.google.android.material.progressindicator.LinearProgressIndicator
                android:id="@+id/progress"
                android:layout_width="0dp"
                android:layout_height="3dp"
                android:layout_gravity="bottom"
                android:layout_marginTop="4dp"
                android:layout_marginEnd="6dp"
                android:background="#66000000"
                android:indeterminate="false"
                android:progress="10"
                android:progressTint="?attr/colorSecondary"
                android:visibility="gone"
                app:layout_constraintEnd_toStartOf="@id/button_layout"
                app:layout_constraintStart_toStartOf="@id/title"
                app:layout_constraintTop_toBottomOf="@id/subtitle" />

            <LinearLayout
                android:id="@+id/button_layout"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_marginEnd="8dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@id/subtitle">

                <ImageButton
                    android:id="@+id/show_more_chapters"
                    android:layout_width="45dp"
                    android:layout_height="match_parent"
                    android:background="?selectableItemBackgroundBorderless"
                    android:contentDescription="@string/show_more_chapters"
                    android:paddingTop="8dp"
                    android:paddingBottom="8dp"
                    android:paddingStart="16dp"
                    android:paddingEnd="16dp"
                    android:tooltipText="@string/show_more_chapters"
                    app:layout_constraintHorizontal_chainStyle="spread"
                    app:tint="?attr/colorSecondary"
                    app:srcCompat="@drawable/ic_expand_more_24dp" />

                <ImageButton
                    android:id="@+id/remove_history"
                    android:layout_width="45dp"
                    android:layout_height="match_parent"
                    android:background="?selectableItemBackgroundBorderless"
                    android:contentDescription="@string/reset_chapter_history"
                    android:padding="8dp"
                    android:tooltipText="@string/reset_chapter_history"
                    app:layout_constraintHorizontal_chainStyle="spread"
                    app:srcCompat="@drawable/ic_eye_remove_outline_24dp"
                    app:tint="@color/holo_red" />
                <include
                    android:id="@+id/download_button"
                    layout="@layout/download_button"
                    android:layout_width="45dp"
                    android:layout_height="match_parent" />
            </LinearLayout>

            <androidx.constraintlayout.widget.Barrier
                android:id="@+id/bottom_line"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="6dp"
                android:orientation="horizontal"
                app:barrierDirection="bottom"
                app:constraint_referenced_ids="space,card_layout" />

            <Space
                android:id="@+id/padding"
                android:layout_width="0dp"
                android:layout_height="6dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@id/bottom_line" />

        </androidx.constraintlayout.widget.ConstraintLayout>
        <androidx.appcompat.widget.LinearLayoutCompat
            android:id="@+id/more_chapters_layout"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:visibility="gone"
            android:layout_height="wrap_content"/>
    </androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout>
