<?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="com.yidian.shenghuoquan.buserorder.manager.OrderStatus" />

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

        <variable
            name="status"
            type="com.yidian.shenghuoquan.buserorder.manager.OrderStatus" />

        <variable
            name="data"
            type="com.yidian.shenghuoquan.buserorder.dto.OrderDetailDto" />
    </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_activity_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxWidth="@dimen/dp200"
            android:maxLines="1"
            android:onClick="@{() -> vm.gotoMarketingDetail(data.marketingId)}"
            android:text="@{data.marketingName}"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp16"
            android:textStyle="bold"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="拼餐优惠多多拼餐优惠多多拼餐优惠多多拼餐优惠多多拼餐优惠多多" />

        <ImageView
            android:layout_width="@dimen/dp14"
            android:layout_height="@dimen/dp14"
            android:layout_marginStart="@dimen/dp4"
            android:src="@drawable/icon_next"
            android:visibility="@{status == OrderStatus.ORDER_STATUS_UNKNOWN || status == OrderStatus.ORDER_STATUS_WAIT_PAY ? View.GONE : View.VISIBLE}"
            app:layout_constraintBottom_toBottomOf="@id/tv_activity_title"
            app:layout_constraintStart_toEndOf="@id/tv_activity_title"
            app:layout_constraintTop_toTopOf="@id/tv_activity_title" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_commodity_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:overScrollMode="never"
            app:layout_constraintTop_toBottomOf="@id/tv_activity_title" />

        <TextView
            android:id="@+id/tv_apply_refund"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/dp8"
            android:background="@drawable/shape_stroke_e5e5e5_corner_14"
            android:onClick="@{() -> vm.applyRefund(data.orderId)}"
            android:paddingStart="@dimen/dp13"
            android:paddingTop="@dimen/dp9"
            android:paddingEnd="@dimen/dp13"
            android:paddingBottom="@dimen/dp8"
            android:text="@string/apply_refund"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp11"
            android:visibility="@{status == OrderStatus.ORDER_STATUS_PAID ? View.VISIBLE : View.GONE}"
            app:layout_constraintEnd_toStartOf="@id/tv_contract_seller"
            app:layout_constraintTop_toTopOf="@id/tv_contract_seller" />

        <TextView
            android:id="@+id/tv_contract_seller"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp8"
            android:background="@drawable/shape_stroke_e5e5e5_corner_14"
            android:onClick="@{() -> vm.contractSeller(data.lifeAccountPhone)}"
            android:paddingStart="@dimen/dp13"
            android:paddingTop="@dimen/dp9"
            android:paddingEnd="@dimen/dp13"
            android:paddingBottom="@dimen/dp8"
            android:text="@string/contract_seller"
            android:textColor="@color/color_999999"
            android:textSize="@dimen/sp11"
            android:visibility="@{status == OrderStatus.ORDER_STATUS_UNKNOWN || status == OrderStatus.ORDER_STATUS_WAIT_PAY ? View.GONE : View.VISIBLE}"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@id/rv_commodity_list" />

        <ImageView
            android:id="@+id/iv_coupon"
            android:layout_width="@dimen/dp20"
            android:layout_height="@dimen/dp20"
            android:layout_marginTop="@dimen/dp18"
            android:src="@drawable/icon_order_coupon"
            android:visibility="@{data.couponList.size() > 0 ? View.VISIBLE : View.GONE}"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/tv_contract_seller" />

        <TextView
            android:id="@+id/tv_coupon_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/dp3"
            android:ellipsize="end"
            android:maxLines="1"
            android:text='@{data.couponList.size() > 0 ? data.couponList.get(0).name : @string/red_packet_or_coupon}'
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp14"
            android:visibility="@{data.couponList.size() > 0 ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="@id/iv_coupon"
            app:layout_constraintEnd_toStartOf="@id/tv_coupon_amount"
            app:layout_constraintStart_toEndOf="@id/iv_coupon"
            app:layout_constraintTop_toTopOf="@id/iv_coupon"
            tools:text="红包/优惠券" />

        <TextView
            android:id="@+id/tv_coupon_amount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text='@{data.couponList.size() > 0 ? "- ¥" + data.couponList.get(0).amount : "- ¥0.00"}'
            android:textColor="@color/color_FB4653"
            android:textSize="@dimen/sp14"
            android:visibility="@{data.couponList.size() > 0 ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="@id/iv_coupon"
            app:layout_constraintEnd_toStartOf="@id/iv_coupon_select"
            app:layout_constraintTop_toTopOf="@id/iv_coupon"
            tools:text="-¥10.00" />

        <ImageView
            android:id="@+id/iv_coupon_select"
            android:layout_width="@dimen/dp14"
            android:layout_height="@dimen/dp14"
            android:src="@drawable/icon_next"
            android:visibility="@{status == OrderStatus.ORDER_STATUS_UNKNOWN || status == OrderStatus.ORDER_STATUS_WAIT_PAY ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="@id/iv_coupon"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/iv_coupon" />

        <TextView
            android:id="@+id/tv_discount_amount_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/dp8"
            android:text="@string/already_discount"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp14"
            android:visibility="@{data.useCoupon == 1 ? View.VISIBLE : View.GONE}"
            app:layout_constraintBaseline_toBaselineOf="@id/tv_total_amount"
            app:layout_constraintEnd_toStartOf="@id/tv_discount_amount" />

        <TextView
            android:id="@+id/tv_discount_amount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/dp8"
            android:text="@{@string/amount(data.discountFee)}"
            android:textColor="@color/color_FB4653"
            android:textSize="@dimen/sp14"
            android:visibility="@{data.useCoupon == 1 ? View.VISIBLE : View.GONE}"
            app:layout_constraintBaseline_toBaselineOf="@id/tv_total_amount"
            app:layout_constraintEnd_toStartOf="@id/tv_total_amount_text"
            tools:text="¥10.00" />

        <TextView
            android:id="@+id/tv_total_amount_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/dp8"
            android:text="@string/total_amount"
            android:textColor="@color/color_333333"
            android:textSize="@dimen/sp14"
            app:layout_constraintBaseline_toBaselineOf="@id/tv_total_amount"
            app:layout_constraintEnd_toStartOf="@id/tv_total_amount_symbol" />

        <TextView
            android:id="@+id/tv_total_amount_symbol"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/renminbi"
            android:textColor="@color/black"
            android:textSize="@dimen/sp14"
            app:layout_constraintBaseline_toBaselineOf="@id/tv_total_amount"
            app:layout_constraintEnd_toStartOf="@id/tv_total_amount" />

        <TextView
            android:id="@+id/tv_total_amount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp24"
            android:text='@{String.format("%.2f", data.payment)}'
            android:textColor="@color/black"
            android:textSize="@dimen/sp18"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@id/iv_coupon"
            tools:text="¥35.00" />

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