<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ This file is part of FYReader.
  ~  FYReader is free software: you can redistribute it and/or modify
  ~  it under the terms of the GNU General Public License as published by
  ~  the Free Software Foundation, either version 3 of the License, or
  ~  (at your option) any later version.
  ~
  ~  FYReader is distributed in the hope that it will be useful,
  ~  but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~  GNU General Public License for more details.
  ~
  ~  You should have received a copy of the GNU General Public License
  ~  along with FYReader.  If not, see <https://www.gnu.org/licenses/>.
  ~
  ~  Copyright (C) 2020 - 2022 fengyuecanzhu
  -->

<LinearLayout 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:background="@color/colorBackground"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    tools:context="xyz.fycz.myreader.ui.activity.SearchBookActivity">

    <include layout="@layout/toolbar" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:gravity="center"
        android:orientation="horizontal"
        android:paddingLeft="15dp"
        android:paddingTop="10dp"
        android:paddingRight="15dp"
        android:paddingBottom="10dp">

        <EditText
            android:id="@+id/et_search_key"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_weight="2"
            android:background="@drawable/search_et_backcolor"
            android:hint="@string/input_keyword"
            android:imeOptions="actionSearch"
            android:paddingStart="10dp"
            android:textColor="@color/textPrimary" />


        <TextView
            android:id="@+id/tv_search_conform"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:layout_weight="8"
            android:background="@drawable/search_btn_backcolor"
            android:gravity="center"
            android:text="@string/common_search"
            android:textColor="@color/textPrimaryInverted"
            android:textSize="18sp" />
    </LinearLayout>

    <RadioGroup
        android:id="@+id/rg_search_filter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal">

        <androidx.appcompat.widget.AppCompatRadioButton
            android:id="@+id/rb_all_search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="@string/all"
            android:textColor="@color/textPrimary"
            android:textSize="@dimen/text_small_size" />

        <androidx.appcompat.widget.AppCompatRadioButton
            android:id="@+id/rb_fuzzy_search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:checked="true"
            android:text="@string/fuzzy_search"
            android:textColor="@color/textPrimary"
            android:textSize="@dimen/text_small_size" />

        <androidx.appcompat.widget.AppCompatRadioButton
            android:id="@+id/rb_precise_search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:text="@string/precise_search"
            android:textColor="@color/textPrimary"
            android:textSize="@dimen/text_small_size" />
    </RadioGroup>

    <xyz.fycz.myreader.widget.RefreshProgressBar
        android:id="@+id/rpb"
        android:layout_width="match_parent"
        android:layout_height="3dp"
        android:visibility="visible" />

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:id="@+id/ll_pre_keys"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorForeground"
            android:gravity="center"
            android:orientation="vertical"
            android:padding="5dp">

            <LinearLayout
                android:id="@+id/ll_bookcase"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingHorizontal="5dp"
                android:visibility="gone">

                <RelativeLayout
                    android:id="@+id/rl_bookcase_bar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingVertical="5dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:paddingVertical="2dp"
                        android:text="@string/bookcase"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />

                    <TextView
                        android:id="@+id/tv_flatten_bookcase"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_alignParentEnd="true"
                        android:layout_marginStart="10dp"
                        android:text="@string/fold"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />
                </RelativeLayout>


                <xyz.fycz.myreader.widget.TagGroup
                    android:id="@+id/tg_bookcase"
                    style="@style/TagGroup"
                    app:atg_backgroundColor="@color/colorBackground"
                    app:atg_borderColor="@color/colorForeground"
                    app:atg_horizontalPadding="5dp"
                    app:atg_textColor="@color/textPrimary"
                    app:atg_textSize="14sp"
                    app:atg_verticalSpacing="5dp" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_suggest_book"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingHorizontal="5dp"
                android:visibility="gone">

                <RelativeLayout
                    android:id="@+id/rl_suggest_bar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingVertical="5dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:paddingVertical="2dp"
                        android:text="@string/recommend"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />

                    <TextView
                        android:id="@+id/tv_flatten_suggest"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_alignParentEnd="true"
                        android:layout_marginStart="10dp"
                        android:text="@string/fold"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />
                </RelativeLayout>


                <xyz.fycz.myreader.widget.TagGroup
                    android:id="@+id/tg_suggest_book"
                    style="@style/TagGroup"
                    app:atg_backgroundColor="@color/colorBackground"
                    app:atg_borderColor="@color/colorForeground"
                    app:atg_horizontalPadding="5dp"
                    app:atg_textColor="@color/textPrimary"
                    app:atg_textSize="14sp"
                    app:atg_verticalSpacing="5dp" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_history_books"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingHorizontal="5dp"
                android:visibility="visible">

                <RelativeLayout
                    android:id="@+id/rl_history_bar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingVertical="5dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_alignParentStart="true"
                        android:text="@string/history_record"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />


                    <TextView
                        android:id="@+id/tv_clear_history"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_toStartOf="@+id/tv_flatten_history"
                        android:text="@string/clear_search"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />

                    <TextView
                        android:id="@+id/tv_flatten_history"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_alignParentEnd="true"
                        android:layout_marginStart="10dp"
                        android:text="@string/fold"
                        android:textColor="@color/blue_bar"
                        android:textSize="@dimen/text_default_size" />


                </RelativeLayout>

                <xyz.fycz.myreader.widget.TagGroup
                    android:id="@+id/tg_history_books"
                    style="@style/TagGroup"
                    app:atg_backgroundColor="@color/colorBackground"
                    app:atg_borderColor="@color/colorForeground"
                    app:atg_horizontalPadding="5dp"
                    app:atg_textColor="@color/textPrimary"
                    app:atg_textSize="14sp"
                    app:atg_verticalSpacing="5dp" />
            </LinearLayout>

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3">

        <com.scwang.smartrefresh.layout.SmartRefreshLayout
            android:id="@+id/srl_search_book_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:descendantFocusability="blocksDescendants">

            <com.scwang.smartrefresh.header.MaterialHeader
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
            <!--<ListView
                    android:id="@+id/lv_search_books_list"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fadingEdge="none"
                    android:overScrollMode="never"
                    android:scrollbars="none">
            </ListView>-->
            <!--<xyz.fycz.myreader.custom.DragSortGridView
                    android:id="@+id/gv_search_books_list"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:listSelector="@android:color/transparent"
                    android:numColumns="auto_fit"
                    android:scrollbars="none"
                    android:padding="5dp">
            </xyz.fycz.myreader.custom.DragSortGridView>-->
            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rv_search_books_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:visibility="visible" />
        </com.scwang.smartrefresh.layout.SmartRefreshLayout>

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fabSearchStop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentBottom="true"
            android:layout_marginEnd="30dp"
            android:layout_marginBottom="30dp"
            android:contentDescription="@string/stop"
            android:src="@drawable/ic_stop_black_24dp"
            android:visibility="gone"
            app:elevation="5dp"
            app:fabSize="mini"
            app:layout_anchorGravity="right|bottom" />
    </RelativeLayout>
</LinearLayout>


