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

        <variable
            name="viewModel"
            type="com.sixin.module_p.ui.enter.home.HomeViewModel" />
    </data>

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="44dp"
            android:background="@color/colorPrimary">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="首页"
                android:textColor="@color/white"
                android:textSize="18sp" />

        </RelativeLayout>

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp">

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_marginHorizontal="15dp"
                    android:gravity="center_vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="航班动态"
                        android:textColor="#333"
                        android:textSize="16sp" />

                    <View
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_weight="1" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:button="@drawable/p_home_cb_selector"
                        android:checked="@={!viewModel.countryType}"
                        android:paddingStart="5dp"
                        android:text="国内"
                        android:textSize="12sp" />

                    <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:button="@drawable/p_home_cb_selector"
                        android:checked="@={viewModel.countryType}"
                        android:paddingStart="5dp"
                        android:text="国际"
                        android:textSize="12sp" />

                    <LinearLayout
                        shape_border_color="@{@color/backgroud_gray}"
                        shape_border_width="@{1}"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="15dp"
                        android:gravity="center_vertical"
                        android:onClick="@{()->viewModel.onDateClick()}"
                        android:paddingHorizontal="10dp"
                        android:paddingVertical="4dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{viewModel.date}"
                            android:textColor="#333"
                            android:textSize="13sp"
                            tools:text="2020-01-01" />

                        <ImageView
                            android:layout_width="12dp"
                            android:layout_height="12dp"
                            android:layout_marginLeft="5dp"
                            android:src="@drawable/img_daosanjiao" />


                    </LinearLayout>

                </LinearLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="@color/backgroud_gray" />

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

                    <LinearLayout
                        shape_border_color='@{"#1ed4b3"}'
                        shape_border_width="@{1}"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_marginVertical="5dp"
                        android:gravity="center_vertical">

                        <RelativeLayout
                            shape_bg_color='@{viewModel.type == viewModel.TYPE_LEAVE ? "#1fd4b4" : @color/white}'
                            android:layout_width="80dp"
                            android:layout_height="match_parent"
                            android:onClick="@{()->viewModel.onTypeChange(viewModel.TYPE_LEAVE)}">

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_centerInParent="true"
                                android:text="出发"
                                android:textColor="@{viewModel.type == viewModel.TYPE_LEAVE ? @color/white : @color/text_normal}" />

                        </RelativeLayout>

                        <RelativeLayout
                            shape_bg_color='@{viewModel.type == viewModel.TYPE_ARRIVAL ? "#1fd4b4" : @color/white}'
                            android:layout_width="80dp"
                            android:layout_height="match_parent"
                            android:onClick="@{()->viewModel.onTypeChange(viewModel.TYPE_ARRIVAL)}">

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_centerInParent="true"
                                android:text="到达"
                                android:textColor="@{viewModel.type == viewModel.TYPE_ARRIVAL ? @color/white : @color/text_normal}" />

                        </RelativeLayout>

                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="end">

                        <ImageView
                            android:layout_width="35dp"
                            android:layout_height="match_parent"
                            android:src="@drawable/img_config"
                            android:onClick="@{()->viewModel.onConfigClick()}"/>
                    </LinearLayout>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:background="#0702f0"
                    android:gravity="center_vertical">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="航班号"
                        android:textColor="@color/white"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="航程"
                        android:textColor="@color/white"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="地区类型"
                        android:textColor="@color/white"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text='@{viewModel.type == viewModel.TYPE_ARRIVAL ? "计划降落" : "计划起飞"}'
                        android:textColor="@color/white"
                        android:textSize="15sp" />

                </LinearLayout>

                <com.scwang.smart.refresh.layout.SmartRefreshLayout
                    android:id="@+id/srl"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="@color/white"
                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                        tools:listitem="@layout/item_pda_home" />

                </com.scwang.smart.refresh.layout.SmartRefreshLayout>

            </LinearLayout>

        </androidx.cardview.widget.CardView>

    </LinearLayout>
</layout>