<?xml version="1.0" encoding="utf-8"?>
<com.github.libretube.ui.views.SingleViewTouchableMotionLayout 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/playerMotionLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/player_scene">

    <ScrollView
        android:id="@+id/player_scrollView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="?android:attr/colorBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/main_container">

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

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginVertical="8dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/player_title"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginStart="10dp"
                        android:layout_marginEnd="5dp"
                        android:layout_weight="1"
                        android:maxLines="2"
                        android:textSize="18sp"
                        tools:text="Video Title" />

                    <ImageView
                        android:id="@+id/player_description_arrow"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginHorizontal="10dp"
                        android:src="@drawable/ic_arrow_down" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginHorizontal="10dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/player_views_info"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        tools:text="10M views    2 days ago " />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="3dp"
                        android:layout_marginTop="2dp">

                        <ImageView
                            android:layout_width="12dp"
                            android:layout_height="12dp"
                            android:layout_gravity="center"
                            android:src="@drawable/ic_like" />

                        <TextView
                            android:id="@+id/textLike"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginHorizontal="5dp"
                            tools:text="4.2K" />

                        <ImageView
                            android:layout_width="12dp"
                            android:layout_height="12dp"
                            android:layout_gravity="center"
                            android:layout_marginStart="5dp"
                            android:rotation="180"
                            android:src="@drawable/ic_like" />

                        <TextView
                            android:id="@+id/textDislike"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginHorizontal="5dp"
                            tools:text="1.3K" />

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

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

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/chapters_recView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginHorizontal="3dp"
                    android:layout_marginTop="20dp"
                    android:nestedScrollingEnabled="false"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/player_description"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:textIsSelectable="true"
                    android:textSize="14sp" />

            </LinearLayout>

            <com.google.android.material.card.MaterialCardView
                style="@style/Widget.Material3.CardView.Elevated"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:layout_margin="17dp"
                app:cardCornerRadius="27dp">

                <LinearLayout
                    android:id="@+id/optionsLL"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:gravity="center"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/relPlayer_share"
                        style="@style/PlayerActionsText"
                        android:text="@string/share"
                        app:drawableTopCompat="@drawable/ic_share" />

                    <TextView
                        android:id="@+id/relPlayer_download"
                        style="@style/PlayerActionsText"
                        android:text="@string/download"
                        app:drawableTopCompat="@drawable/ic_download" />

                    <TextView
                        android:id="@+id/relPlayer_pip"
                        style="@style/PlayerActionsText"
                        android:text="@string/pop_up"
                        app:drawableTopCompat="@drawable/ic_open" />

                    <TextView
                        android:id="@+id/relPlayer_background"
                        style="@style/PlayerActionsText"
                        android:text="@string/audio"
                        app:drawableTopCompat="@drawable/ic_headphones" />

                    <TextView
                        android:id="@+id/relPlayer_save"
                        style="@style/PlayerActionsText"
                        android:text="@string/save"
                        app:drawableTopCompat="@drawable/ic_save" />
                </LinearLayout>

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

            <LinearLayout
                android:id="@+id/player_channel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="8dp"
                android:layout_marginVertical="15dp"
                android:background="@drawable/rounded_ripple"
                android:orientation="horizontal"
                android:paddingLeft="8dp"
                android:paddingRight="8dp">

                <com.google.android.material.imageview.ShapeableImageView
                    android:id="@+id/player_channelImage"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="4dp"
                    app:shapeAppearance="@style/CircleImageView" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginHorizontal="5dp"
                    android:layout_weight="1"
                    android:layoutDirection="locale"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/player_channelName"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:textSize="15sp" />

                    <TextView
                        android:id="@+id/player_channelSubCount"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:textSize="11sp"
                        tools:text="2.5M subscribers" />

                </LinearLayout>

                <com.google.android.material.button.MaterialButton
                    android:id="@+id/player_subscribe"
                    style="@style/Widget.Material3.Button.ElevatedButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="@string/subscribe"
                    android:textColor="?android:attr/textColorPrimary"
                    android:textSize="12sp"
                    app:cornerRadius="11dp" />
            </LinearLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/alternativeTrendingRec"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="12dp" />

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/comments_toggle"
                style="@style/Widget.Material3.CardView.Elevated"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="16dp"
                app:cardCornerRadius="18dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="8dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/commentsToggle_textView"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="8dp"
                        android:layout_weight="1"
                        android:text="@string/comments"
                        android:textSize="17sp" />

                    <ImageView
                        android:id="@+id/commentsToggle_imageView"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginEnd="3dp"
                        android:src="@drawable/ic_arrow_up_down" />

                </LinearLayout>

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

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:animateLayoutChanges="true"
                android:descendantFocusability="blocksDescendants">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/related_rec_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:layout_marginBottom="10dp"
                    android:nestedScrollingEnabled="false" />
            </RelativeLayout>

        </LinearLayout>

    </ScrollView>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/main_container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="?attr/colorSurface"
        app:layout_constraintDimensionRatio="16:9"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.github.libretube.ui.views.CustomExoPlayerView
        android:id="@+id/player"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black"
        app:layout_constraintBottom_toBottomOf="@id/main_container"
        app:layout_constraintStart_toStartOf="@id/main_container"
        app:layout_constraintTop_toTopOf="@id/main_container"
        app:show_buffering="when_playing">

        <com.github.libretube.ui.views.DoubleTapOverlay
            android:id="@+id/doubleTapOverlay"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center" />

        <com.github.libretube.ui.views.PlayerGestureControlsView
            android:id="@+id/playerGestureControlsView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:gravity="center" />

        <com.google.android.material.card.MaterialCardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_marginEnd="-10dp"
            android:layout_marginBottom="60dp"
            android:paddingEnd="10dp"
            app:cardBackgroundColor="#88000000"
            app:strokeWidth="1dp"
            tools:ignore="RtlSymmetry">

            <LinearLayout
                android:id="@+id/sb_skip_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="10dp"
                android:visibility="gone">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/skip_segment"
                    android:textColor="@android:color/white"
                    android:textSize="18sp" />

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_gravity="center"
                    android:layout_marginHorizontal="10dp"
                    android:src="@drawable/ic_next"
                    app:tint="@android:color/white" />

            </LinearLayout>

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

    </com.github.libretube.ui.views.CustomExoPlayerView>

    <ImageView
        android:id="@+id/close_imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:alpha="0"
        android:background="?attr/selectableItemBackgroundBorderless"
        android:padding="8dp"
        android:src="@drawable/ic_close"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@id/main_container"
        app:layout_constraintEnd_toEndOf="@id/main_container"
        app:layout_constraintTop_toTopOf="@id/main_container" />

    <ImageView
        android:id="@+id/play_imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:alpha="0"
        android:background="?attr/selectableItemBackgroundBorderless"
        android:padding="8dp"
        android:src="@drawable/ic_play"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@+id/close_imageView"
        app:layout_constraintEnd_toStartOf="@+id/close_imageView"
        app:layout_constraintTop_toTopOf="@+id/close_imageView" />

    <TextView
        android:id="@+id/title_textView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:alpha="0"
        android:ellipsize="end"
        android:maxLines="1"
        android:paddingHorizontal="8dp"
        android:paddingVertical="15dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="@+id/play_imageView"
        app:layout_constraintEnd_toStartOf="@+id/play_imageView"
        app:layout_constraintStart_toEndOf="@+id/player"
        app:layout_constraintTop_toTopOf="@+id/play_imageView" />

</com.github.libretube.ui.views.SingleViewTouchableMotionLayout>