<?xml version="1.0" encoding="utf-8"?>
<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:animateLayoutChanges="true"
    android:background="@color/supply_chain_bg_color"
    android:orientation="vertical">

    <com.qmuiteam.qmui.widget.QMUITopBar
        android:id="@+id/topbar_food_ingredients"
        android:layout_width="match_parent"
        android:layout_height="@dimen/head_height"
        android:background="@color/theme_color"
        app:qmui_topbar_title_color="@color/theme_white_color" />

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/layout_purchase_food_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/layout_food_ingredients_top"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/dp_8"
                android:layout_marginTop="@dimen/dp_4"
                android:layout_marginRight="@dimen/dp_10"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:visibility="gone">

                <LinearLayout
                    android:id="@+id/layout_food_ingredients_search"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/dp_40"
                    android:layout_weight="1"
                    android:background="@drawable/shape_white_eight_corners_bg"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="@dimen/dp_24"
                        android:layout_height="@dimen/dp_24"
                        android:layout_gravity="center_vertical"
                        android:layout_marginLeft="@dimen/dp_10"
                        android:src="@drawable/ic_search" />

                    <EditText
                        android:id="@+id/ed_food_ingredients_search"
                        style="@style/supplier_search_style"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_marginLeft="@dimen/dp_8"
                        android:layout_marginRight="@dimen/dp_5"
                        android:layout_weight="1"
                        android:background="@null"
                        android:hint="搜索食材名稱" />

                </LinearLayout>

                <com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
                    android:id="@+id/btn_switch_row"
                    android:layout_width="@dimen/dp_26"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/dp_10"
                    android:src="@drawable/ic_single_row" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/srl_supplier"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@id/layout_food_ingredients_btn"
                android:layout_below="@id/layout_food_ingredients_top"
                android:layout_marginTop="@dimen/dp_5"
                android:orientation="horizontal">

                <LinearLayout
                    android:id="@+id/layout_ingredients_left"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <com.qmuiteam.qmui.alpha.QMUIAlphaTextView
                        android:id="@+id/tv_switch_food_ingredients_show_type"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/dp_5"
                        android:layout_marginRight="@dimen/dp_7"
                        android:background="@drawable/shape_light_small_app_btn"
                        android:gravity="center"
                        android:paddingLeft="@dimen/dp_4"
                        android:paddingTop="@dimen/dp_5"
                        android:paddingRight="@dimen/dp_4"
                        android:paddingBottom="@dimen/dp_5"
                        android:text="@string/str_species"
                        android:textColor="@color/white"
                        android:textSize="@dimen/dp_14" />

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv_food_ingredients_category"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="4"
                    android:orientation="vertical">

                    <!-- 二級分類 -->
                    <com.google.android.material.appbar.CollapsingToolbarLayout
                        android:id="@+id/layout_category"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dp_40"
                        android:background="@color/white"
                        android:visibility="gone">

                        <androidx.recyclerview.widget.RecyclerView
                            android:id="@+id/rv_food_ingredients_second_category"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="@dimen/dp_40" />

                        <androidx.cardview.widget.CardView
                            android:id="@+id/card_show_more_category"
                            android:layout_width="@dimen/dp_40"
                            android:layout_height="match_parent"
                            android:layout_gravity="right"
                            android:background="@color/white"
                            app:cardElevation="@dimen/dp_10">

                            <ImageView
                                android:id="@+id/iv_unfold_arrow"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:src="@drawable/ic_inverted_triangle_66" />
                        </androidx.cardview.widget.CardView>
                    </com.google.android.material.appbar.CollapsingToolbarLayout>

                    <!-- 食材 -->
                    <com.scwang.smartrefresh.layout.SmartRefreshLayout
                        android:id="@+id/refreshLayout"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <com.scwang.smartrefresh.layout.header.ClassicsHeader
                            android:id="@+id/fresh_header"
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/dp_30"
                            app:srlAccentColor="#aaa"
                            app:srlDrawableArrow="@drawable/ic_pulling"
                            app:srlDrawableMarginRight="@dimen/dp_5"
                            app:srlDrawableSize="@dimen/dp_12"
                            app:srlEnableLastTime="false"
                            app:srlFinishDuration="300"
                            app:srlPrimaryColor="@color/trans"
                            app:srlTextFinish="加載完成"
                            app:srlTextPulling="下滑查看上一分類"
                            app:srlTextRefreshing="正在飛速加載..."
                            app:srlTextRelease="釋放查看上一分類"
                            app:srlTextSizeTitle="@dimen/dp_12" />

                        <com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
                            android:id="@+id/view_stick_head"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                            <androidx.recyclerview.widget.RecyclerView
                                android:id="@+id/rv_food_ingredients"
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

                        </com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout>

                        <com.scwang.smartrefresh.layout.footer.ClassicsFooter
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/dp_30"
                            app:srlDrawableArrow="@drawable/ic_push"
                            app:srlDrawableMarginRight="@dimen/dp_5"
                            app:srlDrawableSize="@dimen/dp_12"
                            app:srlTextFailed="加載完成"
                            app:srlTextLoading="正在飛速加載中..."
                            app:srlTextPulling="上拉加載更多"
                            app:srlTextRelease="釋放查看下一分類"
                            app:srlTextSizeTitle="@dimen/dp_12" />
                    </com.scwang.smartrefresh.layout.SmartRefreshLayout>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/layout_food_ingredients_btn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_marginLeft="@dimen/dp_20"
                android:layout_marginTop="@dimen/dp_10"
                android:layout_marginRight="@dimen/dp_20"
                android:layout_marginBottom="@dimen/dp_10"
                android:visibility="gone"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <com.qmuiteam.qmui.alpha.QMUIAlphaButton
                    android:id="@+id/btn_new_food_ingredient"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/shape_app_btn"
                    android:gravity="center"
                    android:text="+新增食材"
                    android:textColor="@color/white"
                    android:textSize="@dimen/dp_16"
                    android:visibility="gone" />

                <LinearLayout
                    android:id="@+id/layout_choose_size"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="@dimen/dp_20"
                    android:layout_weight="1"
                    android:visibility="gone">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/str_chosen"
                        android:textColor="@color/theme_333_color"
                        android:textSize="@dimen/dp_16" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/left_parenthesis"
                        android:textColor="@color/theme_333_color"
                        android:textSize="@dimen/dp_16" />

                    <TextView
                        android:id="@+id/tv_select_food_size"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="0"
                        android:textColor="@color/required_color"
                        android:textSize="@dimen/dp_16" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/right_parenthesis"
                        android:textColor="@color/theme_333_color"
                        android:textSize="@dimen/dp_16" />
                </LinearLayout>

                <FrameLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1">

                    <com.qmuiteam.qmui.alpha.QMUIAlphaButton
                        android:id="@+id/btn_food_ingredients_confirm"
                        style="@style/Save_Btn_Style"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_5"
                        android:layout_marginRight="@dimen/dp_5"
                        android:layout_marginBottom="@dimen/dp_5"
                        android:text="確定"
                        android:visibility="visible" />

                    <TextView
                        android:id="@+id/tv_ingredients_food_num"
                        android:layout_width="@dimen/dp_20"
                        android:layout_height="@dimen/dp_20"
                        android:layout_gravity="right"
                        android:autoSizeMaxTextSize="@dimen/dp_8"
                        android:autoSizeMinTextSize="@dimen/dp_4"
                        android:background="@drawable/ui_shape_red_oval"
                        android:gravity="center"
                        android:text="3"
                        android:textColor="@color/white"
                        android:textSize="@dimen/dp_12"
                        android:visibility="gone"
                        app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
                        app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" />
                </FrameLayout>

                <com.qmuiteam.qmui.alpha.QMUIAlphaButton
                    android:id="@+id/btn_food_ingredients_cancel"
                    style="@style/Cancel_Btn_Style"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/dp_20"
                    android:layout_marginTop="@dimen/dp_5"
                    android:layout_marginBottom="@dimen/dp_5"
                    android:layout_weight="1"
                    android:text="取消" />
            </LinearLayout>
        </RelativeLayout>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>