<?xml version="1.0" encoding="utf-8"?>
<layout 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">

    <data>

        <variable
            name="vm"
            type="com.yidian.shenghuoquan.bgoods.ui.coupon.CategorySearchViewModel" />
    </data>

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

        <include
            android:id="@+id/include"
            layout="@layout/layout_common_toolbar" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/dp60"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="0dp"
                android:layout_height="@dimen/dp40"
                android:layout_marginStart="@dimen/dp20"
                android:layout_marginTop="@dimen/dp10"
                android:layout_marginBottom="@dimen/dp10"
                android:layout_weight="1"
                android:background="@drawable/shape_gray_bg">

                <ImageView
                    android:id="@+id/iv_search"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/dp10"
                    android:src="@drawable/icon_search"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <EditText
                    android:id="@+id/et_search_keyword"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/dp40"
                    android:layout_marginStart="@dimen/dp5"
                    android:background="@null"
                    android:hint="请输入关键词搜索商品类目"
                    android:imeOptions="actionSearch"
                    android:singleLine="true"
                    android:text="@={vm.searchKeyword}"
                    android:textColor="@color/color_333333"
                    android:textSize="@dimen/sp16"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="@id/iv_clear"
                    app:layout_constraintStart_toEndOf="@id/iv_search"
                    app:layout_constraintTop_toTopOf="parent" />

                <ImageView
                    android:id="@+id/iv_clear"
                    android:layout_width="@dimen/dp24"
                    android:layout_height="@dimen/dp24"
                    android:layout_marginStart="@dimen/dp10"
                    android:layout_marginEnd="@dimen/dp12"
                    android:onClick="@{() -> vm.toClear()}"
                    android:src="@drawable/bcommon_icon_clear"
                    app:isShow="@{!vm.searchKeyword.empty}"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

            </androidx.constraintlayout.widget.ConstraintLayout>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/dp8"
                android:onClick="@{() -> vm.toSearch()}"
                android:padding="@dimen/dp12"
                android:text="搜索"
                android:textColor="@color/color_333333"
                android:textSize="@dimen/sp14" />

        </LinearLayout>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_category_list"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:layoutAnimation="@null"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            tools:itemCount="3"
            tools:listitem="@layout/commodity_layout_category_search_list_item" />

        <com.yidian.bcommon.widget.CommonEmptyPageView
            android:id="@+id/pv_empty_page"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:visibility="gone"
            app:CommonEmptyPageView_empty_content_text="@string/no_search_result"
            app:CommonEmptyPageView_empty_tips_text="@string/click_search_again"
            app:CommonEmptyPageView_place_holder_img="@drawable/img_empty_place_holder" />

    </LinearLayout>
</layout>