<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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">

    <!-- since ToolbarTheme sets the tint to icons, it would make images all white,
    therefore app:tint="@null" is used to undo that setting -->
    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ToolbarTheme"
        app:elevation="0dp">

        <org.schabi.newpipe.views.CustomCollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/channel_metadata"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax">

                <ImageView
                    android:id="@+id/channel_banner_image"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:maxHeight="70dp"
                    android:scaleType="fitCenter"
                    android:src="@drawable/placeholder_channel_banner"
                    app:layout_constraintTop_toTopOf="parent"
                    app:tint="@null"
                    tools:ignore="ContentDescription" />

                <com.google.android.material.imageview.ShapeableImageView
                    android:id="@+id/channel_avatar_view"
                    android:layout_width="@dimen/channel_avatar_size"
                    android:layout_height="@dimen/channel_avatar_size"
                    android:layout_marginVertical="8dp"
                    android:layout_marginStart="8dp"
                    android:padding="1dp"
                    android:src="@drawable/placeholder_person"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintVertical_bias="1.0"
                    app:shapeAppearance="@style/CircularImageView"
                    app:strokeColor="#ffffff"
                    app:strokeWidth="2dp"
                    app:tint="@null" />

                <com.google.android.material.imageview.ShapeableImageView
                    android:id="@+id/sub_channel_avatar_view"
                    android:layout_width="@dimen/sub_channel_avatar_size"
                    android:layout_height="@dimen/sub_channel_avatar_size"
                    android:padding="1dp"
                    android:src="@drawable/placeholder_person"
                    android:visibility="gone"
                    app:layout_constraintBottom_toBottomOf="@id/channel_avatar_view"
                    app:layout_constraintEnd_toEndOf="@id/channel_avatar_view"
                    app:shapeAppearance="@style/CircularImageView"
                    app:strokeColor="#ffffff"
                    app:strokeWidth="2dp"
                    app:tint="@null"
                    tools:visibility="visible" />

                <org.schabi.newpipe.views.NewPipeTextView
                    android:id="@+id/channel_title_view"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="8dp"
                    android:layout_marginEnd="4dp"
                    android:ellipsize="end"
                    android:lines="1"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textSize="16sp"
                    app:layout_constraintBottom_toTopOf="@+id/sub_channel_title_view"
                    app:layout_constraintEnd_toStartOf="@+id/channel_subscribe_button"
                    app:layout_constraintStart_toEndOf="@+id/channel_avatar_view"
                    app:layout_constraintTop_toBottomOf="@+id/channel_banner_image"
                    tools:text="@tools:sample/lorem[10]" />

                <org.schabi.newpipe.views.NewPipeTextView
                    android:id="@+id/sub_channel_title_view"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="8dp"
                    android:layout_marginEnd="4dp"
                    android:ellipsize="end"
                    android:lines="1"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textSize="14sp"
                    android:visibility="gone"
                    app:layout_constraintBottom_toTopOf="@+id/channel_subscriber_view"
                    app:layout_constraintEnd_toStartOf="@+id/channel_subscribe_button"
                    app:layout_constraintStart_toEndOf="@+id/channel_avatar_view"
                    app:layout_constraintTop_toBottomOf="@+id/channel_title_view"
                    tools:text="@tools:sample/lorem[10]"
                    tools:visibility="visible" />

                <org.schabi.newpipe.views.NewPipeTextView
                    android:id="@+id/channel_subscriber_view"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginEnd="4dp"
                    android:layout_marginBottom="8dp"
                    android:textSize="12sp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@+id/channel_subscribe_button"
                    app:layout_constraintStart_toEndOf="@+id/channel_avatar_view"
                    app:layout_constraintTop_toBottomOf="@+id/sub_channel_title_view"
                    tools:text="123,141,411 subscribers" />

                <androidx.appcompat.widget.AppCompatButton
                    android:id="@+id/channel_subscribe_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/subscribe_button_title"
                    android:textSize="@dimen/channel_rss_title_size"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/channel_banner_image" />
            </androidx.constraintlayout.widget.ConstraintLayout>
        </org.schabi.newpipe.views.CustomCollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/app_bar_layout"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:tabGravity="fill"
            app:tabIndicatorColor="@color/white"
            app:tabMode="scrollable"
            app:tabRippleColor="@color/white"
            app:tabTextColor="@color/white" />

        <androidx.viewpager.widget.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/tab_layout" />

        <ProgressBar
            android:id="@+id/loading_progress_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:indeterminate="true"
            android:visibility="gone"
            tools:visibility="visible" />

        <LinearLayout
            android:id="@+id/empty_state_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:orientation="vertical"
            android:paddingTop="90dp"
            android:visibility="gone"
            tools:visibility="visible">

            <org.schabi.newpipe.views.NewPipeTextView
                android:id="@+id/channel_kaomoji"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="10dp"
                android:fontFamily="monospace"
                android:text="(︶︹︺)"
                android:textSize="35sp"
                tools:ignore="HardcodedText" />

            <org.schabi.newpipe.views.NewPipeTextView
                android:id="@+id/error_content_not_supported"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:text="@string/content_not_supported"
                android:textSize="15sp"
                android:visibility="gone" />

        </LinearLayout>

        <!--ERROR PANEL-->
        <include
            android:id="@+id/error_panel"
            layout="@layout/error_panel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginTop="50dp"
            android:visibility="gone"
            tools:visibility="visible" />
    </RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>