<?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
            alias="textUtils"
            type="android.text.TextUtils" />

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

    </data>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/color_F7F7F7"
        android:fitsSystemWindows="true"
        android:orientation="vertical">

        <com.yidian.bcommon.widget.CommonTopBarView
            android:id="@+id/common_top_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:CommonTopBarView_bg_color="@color/white"
            app:CommonTopBarView_horizontal_padding="@dimen/dp10"
            app:CommonTopBarView_statusBar_color="@color/white"
            app:CommonTopBarView_title_text="确认订单" />

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:fillViewport="true"
            android:paddingStart="@dimen/dp16"
            android:paddingEnd="@dimen/dp16"
            android:scrollbars="none">

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

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/cl_point"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/dp8"
                    android:background="@drawable/shape_white_card_bg"
                    android:onClick="@{() -> vm.choosePickUpPoint()}"
                    android:paddingStart="@dimen/dp16"
                    android:paddingTop="@dimen/dp20"
                    android:paddingEnd="@dimen/dp16"
                    android:paddingBottom="@dimen/dp20">

                    <TextView
                        android:id="@+id/tv_please_choose_point"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="请选择自提点"
                        android:textColor="@color/black_333333"
                        android:textSize="@dimen/sp16"
                        android:textStyle="bold"
                        app:isShow="@{vm.selectedPickUpPoint.takePlaceName == null}"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0"
                        tools:visibility="gone" />

                    <TextView
                        android:id="@+id/tv_pick_up"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="自提点"
                        android:textColor="@color/black_333333"
                        android:textSize="@dimen/sp16"
                        app:isShow="@{vm.selectedPickUpPoint.takePlaceName != null}"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0" />

                    <TextView
                        android:id="@+id/tv_point_name"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="@dimen/dp12"
                        android:gravity="center_vertical"
                        android:text="@{vm.selectedPickUpPoint.takePlaceName}"
                        android:textColor="@color/black_333333"
                        android:textSize="@dimen/sp16"
                        app:isShow="@{vm.selectedPickUpPoint.takePlaceName != null}"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toStartOf="@id/iv_next_arrow"
                        app:layout_constraintStart_toEndOf="@id/tv_pick_up"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0"
                        tools:text="维多利亚3层" />

                    <ImageView
                        android:id="@+id/iv_next_arrow"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@drawable/icon_next"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0" />

                    <TextView
                        android:id="@+id/tv_point_address"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp8"
                        android:text="@{vm.selectedPickUpPoint.location}"
                        android:textColor="@color/color_999999"
                        android:textSize="@dimen/sp14"
                        app:isShow="@{vm.selectedPickUpPoint.takePlaceName != null}"
                        app:layout_constraintEnd_toStartOf="@id/iv_next_arrow"
                        app:layout_constraintStart_toStartOf="@id/tv_point_name"
                        app:layout_constraintTop_toBottomOf="@id/tv_point_name"
                        tools:text="经济技术开发区燕郊顺路123号经济技术开发区燕郊顺路123号经济技术开发区燕郊顺路123" />

                    <TextView
                        android:id="@+id/tv_point_contact_person"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp8"
                        android:text="@{@string/pickup_point_contract_person + String.valueOf(vm.selectedPickUpPoint.contactName + vm.selectedPickUpPoint.phone)}"
                        android:textColor="@color/color_999999"
                        android:textSize="@dimen/sp14"
                        app:isShow="@{vm.selectedPickUpPoint.takePlaceName != null &amp;&amp; (!textUtils.isEmpty(vm.selectedPickUpPoint.contactName) || !textUtils.isEmpty(vm.selectedPickUpPoint.phone)) }"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toStartOf="@id/iv_next_arrow"
                        app:layout_constraintStart_toStartOf="@id/tv_point_name"
                        app:layout_constraintTop_toBottomOf="@id/tv_point_address"
                        tools:text="提货点联系人：面团儿 18888889999" />

                </androidx.constraintlayout.widget.ConstraintLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/cl_contact"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/dp8"
                    android:background="@drawable/shape_white_card_bg"
                    android:paddingStart="@dimen/dp16"
                    android:paddingTop="@dimen/dp18"
                    android:paddingEnd="@dimen/dp16"
                    android:paddingBottom="@dimen/dp18">

                    <TextView
                        android:id="@+id/tv_receiving_name_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="收货姓名"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0" />

                    <EditText
                        android:id="@+id/et_receiving_name"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="@dimen/dp12"
                        android:background="@null"
                        android:hint="请输入收货人姓名"
                        android:singleLine="true"
                        android:text="@={vm.receivingName}"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintBaseline_toBaselineOf="@id/tv_receiving_name_title"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toEndOf="@id/tv_receiving_name_title" />

                    <TextView
                        android:id="@+id/tv_receiving_phone_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp18"
                        android:text="手机号码"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_receiving_name_title" />

                    <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="@dimen/dp12"
                        android:background="@null"
                        android:hint="请输入收货人电话号码"
                        android:inputType="phone"
                        android:maxLength="11"
                        android:singleLine="true"
                        android:text="@={vm.receivingPhone}"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintBaseline_toBaselineOf="@id/tv_receiving_phone_title"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toEndOf="@id/tv_receiving_phone_title" />
                </androidx.constraintlayout.widget.ConstraintLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/dp8"
                    android:background="@drawable/shape_white_card_bg"
                    android:paddingStart="@dimen/dp16"
                    android:paddingTop="@dimen/dp18"
                    android:paddingEnd="@dimen/dp16"
                    android:paddingBottom="@dimen/dp18">

                    <TextView
                        android:id="@+id/tv_goods_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:singleLine="true"
                        android:text="@{vm.marketingName}"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        tools:text="活动名称" />

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv_goods_list"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp16"
                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/tv_goods_title"
                        tools:itemCount="3"
                        tools:listitem="@layout/border_item_order_confirm_commodity_list" />

                    <androidx.constraintlayout.widget.ConstraintLayout
                        android:id="@+id/cl_coupons"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp8"
                        android:onClick="@{() -> vm.chooseVoucher()}"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/rv_goods_list">

                        <TextView
                            android:id="@+id/tv_coupons"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:drawableStart="@drawable/icon_red_envelope"
                            android:drawablePadding="@dimen/dp5"
                            android:singleLine="true"
                            android:text="@{vm.couponNameValue ?? @string/red_packet_or_coupon}"
                            android:textColor="@color/color_333333"
                            android:textSize="@dimen/sp14"
                            app:layout_constraintBottom_toBottomOf="parent"
                            app:layout_constraintEnd_toStartOf="@id/tv_coupons_available"
                            app:layout_constraintHorizontal_bias="0"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            tools:text="@string/red_packet_or_coupon" />

                        <TextView
                            android:id="@+id/tv_coupons_available"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/shape_coupons_num_bg"
                            android:paddingStart="@dimen/dp5"
                            android:paddingTop="@dimen/dp2"
                            android:paddingEnd="@dimen/dp5"
                            android:paddingBottom="@dimen/dp2"
                            android:text="@{vm.couponsAvailableNum}"
                            android:textColor="@color/white"
                            android:textSize="11sp"
                            app:isShow="@{vm.selectedCouponList.size() == 0}"
                            app:layout_constraintBottom_toBottomOf="parent"
                            app:layout_constraintEnd_toStartOf="@id/iv_coupons_next_arrow"
                            app:layout_constraintHorizontal_bias="1"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            tools:text="3张优惠券可用" />

                        <TextView
                            android:id="@+id/tv_coupons_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:paddingStart="@dimen/dp5"
                            android:paddingTop="@dimen/dp2"
                            android:paddingEnd="@dimen/dp5"
                            android:paddingBottom="@dimen/dp2"
                            android:text='@{"- " + @string/amount(vm.couponAmountValue)}'
                            android:textColor="@color/color_FD7823"
                            android:textSize="11sp"
                            app:isShow="@{vm.selectedCouponList.size() > 0}"
                            app:layout_constraintBottom_toBottomOf="parent"
                            app:layout_constraintEnd_toStartOf="@id/iv_coupons_next_arrow"
                            app:layout_constraintHorizontal_bias="1"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            tools:text="- ¥10.00" />

                        <ImageView
                            android:id="@+id/iv_coupons_next_arrow"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/icon_next"
                            app:layout_constraintBottom_toBottomOf="parent"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintHorizontal_bias="1"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent" />

                    </androidx.constraintlayout.widget.ConstraintLayout>

                    <androidx.constraintlayout.widget.ConstraintLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/dp10"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/cl_coupons">

                        <TextView
                            android:id="@+id/tv_discount_amount_title"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="3dp"
                            android:text="@string/already_discount"
                            android:textColor="@color/color_333333"
                            android:textSize="@dimen/sp14"
                            app:isShow="@{vm.couponAmountValue > 0}"
                            app:layout_constraintBottom_toBottomOf="@id/tv_goods_total_amount"
                            app:layout_constraintEnd_toStartOf="@id/tv_discount_amount"
                            app:layout_constraintTop_toTopOf="@id/tv_goods_total_amount" />

                        <TextView
                            android:id="@+id/tv_discount_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="3dp"
                            android:layout_marginEnd="@dimen/dp10"
                            android:text="@{@string/amount(vm.couponAmountValue)}"
                            android:textColor="@color/color_FD7823"
                            android:textSize="@dimen/sp14"
                            app:isShow="@{vm.couponAmountValue > 0}"
                            app:layout_constraintBottom_toBottomOf="@id/tv_goods_total_amount"
                            app:layout_constraintEnd_toStartOf="@id/tv_goods_total_title"
                            app:layout_constraintTop_toTopOf="@id/tv_goods_total_amount"
                            tools:text="¥ 10.00" />

                        <TextView
                            android:id="@+id/tv_goods_total_title"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="3dp"
                            android:text="@string/total_amount"
                            android:textColor="@color/color_333333"
                            android:textSize="@dimen/sp14"
                            android:textStyle="bold"
                            app:layout_constraintBottom_toBottomOf="@id/tv_goods_total_amount"
                            app:layout_constraintEnd_toStartOf="@id/tv_goods_total_before"
                            app:layout_constraintTop_toTopOf="@id/tv_goods_total_amount" />

                        <TextView
                            android:id="@+id/tv_goods_total_before"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="3dp"
                            android:text="@string/renminbi"
                            android:textColor="@color/color_333333"
                            android:textSize="@dimen/sp14"
                            android:textStyle="bold"
                            app:layout_constraintBottom_toBottomOf="@id/tv_goods_total_amount"
                            app:layout_constraintEnd_toStartOf="@id/tv_goods_total_amount"
                            app:layout_constraintTop_toTopOf="@id/tv_goods_total_amount" />

                        <TextView
                            android:id="@+id/tv_goods_total_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text='@{String.format("%.2f", vm.totalAmount)}'
                            android:textColor="@color/color_333333"
                            android:textSize="@dimen/sp18"
                            android:textStyle="bold"
                            app:layout_constraintBottom_toBottomOf="parent"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintHorizontal_bias="1"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            tools:text="35.00" />

                    </androidx.constraintlayout.widget.ConstraintLayout>

                </androidx.constraintlayout.widget.ConstraintLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/dp8"
                    android:layout_marginBottom="@dimen/dp8"
                    android:background="@drawable/shape_white_card_bg"
                    android:paddingStart="@dimen/dp16"
                    android:paddingTop="@dimen/dp20"
                    android:paddingEnd="@dimen/dp16"
                    android:paddingBottom="@dimen/dp20">

                    <TextView
                        android:id="@+id/tv_remark_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="备注："
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp14"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0" />

                    <EditText
                        android:id="@+id/et_mark"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:background="@null"
                        android:hint="建议备注前与发布人沟通，最多50个字"
                        android:text="@={vm.remark}"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp14"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toEndOf="@id/tv_remark_title"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0"
                        tools:text="一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十水电费不舍得放手" />

                </androidx.constraintlayout.widget.ConstraintLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/dp8"
                    android:layout_marginBottom="@dimen/dp8"
                    android:background="@drawable/shape_white_card_bg"
                    android:paddingStart="@dimen/dp16"
                    android:paddingTop="@dimen/dp20"
                    android:paddingEnd="@dimen/dp16"
                    android:paddingBottom="@dimen/dp20">

                    <TextView
                        android:id="@+id/tv_pay_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="支付方式"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:drawableStart="@drawable/icon_weixin_pay"
                        android:text="微信支付"
                        android:textColor="@color/color_999999"
                        android:textSize="@dimen/sp16"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                </androidx.constraintlayout.widget.ConstraintLayout>

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


        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/cl_pay"
            android:layout_width="match_parent"
            android:layout_height="@dimen/dp54"
            android:background="@color/white">

            <TextView
                android:id="@+id/tv_total_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dp5"
                android:text="合计："
                android:textColor="@color/color_999999"
                android:textSize="@dimen/sp14"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@id/tv_price_symbol"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_price_symbol"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dp5"
                android:text="@string/renminbi"
                android:textColor="@color/color_FB4653"
                android:textSize="@dimen/sp14"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@id/tv_total_amount"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_total_amount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/dp12"
                android:text='@{String.format("%.2f", vm.totalAmount)}'
                android:textColor="@color/color_FB4653"
                android:textSize="@dimen/sp24"
                android:textStyle="bold"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@id/tv_pay_now"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="35.00" />

            <TextView
                android:id="@+id/tv_pay_now"
                android:layout_width="@dimen/dp96"
                android:layout_height="@dimen/dp36"
                android:layout_marginEnd="@dimen/dp16"
                android:background="@drawable/shape_pay_now_bg"
                android:gravity="center"
                android:onClick="@{() -> vm.createOrder()}"
                android:text="立即支付"
                android:textColor="@color/white"
                android:textSize="@dimen/sp13"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </LinearLayout>

</layout>