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

    <data>

        <import type="com.gingersoft.gsa.cloud.common.utils.time.TimeUtils" />

        <import type="com.gingersoft.gsa.cloud.common.utils.MoneyUtil" />

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

        <variable
            name="total_amount"
            type="Double" />

        <variable
            name="data"
            type="com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails.DataBean" />

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

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

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

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

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


        <variable
            name="estimatedTime"
            type="String" />
    </data>

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

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginBottom="@dimen/dp_10"
            android:background="@drawable/shape_dialog_bg"
            android:paddingTop="@dimen/dp_15"
            android:paddingBottom="@dimen/dp_15"
            app:layout_constraintBottom_toTopOf="@id/iv_close"
            app:layout_constraintTop_toTopOf="parent">

            <TextView
                android:id="@+id/tv_order_name"
                style="@style/otherOrderInfoDialogBoldTextStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                android:text="@{data.order_from==7?@string/h5_order:@string/ricepon_order}"
                android:textSize="@dimen/dp_16"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_order_state"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                android:text="@{orderStatus}"
                android:textColor="#009788"
                android:textSize="@dimen/dp_15"
                android:visibility="@{isHistory?View.INVISIBLE:View.VISIBLE}"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <androidx.core.widget.NestedScrollView
                android:id="@+id/scroll_order_info"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="@dimen/dp_8"
                android:paddingBottom="@dimen/dp_10"
                app:layout_constraintBottom_toTopOf="@id/btn_assign_shipping"
                app:layout_constraintTop_toBottomOf="@id/tv_order_state">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/cl_order_info"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/tv_total_amount_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="總金額"
                        android:textColor="@color/color_3c"
                        android:textSize="@dimen/dp_14"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <TextView
                        android:id="@+id/tv_total_amount"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_5"
                        android:text="@{@string/amount_unit + total_amount}"
                        android:textColor="#BE1C42"
                        android:textSize="@dimen/dp_24"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_total_amount_text" />

                    <TextView
                        android:id="@+id/tv_take_food_code"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_15"
                        android:text="取餐碼："
                        android:textColor="@color/color_3c"
                        android:textSize="@dimen/dp_14"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_total_amount" />

                    <TextView
                        android:id="@+id/tv_order_num"
                        style="@style/otherOrder_item_info_title_textStyle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        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_take_food_code"
                        app:layout_constraintLeft_toRightOf="@id/tv_take_food_code"
                        app:layout_constraintTop_toTopOf="@id/tv_take_food_code" />

                    <TextView
                        android:id="@+id/tv_order_no"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:text="@{@string/order_no + data.oRDER_NO}"
                        android:textColor="@color/color_3c"
                        android:textSize="@dimen/dp_14"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_order_num" />

                    <TextView
                        android:id="@+id/tv_create_time"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
                        android:textColor="@color/color_3c"
                        android:textSize="@dimen/dp_14"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_order_no" />

                    <TextView
                        android:id="@+id/tv_estimated_time"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:text="@{estimatedTime}"
                        android:textColor="@color/color_3c"
                        android:textSize="@dimen/dp_14"
                        android:visibility="@{estimatedTime.length()>0?View.VISIBLE:View.GONE}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_create_time" />

                    <View
                        android:id="@+id/line_info_top"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dp_1"
                        android:layout_marginTop="@dimen/dp_10"
                        android:background="@color/color_ccc"
                        app:layout_constraintTop_toBottomOf="@id/tv_estimated_time" />

                    <TextView
                        android:id="@+id/tv_receiver_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_8"
                        android:gravity="right"
                        android:text="收貨人："
                        android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/line_info_top" />

                    <TextView
                        android:id="@+id/tv_receiver"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{data.rECEIVER}"
                        android:visibility="@{isSelf?View.GONE:View.VISIBLE}"
                        app:layout_constraintLeft_toRightOf="@id/tv_receiver_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_receiver_text" />


                    <TextView
                        android:id="@+id/tv_receive_phone_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_receiver" />

                    <TextView
                        android:id="@+id/tv_receive_phone"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{data.pHONE}"
                        app:layout_constraintLeft_toRightOf="@id/tv_receive_phone_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_receive_phone_text" />


                    <TextView
                        android:id="@+id/tv_receive_time_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:gravity="right"
                        android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_receive_phone" />

                    <TextView
                        android:id="@+id/tv_receive_time"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{isSelf?data.takeTime:data.sEND_TIME}"
                        app:layout_constraintLeft_toRightOf="@id/tv_receive_time_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_receive_time_text" />

                    <TextView
                        android:id="@+id/tv_receive_address_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:gravity="right"
                        android:text="@{isSelf?@string/meal_code:@string/receiving_address}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_receive_time" />

                    <TextView
                        android:id="@+id/tv_receive_address"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{isSelf?data.takeFoodCode:data.addressDetail}"
                        app:layout_constraintLeft_toRightOf="@id/tv_receive_address_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_receive_address_text" />


                    <TextView
                        android:id="@+id/tv_remark_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_8"
                        android:text="備註："
                        android:visibility="@{data.remark==null||data.remark.length() == 0?View.GONE:View.VISIBLE}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_receive_address" />

                    <TextView
                        android:id="@+id/tv_remark"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{data.remark}"
                        android:visibility="@{data.remark==null||data.remark.length() == 0?View.GONE:View.VISIBLE}"
                        app:layout_constraintLeft_toRightOf="@id/tv_remark_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_remark_text" />

                    <TextView
                        android:id="@+id/tv_delivery_man_name_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:gravity="right"
                        android:text="@string/deliveryman"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_remark" />

                    <!--                android:visibility="@{(data.delivery_man_name==null || data.delivery_man_name.length()==0) ? View.GONE : View.VISIBLE}"-->

                    <TextView
                        android:id="@+id/tv_delivery_man_name"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{data.delivery_man_name}"
                        app:layout_constraintLeft_toRightOf="@id/tv_delivery_man_name_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_delivery_man_name_text" />

                    <TextView
                        android:id="@+id/tv_delivery_man_phone_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:gravity="right"
                        android:text="@string/deliveryman_phone"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_delivery_man_name" />
                    <!--                android:visibility="@{(data.delivery_man_phone_num==null||data.delivery_man_phone_num.length()==0)?View.GONE:View.VISIBLE}"-->

                    <TextView
                        android:id="@+id/tv_delivery_man_phone"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{data.delivery_man_phone_num}"
                        app:layout_constraintLeft_toRightOf="@id/tv_delivery_man_phone_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_delivery_man_phone_text" />


                    <TextView
                        android:id="@+id/tv_delivery_num_text"
                        style="@style/otherOrderReceiving_title_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:gravity="right"
                        android:text="@string/logistics_number"
                        android:visibility="@{(data.trkNo==null||data.trkNo.length()==0)?View.GONE:View.VISIBLE}"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_delivery_man_phone" />

                    <TextView
                        android:id="@+id/tv_delivery_num"
                        style="@style/otherOrderReceiving_information_textStyle"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:gravity="right"
                        android:text="@{data.trkNo}"
                        android:visibility="@{(data.trkNo==null||data.trkNo.length()==0)?View.GONE:View.VISIBLE}"
                        app:layout_constraintLeft_toRightOf="@id/tv_delivery_num_text"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toTopOf="@id/tv_delivery_num_text" />

                    <View
                        android:id="@+id/line_info_bottom"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dp_10"
                        android:layout_marginTop="@dimen/dp_10"
                        android:background="@color/color_ef"
                        app:layout_constraintTop_toBottomOf="@id/tv_delivery_num" />

                    <TextView
                        android:id="@+id/tv_food_details_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="@dimen/dp_10"
                        android:text="商品詳情"
                        android:textColor="@color/black"
                        android:textSize="@dimen/dp_16"
                        android:textStyle="bold"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/line_info_bottom" />

                    <View
                        android:id="@+id/line_food_top"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dp_1"
                        android:background="@color/color_ccc"
                        app:layout_constraintTop_toBottomOf="@id/tv_food_details_text" />


                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv_food"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        app:layout_constraintTop_toBottomOf="@id/line_food_top" />


                    <View
                        android:id="@+id/line_food_bottom"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dp_1"
                        android:layout_marginTop="@dimen/dp_5"
                        android:background="@color/color_ccc"
                        app:layout_constraintTop_toBottomOf="@id/rv_food" />

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/recycler_order_details_pay_info"
                        android:layout_width="match_parent"
                        app:layout_constraintTop_toBottomOf="@id/line_food_bottom"
                        android:layout_height="wrap_content"/>

                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.core.widget.NestedScrollView>

            <Button
                android:id="@+id/btn_assign_shipping"
                android:layout_width="0dp"
                android:layout_height="@dimen/dp_40"
                android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                android:layout_marginBottom="@dimen/dp_10"
                android:background="@drawable/shape_green_btn"
                android:text="@{btnContent}"
                android:textColor="@color/white"
                android:textSize="@dimen/dp_16"
                android:visibility="@{(btnContent==null||btnContent.length()==0)?View.GONE:View.VISIBLE}"
                app:layout_constraintBottom_toTopOf="@id/btn_cancel_order"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent" />

            <Button
                android:id="@+id/btn_cancel_order"
                android:layout_width="0dp"
                android:layout_height="@dimen/dp_40"
                android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                android:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                android:background="@drawable/shape_green_btn"
                android:text="@{cancelBtnContent}"
                android:textColor="@color/white"
                android:textSize="@dimen/dp_16"
                android:visibility="@{(cancelBtnContent==null||cancelBtnContent.length()==0)?View.GONE:View.VISIBLE}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>

        <ImageView
            android:id="@+id/iv_close"
            android:layout_width="@dimen/dp_30"
            android:layout_height="@dimen/dp_30"
            android:src="@drawable/dialog_close"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>