<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    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"
        android:fitsSystemWindows="true"
        app:qmui_topbar_title_color="@color/theme_white_color" />

    <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">

            <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>

            <androidx.coordinatorlayout.widget.CoordinatorLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:orientation="vertical">

                <com.google.android.material.appbar.AppBarLayout
                    android:id="@+id/layout_category"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/dp_5"
                    android:background="@color/white">
                    <!-- 二級分類 -->
                    <com.google.android.material.appbar.CollapsingToolbarLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:layout_scrollFlags="scroll|enterAlways">

                        <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_58" />

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

                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:background="@color/white"
                                android:gravity="center"
                                android:orientation="horizontal">

                                <ImageView
                                    android:id="@+id/iv_unfold_arrow"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:src="@drawable/ic_inverted_triangle_66" />

                                <TextView
                                    android:id="@+id/tv_unfold_category"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginLeft="@dimen/dp_3"
                                    android:text="展開"
                                    android:textColor="@color/color_3c"
                                    android:textSize="@dimen/dp_12" />

                            </LinearLayout>
                        </androidx.cardview.widget.CardView>
                    </com.google.android.material.appbar.CollapsingToolbarLayout>

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

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

                    <com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
                        android:id="@+id/section_food_ingredients"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                </com.scwang.smartrefresh.layout.SmartRefreshLayout>

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

            </androidx.coordinatorlayout.widget.CoordinatorLayout>

        </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: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" />

            <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="取消"
                android:visibility="visible" />
        </LinearLayout>

    </RelativeLayout>

</LinearLayout>