<?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="com.gingersoft.gsa.cloud.common.utils.time.TimeUtils" />

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

        <variable
            name="data"
            type="com.gingersoft.gsa.delivery_pick_mode.data.model.bean.OrderListBean" />

        <variable
            name="delivery_state"
            type="String" />

        <variable
            name="state"
            type="String" />

        <variable
            name="orderingMethod"
            type="String" />

        <variable
            name="payMethod"
            type="String" />

        <variable
            name="orderingMethodBg"
            type="android.graphics.drawable.Drawable" />

        <variable
            name="stateBg"
            type="android.graphics.drawable.Drawable" />

        <variable
            name="payMethodBg"
            type="android.graphics.drawable.Drawable" />

        <!-- 是否自取-->
        <variable
            name="isSelf"
            type="Boolean" />

        <variable
            name="vehicle"
            type="android.graphics.drawable.Drawable" />

        <variable
            name="isTimeOut"
            type="Boolean" />
    </data>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/dp_3"
        android:layout_marginTop="@dimen/dp_7"
        android:layout_marginRight="@dimen/dp_3">

        <com.lihang.ShadowLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:hl_cornerRadius="@dimen/dp_8"
            app:hl_shadowLimit="@dimen/dp_3">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/tv_delivery_method"
                    android:layout_width="@dimen/dp_19"
                    android:layout_height="match_parent"
                    android:background="@{orderingMethodBg}"
                    android:gravity="center"
                    android:text="@{orderingMethod}"
                    android:textColor="@color/white"
                    android:textSize="@dimen/dp_14"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:text="外送"
                    tools:textColor="@color/theme_333_color" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingLeft="@dimen/dp_4"
                    android:paddingBottom="@dimen/dp_6">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_3"
                        android:gravity="center_vertical"
                        android:orientation="horizontal">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="left"
                            android:background="@{payMethodBg}"
                            android:gravity="left"
                            android:paddingLeft="@dimen/dp_6"
                            android:paddingTop="@dimen/dp_1"
                            android:paddingRight="@dimen/dp_6"
                            android:paddingBottom="@dimen/dp_1"
                            android:text="@{payMethod}"
                            android:textColor="@color/white"
                            android:textSize="@dimen/sp_9"
                            android:textStyle="bold"
                            tools:text="支付方式"
                            tools:textColor="@color/theme_333_color" />

                        <TextView
                            android:id="@+id/tv_order_time"
                            style="@style/otherOrder_item_create_time_textStyle"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="@dimen/dp_5"
                            android:layout_marginRight="@dimen/dp_10"
                            android:layout_weight="1"
                            android:gravity="right"
                            android:text="@{TimeUtils.parseTimeRepeat(data.createTime,TimeUtils.DEFAULT_DATE_FORMAT)}"
                            android:textSize="@dimen/dp_10"
                            tools:text="下單時間"
                            tools:textColor="@color/theme_333_color" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal">

                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:orientation="vertical">

                            <TextView
                                android:id="@+id/tv_order_user_name"
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:layout_marginTop="@dimen/dp_2"
                                android:layout_marginRight="@dimen/dp_10"
                                android:text="@{data.receiver + @string/left_parenthesis+data.phone + @string/right_parenthesis}"
                                android:textColor="@color/theme_text_color"
                                android:textSize="@dimen/sp_14"
                                android:textStyle="bold"
                                tools:text="用戶名+手機號（1234567862）"
                                tools:textColor="@color/theme_333_color" />

                            <TextView
                                android:id="@+id/tv_delivery_time"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="@dimen/dp_9"
                                android:text="@{data.sendTime}"
                                android:textColor="#EC2D2D"
                                android:textSize="@dimen/dp_12"
                                android:visibility="@{(data.sendTime == null || data.sendTime.length() == 0)?View.INVISIBLE:View.VISIBLE}"
                                tools:text="儘快送達 預計18：00-18：30"
                                tools:textColor="#EC2D2D" />

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

                                <TextView
                                    android:id="@+id/tv_order_num_text"
                                    style="@style/otherOrder_item_info_title_textStyle"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_centerVertical="true"
                                    android:text="取餐碼："
                                    app:layout_constraintLeft_toLeftOf="parent"
                                    app:layout_constraintTop_toTopOf="parent" />

                                <TextView
                                    android:id="@+id/tv_order_num"
                                    style="@style/otherOrder_item_info_title_textStyle"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:layout_centerVertical="true"
                                    android:layout_marginLeft="@dimen/dp_5"
                                    android:gravity="left"
                                    android:text='@{data.takeFoodCode.equals("0")? @string/take_food_code_omit:data.takeFoodCode}'
                                    android:textSize="@dimen/dp_16"
                                    android:textStyle="bold"
                                    app:layout_constraintBottom_toBottomOf="@id/tv_order_num_text"
                                    app:layout_constraintHorizontal_weight="2"
                                    app:layout_constraintLeft_toRightOf="@id/barrier_order_item_right"
                                    app:layout_constraintTop_toTopOf="@id/tv_order_num_text"
                                    tools:text="0046"
                                    tools:textColor="@color/theme_333_color" />

                                <TextView
                                    android:id="@+id/tv_address_text"
                                    style="@style/otherOrder_item_info_title_textStyle"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginTop="@dimen/dp_6"
                                    android:layout_marginBottom="@dimen/dp_10"
                                    android:text="@string/address"
                                    android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
                                    app:layout_constraintLeft_toLeftOf="parent"
                                    app:layout_constraintTop_toBottomOf="@id/tv_order_num_text"
                                    tools:text="@string/address"
                                    tools:textColor="@color/theme_333_color" />

                                <androidx.constraintlayout.widget.Barrier
                                    android:id="@+id/barrier_order_item_right"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    app:barrierDirection="right"
                                    app:constraint_referenced_ids="tv_address_text,tv_order_num_text" />

                                <TextView
                                    android:id="@+id/tv_address"
                                    style="@style/otherOrder_item_info_textStyle"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    android:layout_marginTop="@dimen/dp_6"
                                    android:text="@{data.addressDetail}"
                                    android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
                                    app:layout_constraintLeft_toRightOf="@id/barrier_order_item_right"
                                    app:layout_constraintRight_toRightOf="parent"
                                    app:layout_constraintTop_toBottomOf="@id/tv_order_num"
                                    tools:text="用戶收貨地址"
                                    tools:textColor="#868686" />
                            </androidx.constraintlayout.widget.ConstraintLayout>


                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:gravity="center_vertical"
                            android:orientation="vertical">

                            <ImageView
                                android:id="@+id/ic_vehicle"
                                android:layout_width="@dimen/dp_26"
                                android:layout_height="@dimen/dp_26"
                                android:layout_marginLeft="@dimen/dp_2"
                                android:layout_marginRight="@dimen/dp_2"
                                android:src="@{vehicle}"
                                android:visibility="@{vehicle== null?View.GONE:View.VISIBLE}" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="@dimen/dp_2"
                            android:layout_weight="0.4"
                            android:gravity="center_horizontal"
                            android:orientation="vertical">

                            <TextView
                                android:id="@+id/tv_delivery_state"
                                style="@style/otherOrder_item_info_title_textStyle"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="@dimen/dp_15"
                                android:text="@{delivery_state}"
                                android:textColor="@{isTimeOut?@color/red_600:@color/color_3c}"
                                tools:text="@{isTimeOut?@string/order_receiving_timeout:delivery_state}"
                                tools:textColor="@color/theme_333_color" />

                            <TextView
                                android:id="@+id/tv_order_state"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="@dimen/dp_11"
                                android:background="@{stateBg}"
                                android:paddingLeft="@dimen/dp_13"
                                android:paddingTop="@dimen/dp_4"
                                android:paddingRight="@dimen/dp_13"
                                android:paddingBottom="@dimen/dp_4"
                                android:text="@{state}"
                                android:textColor="@color/white"
                                android:textSize="@dimen/dp_12"
                                tools:text="訂單狀態"
                                tools:textColor="@color/theme_333_color" />

                            <TextView
                                android:id="@+id/tv_order_amount"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="@dimen/dp_2"
                                android:gravity="center_horizontal"
                                android:text="@{@string/amount_unit + data.payAmount}"
                                android:textColor="@color/red_600"
                                android:textSize="@dimen/sp_16"
                                app:layout_constraintHorizontal_weight="1"
                                app:layout_constraintLeft_toRightOf="@id/tv_address"
                                app:layout_constraintRight_toRightOf="parent"
                                app:layout_constraintTop_toBottomOf="@id/barrier_order_item_three"
                                tools:text="$14141"
                                tools:textColor="@color/theme_333_color" />

                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:orientation="horizontal"
                                android:visibility="@{data.paymentValue!=0?View.VISIBLE:View.GONE}">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="貼士:"
                                    android:textColor="@color/theme_333_color"
                                    android:textSize="@dimen/sp_10" />

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginRight="@dimen/dp_2"
                                    android:gravity="center_horizontal"
                                    android:text="@{@string/amount_unit + data.paymentValue}"
                                    android:textColor="@color/red_600"
                                    android:textSize="@dimen/sp_10"
                                    app:layout_constraintHorizontal_weight="1"
                                    app:layout_constraintLeft_toRightOf="@id/tv_address"
                                    app:layout_constraintRight_toRightOf="parent"
                                    app:layout_constraintTop_toBottomOf="@id/barrier_order_item_three"
                                    tools:text="$14141"
                                    tools:textColor="@color/theme_333_color" />
                            </LinearLayout>
                        </LinearLayout>

                    </LinearLayout>

                </LinearLayout>
            </LinearLayout>
        </com.lihang.ShadowLayout>

        <FrameLayout
            android:id="@+id/fl_border"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/shape_order_border"
            android:visibility="gone" />
    </FrameLayout>
</layout>