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

    <data>

        <import type="android.view.View" />

        <variable
            name="vm"
            type="com.yidian.shenghuoquan.buserorder.viewmodel.PickupPointSearchViewModel" />

    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/dp40">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/shape_solid_ffffff_corner_10"
            android:paddingStart="@dimen/dp9"
            android:paddingEnd="@dimen/dp8"
            app:layout_constraintEnd_toStartOf="@id/tv_cancel"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_marginEnd="@{etSearch.text.length() > 0 ? 16 : 0}">

            <ImageView
                android:id="@+id/iv_search"
                android:layout_width="@dimen/dp16"
                android:layout_height="@dimen/dp16"
                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"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/dp4"
                android:layout_marginEnd="@dimen/dp4"
                android:background="@null"
                android:hint="@string/search_pickup_point"
                android:imeOptions="actionSearch"
                android:inputType="text"
                android:maxLines="1"
                android:textColor="@color/color_333333"
                android:textColorHint="@color/color_666666"
                android:textCursorDrawable="@drawable/shape_bg_input_cursor"
                android:textSize="@dimen/sp14"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@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:onClick="@{() -> vm.clearSearch()}"
                android:src="@drawable/bcommon_icon_clear"
                android:visibility="@{etSearch.text.length() > 0 ? View.VISIBLE : View.GONE}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>

        <TextView
            android:id="@+id/tv_cancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="@{() -> vm.cancelSearch()}"
            android:text="@string/cancel"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp14"
            android:visibility="@{etSearch.text.length() > 0 ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>