<?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.base.utils.time.TimeUtils" />

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

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

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

        <variable
            name="data"
            type="com.gingersoft.gsa.cloud.print.bean.OrderDetails.DataBean" />

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

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

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

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

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

    </data>

    <RelativeLayout
        android:id="@+id/rootview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/color_f0">

        <com.qmuiteam.qmui.widget.QMUITopBar
            android:id="@+id/qm_order_details_bar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/head_height"
            android:fitsSystemWindows="true"
            app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
            app:qmui_topbar_title_color="@color/theme_white_color" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_order_details_btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" />

        <androidx.core.widget.NestedScrollView
            android:id="@+id/scroll_order_info"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/rv_order_details_btn"
            android:layout_below="@id/qm_order_details_bar">

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/dp_10"
                    android:layout_marginTop="@dimen/dp_10"
                    android:layout_marginRight="@dimen/dp_10"
                    android:background="@drawable/shape_dialog_bg"
                    android:orientation="vertical"
                    android:paddingBottom="@dimen/dp_10">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">

                        <TextView
                            style="@style/otherOrder_details_sixteen_text_Style"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
                            android:text="@{data.order_from==2?@string/ricepon_order:@string/h5_order}"
                            android:textSize="@dimen/dp_16"
                            android:textStyle="normal" />

                        <TextView
                            android:id="@+id/tv_order_state"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_margin="@dimen/other_order_info_dialog_content_marginRight"
                            android:text="@{orderStatus}"
                            android:textColor="#009788"
                            android:textSize="@dimen/dp_15" />
                    </RelativeLayout>

                    <include layout="@layout/include_horizontal_color_eee_dividing_line" />

                    <!-- 訂單編號-->
                    <TextView
                        android:id="@+id/tv_order_no"
                        style="@style/otherOrder_details_twelve_text_Style"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginTop="@dimen/dp_10"
                        android:text="@{@string/order_no + data.oRDER_NO}" />

                    <TextView
                        android:id="@+id/tv_create_time"
                        style="@style/otherOrder_details_twelve_text_Style"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:layout_marginRight="@dimen/dp_10"
                        android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}" />

                    <TextView
                        style="@style/otherOrder_details_twelve_text_Style"
                        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:layout_marginRight="@dimen/other_order_info_dialog_content_marginRight"
                        android:text="@{data.estimatedTime}"
                        android:visibility="@{data.estimatedTime.length()>0?View.VISIBLE:View.GONE}" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/dp_10"
                    android:layout_marginTop="@dimen/dp_10"
                    android:layout_marginRight="@dimen/dp_10"
                    android:background="@drawable/shape_dialog_bg"
                    android:orientation="vertical"
                    android:paddingBottom="@dimen/dp_10">

                    <TextView
                        style="@style/otherOrder_details_sixteen_text_Style"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/other_order_info_dialog_content_marginLeft"
                        android:text="訂單詳情" />

                    <include layout="@layout/include_horizontal_color_eee_dividing_line" />

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14"
                        android:visibility="@{isSelf?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_receiver_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="收貨人：" />

                        <TextView
                            android:id="@+id/tv_receiver"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_receiver_text"
                            android:gravity="right"
                            android:text="@{data.rECEIVER}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14">

                        <TextView
                            android:id="@+id/tv_receive_phone_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{isSelf?@string/reserved_telephone:@string/receiving_telephone}" />

                        <TextView
                            android:id="@+id/tv_receive_phone"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_receive_phone_text"
                            android:gravity="right"
                            android:text="@{data.pHONE}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14">

                        <TextView
                            android:id="@+id/tv_receive_time_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{isSelf?@string/self_taking_time:@string/receiving_time}" />

                        <TextView
                            android:id="@+id/tv_receive_time"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_receive_time_text"
                            android:gravity="right"
                            android:text="@{isSelf?data.takeTime:data.sEND_TIME}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14">

                        <TextView
                            android:id="@+id/tv_receive_address_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{isSelf?@string/meal_code:@string/receiving_address}" />

                        <TextView
                            android:id="@+id/tv_receive_address"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_receive_address_text"
                            android:gravity="right"
                            android:text="@{isSelf?data.takeFoodCode:data.addressDetail}" />

                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14"
                        android:visibility="@{data.remark==null||data.remark.length() == 0?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_remark_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="備註：" />

                        <TextView
                            android:id="@+id/tv_remark"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_remark_text"
                            android:gravity="right"
                            android:text="@{data.remark}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14"
                        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_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/deliveryman" />

                        <TextView
                            android:id="@+id/tv_delivery_man_name"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_delivery_man_name_text"
                            android:gravity="right"
                            android:text="@{data.delivery_man_name}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14"
                        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_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/deliveryman_phone" />

                        <TextView
                            android:id="@+id/tv_delivery_man_phone"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_delivery_man_phone_text"
                            android:gravity="right"
                            android:text="@{data.delivery_man_phone_num}" />

                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_14"
                        android:paddingLeft="@dimen/dp_7"
                        android:paddingRight="@dimen/dp_14"
                        android:visibility="@{(data.trkNo==null||data.trkNo.length()==0)?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_delivery_num_text"
                            style="@style/otherOrderReceiving_title_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/logistics_number" />

                        <TextView
                            android:id="@+id/tv_delivery_num"
                            style="@style/otherOrderReceiving_information_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_delivery_num_text"
                            android:gravity="right"
                            android:text="@{data.trkNo}" />
                    </RelativeLayout>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/dp_10"
                    android:layout_marginTop="@dimen/dp_10"
                    android:layout_marginRight="@dimen/dp_10"
                    android:layout_marginBottom="@dimen/dp_10"
                    android:background="@drawable/shape_dialog_bg"
                    android:orientation="vertical"
                    android:paddingBottom="@dimen/dp_10">

                    <TextView
                        android:id="@+id/tv_food_details_text"
                        style="@style/otherOrder_details_sixteen_text_Style"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="@dimen/dp_10"
                        android:text="商品詳情" />

                    <include layout="@layout/include_horizontal_color_eee_dividing_line" />

                    <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"
                        android:layout_marginBottom="@dimen/dp_10"
                        app:layout_constraintTop_toBottomOf="@id/line_food_top" />

                    <include layout="@layout/include_horizontal_color_eee_dividing_line" />

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">

                        <TextView
                            android:id="@+id/tv_total_text"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="right"
                            android:text="合計:" />

                        <TextView
                            android:id="@+id/tv_total"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_total_text"
                            android:gravity="right"
                            android:text="@{@string/amount_unit + MoneyUtil.sub(MoneyUtil.sub(totalAmount, data.lunchbox),data.dELIVERY_CHARGE)}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
                        android:visibility="@{data.lunchbox==0?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_lunchbox_cost_text"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="餐盒費:" />

                        <TextView
                            android:id="@+id/tv_lunchbox_cost"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_lunchbox_cost_text"
                            android:gravity="right"
                            android:text="@{@string/amount_unit + data.lunchbox}" />

                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
                        android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_delivery_fee_text"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="送貨費:" />

                        <TextView
                            android:id="@+id/tv_delivery_fee"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_delivery_fee_text"
                            android:gravity="right"
                            android:text="@{@string/amount_unit + data.dELIVERY_CHARGE}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
                        android:visibility="@{data.discount_amount==0?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_discount_text"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="折扣:" />

                        <TextView
                            android:id="@+id/tv_discount"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_discount_text"
                            android:gravity="right"
                            android:text="@{@string/minus_amount_unit + data.discount_amount}" />

                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">

                        <TextView
                            android:id="@+id/tv_total_amount_text2"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="總金額:" />

                        <TextView
                            android:id="@+id/tv_total_amount2"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_total_amount_text2"
                            android:gravity="right"
                            android:text="@{@string/amount_unit + MoneyUtil.sub(totalAmount, data.discount_amount)}" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft">

                        <TextView
                            android:id="@+id/tv_pay_amount_text"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="支付金額:" />

                        <TextView
                            android:id="@+id/tv_pay_amount"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_pay_amount_text"
                            android:gravity="right"
                            android:text="@{@string/amount_unit + MoneyUtil.sub(totalAmount, data.discount_amount)}"
                            android:textColor="#FF0000" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp_10"
                        android:paddingLeft="@dimen/other_order_info_dialog_content_marginLeft"
                        android:paddingRight="@dimen/other_order_info_dialog_content_marginLeft"
                        android:visibility="@{patMethod.length()==0?View.GONE:View.VISIBLE}">

                        <TextView
                            android:id="@+id/tv_pay_method_text"
                            style="@style/otherOrder_bill_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="支付方式:" />

                        <TextView
                            android:id="@+id/tv_pay_method"
                            style="@style/otherOrder_bill_info_textStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_toRightOf="@id/tv_pay_method_text"
                            android:gravity="right"
                            android:text="@{patMethod}" />
                    </RelativeLayout>
                </LinearLayout>

            </LinearLayout>
        </androidx.core.widget.NestedScrollView>
    </RelativeLayout>

</layout>