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

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

        <import type="android.text.TextUtils" />

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

        <variable
            name="data"
            type="com.yidian.shenghuoquan.buserorder.dto.PickupPoint" />

        <variable
            name="selectedId"
            type="Long" />

        <variable
            name="location"
            type="Boolean" />

    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="@{() -> vm.selectPickupPoint(data)}">

        <TextView
            android:id="@+id/tv_pickup_point_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{data.takePlaceName}"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp16"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="维多利亚3层" />

        <TextView
            android:id="@+id/tv_pickup_point_distance"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@{@string/pickup_point_distance(data.distance)}"
            android:textColor="@color/color_FD7823"
            android:textSize="@dimen/sp14"
            android:visibility="@{location ? View.VISIBLE : View.GONE}"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@id/tv_pickup_point_address"
            tools:text="距您：2.7km" />

        <View
            android:layout_width="@dimen/dp1"
            android:layout_height="@dimen/dp8"
            android:background="@color/color_999999"
            android:visibility="@{location ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="@id/tv_pickup_point_distance"
            app:layout_constraintEnd_toStartOf="@id/tv_pickup_point_address"
            app:layout_constraintStart_toEndOf="@id/tv_pickup_point_distance"
            app:layout_constraintTop_toTopOf="@id/tv_pickup_point_distance" />

        <TextView
            android:id="@+id/tv_pickup_point_address"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp8"
            android:layout_marginEnd="@dimen/dp16"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{data.location}"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp14"
            app:layout_constraintEnd_toStartOf="@id/cb_pickup_point_select"
            app:layout_constraintStart_toEndOf="@id/tv_pickup_point_distance"
            app:layout_constraintTop_toBottomOf="@id/tv_pickup_point_name"
            app:layout_marginStart="@{location ? 17 : 0}"
            tools:text="经济技术开发区燕顺路123号经济技术开发区燕顺路123号" />

        <TextView
            android:id="@+id/tv_pickup_point_contract"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp8"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{@string/pickup_point_contract_name(data.contactName)}"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp14"
            android:visibility="@{!TextUtils.isEmpty(data.contactName) ? View.VISIBLE : View.GONE}"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tv_pickup_point_address"
            tools:text="提货点联系人：面团儿" />

        <CheckBox
            android:id="@+id/cb_pickup_point_select"
            android:layout_width="@dimen/dp18"
            android:layout_height="@dimen/dp18"
            android:background="@drawable/selector_pickup_point_select"
            android:button="@null"
            android:checked="@{selectedId == data.takePlaceId}"
            android:clickable="false"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>