<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <com.google.android.material.search.SearchView
        android:id="@+id/search_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:hint="@string/search_hint"
        app:layout_anchor="@id/search_bar">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <HorizontalScrollView
                android:layout_width="wrap_content"
                android:scrollbars="none"
                android:paddingHorizontal="10dp"
                android:layout_height="wrap_content">

                <com.google.android.material.chip.ChipGroup
                    android:id="@+id/providers"
                    android:layout_marginTop="5dp"
                    app:singleSelection="true"
                    app:chipSpacingVertical="-10dp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:singleLine="true" />

            </HorizontalScrollView>

            <View
                android:id="@+id/chipGroupDivider"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                style="@style/Divider.Vertical"/>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/queries_constraint"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <com.google.android.material.chip.ChipGroup
                    android:id="@+id/queries"
                    android:layout_margin="10dp"
                    app:chipSpacingVertical="-10dp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintHorizontal_bias="0.0"
                    app:layout_constraintEnd_toStartOf="@+id/init_search_query"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    app:singleLine="false" />

                <com.google.android.material.button.MaterialButton
                    android:id="@+id/init_search_query"
                    style="?attr/materialIconButtonStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    app:iconSize="20dp"
                    app:cornerRadius="10dp"
                    app:icon="@drawable/ic_search"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/search_suggestions_recycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </com.google.android.material.search.SearchView>

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/home_appbarlayout"
        app:liftOnScroll="true"
        android:background="@null"
        android:elevation="0dp"
        android:fitsSystemWindows="true"
        app:elevation="0dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            app:layout_scrollFlags="scroll"
            android:layout_height="wrap_content">

            <com.google.android.material.appbar.MaterialToolbar
                android:id="@+id/home_toolbar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:title="@string/app_name" />

            <com.facebook.shimmer.ShimmerFrameLayout
                android:id="@+id/progress"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:translationZ="250dp"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="@+id/search_bar"
                app:layout_constraintEnd_toEndOf="@+id/search_bar"
                app:layout_constraintStart_toStartOf="@+id/search_bar"
                app:layout_constraintTop_toTopOf="@+id/search_bar"
                app:shimmer_auto_start="true">

                <com.google.android.material.card.MaterialCardView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:cardCornerRadius="30dp">

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


            </com.facebook.shimmer.ShimmerFrameLayout>


            <com.google.android.material.search.SearchBar
                android:id="@+id/search_bar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:hint="@string/search_hint"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toEndOf="@+id/home_toolbar"
                app:layout_constraintTop_toTopOf="parent"
                app:menu="@menu/main_menu">

            </com.google.android.material.search.SearchBar>

        </androidx.constraintlayout.widget.ConstraintLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <RelativeLayout
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <HorizontalScrollView
            android:id="@+id/playlist_selection_chips_scrollview"
            android:layout_width="wrap_content"
            android:scrollbars="none"
            android:visibility="gone"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="wrap_content"
                android:paddingHorizontal="10dp"
                android:layout_height="wrap_content">

                <com.google.android.material.chip.ChipGroup
                    android:layout_width="wrap_content"
                    app:selectionRequired="false"
                    android:id="@+id/playlist_selection_chips"
                    app:singleSelection="true"
                    android:layout_height="wrap_content">

                    <com.google.android.material.chip.Chip
                        android:id="@+id/all"
                        style="@style/Widget.Material3.Chip.Filter"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="@string/all"
                        android:tag="all"
                        android:checked="true"
                        android:minWidth="30dp"
                        app:cornerRadius="10dp"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                </com.google.android.material.chip.ChipGroup>

            </LinearLayout>

        </HorizontalScrollView>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerViewHome"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/playlist_selection_chips_scrollview"
            android:clipToPadding="false"
            android:orientation="vertical"
            android:paddingBottom="200dp"
            android:scrollbars="none"
            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
            app:spanCount="2" />

        <com.facebook.shimmer.ShimmerFrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/recyclerViewHome"
            android:id="@+id/shimmer_results_framelayout"
            android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:weightSum="2"
                android:layout_height="250dp">

                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />
                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />
                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:weightSum="2"
                android:layout_height="250dp">

                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />
                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />
                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:weightSum="2"
                android:layout_height="250dp">

                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />
                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />
                <include
                    android:layout_weight="1"
                    layout="@layout/result_card_shimmer"
                    android:layout_height="wrap_content"
                    android:layout_width="0dp" />

            </LinearLayout>


        </LinearLayout>

    </com.facebook.shimmer.ShimmerFrameLayout>

    </RelativeLayout>




    <LinearLayout
        android:id="@+id/home_fabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="bottom|end">

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/copied_url_fab"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:text="@string/link_you_copied"
            android:layout_marginHorizontal="16dp"
            android:layout_marginBottom="10dp"
            android:contentDescription="@string/link_you_copied"
            app:icon="@drawable/ic_clipboard"
            app:useCompatPadding="true" />

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/download_all_fab"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_marginBottom="10dp"
            android:layout_marginHorizontal="16dp"
            android:text="@string/download_all"
            app:icon="@drawable/ic_down" />

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/download_selected_fab"
            android:visibility="gone"
            app:elevation="0dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="16dp"
            android:layout_marginBottom="10dp"
            app:icon="@drawable/ic_down"
            android:text="@string/download"
            app:srcCompat="@drawable/ic_music"/>

    </LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>