<?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.OrderPickupPointViewModel" />

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

    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/shape_solid_ffffff_corner_20"
        android:paddingStart="@dimen/dp16"
        android:paddingTop="@dimen/dp20"
        android:paddingEnd="@dimen/dp16"
        android:paddingBottom="@dimen/dp20">

        <TextView
            android:id="@+id/tv_pickup_point"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/pickup_point"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp16"
            android:visibility="@{data != null ? View.VISIBLE : View.GONE}"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tv_pickup_point_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/dp12"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{data == null ? @string/please_select_pickup_point : data.takePlaceName}"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp16"
            android:textStyle="bold"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@id/tv_pickup_point"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="维多利亚3层" />

        <ImageView
            android:id="@+id/iv_pickup_point_select"
            android:layout_width="@dimen/dp14"
            android:layout_height="@dimen/dp14"
            android:src="@drawable/icon_next"
            android:visibility="@{data == null ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="@id/tv_pickup_point_name"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/tv_pickup_point_name" />

        <TextView
            android:id="@+id/tv_pickup_point_address"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp8"
            android:ellipsize="end"
            android:maxLines="2"
            android:text="@{data.location}"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp14"
            android:visibility="@{data != null ? View.VISIBLE : View.GONE}"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@id/tv_pickup_point_name"
            app:layout_constraintTop_toBottomOf="@id/tv_pickup_point_name"
            tools:text="经济技术开发区燕郊顺路123号经济技术开发区燕郊顺路123号经济技术开发区燕郊顺路123号经济技术开发区燕郊顺路123号" />

        <TextView
            android:id="@+id/tv_pickup_point_contact"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp4"
            android:onClick="@{() -> vm.contractPickupPoint(data.phone)}"
            android:text="@{@string/pickup_point_contract(data.contactName, data.phone)}"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp14"
            android:visibility="@{!TextUtils.isEmpty(data.contactName) || !TextUtils.isEmpty(data.phone) ? View.VISIBLE : View.GONE}"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@id/tv_pickup_point_name"
            app:layout_constraintTop_toBottomOf="@id/tv_pickup_point_address"
            tools:text="提货点联系人：面团儿" />

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