<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:paddingBottom="24dp">

    <com.google.android.material.progressindicator.LinearProgressIndicator
        android:id="@+id/loading_indicator"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/holder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:importantForAccessibility="no"
        android:src="@drawable/ic_minus_fat"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="?attr/colorOnSurface" />

    <com.google.android.material.imageview.ShapeableImageView
        android:id="@+id/episode_image"
        android:layout_width="142dp"
        android:layout_height="85dp"
        android:layout_marginStart="24dp"
        android:scaleType="centerCrop"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/holder"
        app:shapeAppearance="@style/ShapeAppearanceOverlay.Findroid.Image" />

    <FrameLayout
        android:id="@+id/missing_icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/circle_background"
        android:backgroundTint="?attr/colorError"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="@id/episode_image"
        app:layout_constraintTop_toTopOf="@id/episode_image"
        tools:visibility="visible">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="M"
            android:textColor="@android:color/white"
            tools:ignore="HardcodedText" />
    </FrameLayout>

    <ImageView
        android:id="@+id/downloaded_icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/circle_background"
        android:contentDescription="@string/downloaded_indicator"
        android:padding="4dp"
        android:src="@drawable/ic_download"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="@id/episode_image"
        app:layout_constraintTop_toTopOf="@id/episode_image"
        app:tint="?attr/colorOnPrimary"
        tools:visibility="visible" />

    <FrameLayout
        android:id="@+id/progress_bar"
        android:layout_width="wrap_content"
        android:layout_height="4dp"
        android:layout_marginHorizontal="8dp"
        android:layout_marginBottom="8dp"
        android:background="@drawable/button_setup_background"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@id/episode_image"
        app:layout_constraintStart_toStartOf="@id/episode_image"
        tools:layout_width="50dp"
        tools:visibility="visible" />

    <TextView
        android:id="@+id/series_name"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginEnd="24dp"
        android:ellipsize="end"
        android:maxLines="1"
        android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/episode_image"
        app:layout_constraintTop_toTopOf="@id/episode_image"
        tools:text="Attack on Titan" />

    <TextView
        android:id="@+id/episode_name"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginEnd="24dp"
        android:ellipsize="end"
        android:maxLines="3"
        android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/episode_image"
        app:layout_constraintTop_toBottomOf="@id/series_name"
        tools:text="S1:E1 - To You, in 2000 Years: The Fall of Shiganshina, Part 1" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="episode_image,episode_name" />

    <LinearLayout
        android:id="@+id/episode_metadata"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:layout_marginEnd="24dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@id/episode_image"
        app:layout_constraintTop_toBottomOf="@id/barrier">

        <TextView
            android:id="@+id/year"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
            tools:text="4/6/2013" />

        <TextView
            android:id="@+id/playtime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
            tools:text="26 min" />

        <TextView
            android:id="@+id/community_rating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:drawablePadding="4dp"
            android:gravity="bottom"
            android:layout_marginEnd="8dp"
            android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
            app:drawableStartCompat="@drawable/ic_star"
            app:drawableTint="@color/yellow"
            tools:text="8.8" />

        <TextView
            android:id="@+id/size"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
            android:visibility="gone"
            tools:text="42.42 TB" />
    </LinearLayout>

    <include
        android:id="@+id/item_actions"
        layout="@layout/item_actions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="20dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="24dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/episode_metadata" />


    <LinearLayout
        android:id="@+id/player_items_error"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="24dp"
        android:layout_marginBottom="12dp"
        android:orientation="vertical"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/item_actions"
        tools:visibility="visible">

        <TextView
            android:id="@+id/player_items_error_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:text="@string/error_preparing_player_items"
            android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
            android:textColor="?attr/colorError" />

        <TextView
            android:id="@+id/player_items_error_details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/view_details_underlined"
            android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
            android:textColor="?attr/colorError" />
    </LinearLayout>

    <TextView
        android:id="@+id/overview"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="24dp"
        android:layout_marginTop="8dp"
        android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/player_items_error"
        tools:text="After one hundred years of peace, humanity is suddenly reminded of the terror of being at the Titans' mercy." />

</androidx.constraintlayout.widget.ConstraintLayout>