<?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:id="@+id/stats_details_layout"
    android:background="?background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="eu.kanade.tachiyomi.ui.more.stats.details.StatsDetailsController">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/filter_constraint_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <HorizontalScrollView
            android:id="@+id/stats_horizontal_scroll"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            android:clipToPadding="false"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@id/stat_sort"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintHorizontal_chainStyle="spread"
            app:layout_constraintBottom_toBottomOf="parent"
            android:fadingEdgeLength="20dp"
            android:requiresFadingEdge="horizontal"
            android:scrollbars="none">
            <LinearLayout
                android:id="@+id/stats_filter_layout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingStart="0dp"
                android:paddingEnd="20dp">

                <FrameLayout
                    android:id="@+id/stats_clear_button_container"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="12dp"
                    android:layout_marginEnd="-6dp"
                    android:clickable="true"
                    android:focusable="true">

                    <ImageView
                        android:id="@+id/stats_clear_button"
                        android:layout_width="32dp"
                        android:layout_height="32dp"
                        android:background="@drawable/round_clear_border"
                        android:contentDescription="@string/clear"
                        android:padding="3dp"
                        android:src="@drawable/ic_close_24dp"
                        app:tint="@color/gray_button" />
                </FrameLayout>

                <com.google.android.material.chip.ChipGroup
                    android:id="@+id/stats_chip_group"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginVertical="5dp"
                    android:layout_marginStart="12dp"
                    app:chipSpacingHorizontal="5dp"
                    app:singleLine="true">

                    <com.google.android.material.chip.Chip
                        android:id="@+id/chip_stat"
                        style="@style/Widget.Tachiyomi.Chip.Stat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/series_type"
                        app:chipIcon="@drawable/ic_query_stats_24dp"
                        app:chipIconEnabled="true" />

                    <com.google.android.material.chip.Chip
                        android:id="@+id/chip_category"
                        style="@style/Widget.Tachiyomi.Chip.Stat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/category"
                        app:chipIcon="@drawable/ic_label_outline_24dp" />

                    <com.google.android.material.chip.Chip
                        android:id="@+id/chip_source"
                        style="@style/Widget.Tachiyomi.Chip.Stat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/source"
                        app:closeIcon="@drawable/ic_arrow_drop_down_24dp" />

                    <com.google.android.material.chip.Chip
                        android:id="@+id/chip_status"
                        style="@style/Widget.Tachiyomi.Chip.Stat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/status"
                        app:chipIcon="@drawable/ic_progress_clock_24dp" />

                    <com.google.android.material.chip.Chip
                        android:id="@+id/chip_series_type"
                        style="@style/Widget.Tachiyomi.Chip.Stat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/series_type"
                        app:chipIcon="@drawable/ic_style_24dp" />

                    <com.google.android.material.chip.Chip
                        android:id="@+id/chip_language"
                        style="@style/Widget.Tachiyomi.Chip.Stat"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/language"
                        app:chipIcon="@drawable/ic_translate_24dp" />
                </com.google.android.material.chip.ChipGroup>
            </LinearLayout>


        </HorizontalScrollView>

        <TextView
            android:id="@+id/stat_sort"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toEndOf="@id/stats_horizontal_scroll"
            android:layout_marginEnd="12dp"
            android:background="@drawable/square_ripple"
            android:clickable="true"
            android:drawablePadding="6dp"
            android:alpha=".8"
            app:drawableTint="?android:textColorPrimary"
            android:ellipsize="start"
            android:focusable="true"
            android:gravity="center|end"
            android:maxLines="2"
            android:paddingTop="12dp"
            android:paddingBottom="12dp"
            android:paddingStart="6dp"
            android:paddingEnd="6dp"
            android:layout_marginStart="8dp"
            android:layout_gravity="center|end"
            android:textAlignment="textEnd"
            style="?textAppearanceBodyMedium"
            android:textColor="?android:attr/textColorPrimary"
            tools:text="Title Count"
            app:drawableEndCompat="@drawable/ic_sort_24dp" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <include layout="@layout/stats_details_chart"
        android:id="@+id/chart_linear_layout"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/filter_constraint_layout"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/stats_recycler_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:orientation="vertical"
        app:layout_constraintVertical_bias="0.0"
        app:layout_constraintHeight_max="700dp" />

    <eu.kanade.tachiyomi.widget.EmptyView
        android:id="@+id/no_chart_data"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="@id/chart_linear_layout"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:layout_gravity="center"
        android:visibility="gone" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/stats_recycler_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:clipToPadding="false"
        app:layout_constraintStart_toEndOf="@id/chart_linear_layout"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/filter_constraint_layout"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

    <com.google.android.material.progressindicator.CircularProgressIndicator
        android:id="@+id/progress"
        android:indeterminate="true"
        android:layout_width="75dp"
        android:layout_height="75dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:elevation="30dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
