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

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

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

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/iv_commodity_pic"
            android:layout_width="@dimen/dp82"
            android:layout_height="@dimen/dp60"
            android:visibility="@{data.descPicUrl.size() > 0 ? View.VISIBLE : View.GONE}"
            app:commodityImageUrl='@{data.descPicUrl.size() > 0 ? data.descPicUrl.get(0) : ""}'
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:src="@drawable/img_order_commodity_placeholder" />

        <TextView
            android:id="@+id/tv_commodity_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:includeFontPadding="false"
            android:maxLines="1"
            android:text="@{data.goodsName}"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp15"
            app:layout_constraintStart_toEndOf="@id/iv_commodity_pic"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_marginStart="@{ivCommodityPic.visibility == View.VISIBLE ? 8 : 0}"
            tools:text="肉末茄子+蔬蒸蛋套餐+肉末茄…" />

        <TextView
            android:id="@+id/tv_commodity_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp8"
            android:includeFontPadding="false"
            android:text="@{@string/commodity_count(data.goodsNum)}"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp13"
            app:layout_constraintStart_toStartOf="@id/tv_commodity_name"
            app:layout_constraintTop_toBottomOf="@id/tv_commodity_name"
            tools:text="共2件" />

        <TextView
            android:id="@+id/tv_commodity_amount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp8"
            android:includeFontPadding="false"
            android:text="@{@string/amount(data.price)}"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp16"
            app:layout_constraintStart_toStartOf="@id/tv_commodity_name"
            app:layout_constraintTop_toBottomOf="@id/tv_commodity_count"
            tools:text="¥15.00" />

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