<?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="userData"
            type="com.rdiot.yx485.bean.UserData" />
        
        <variable
            name="weatherData"
            type="com.rdiot.yx485.bean.WeatherData" />

    </data>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/main_bg_color"
        tools:context=".ui.home.HomeFragment">

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/main_bg_color"
            app:elevation="0dp">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
                app:layout_scrollFlags="scroll|snap|exitUntilCollapsed|enterAlwaysCollapsed">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
                    <!--信息与天气-->
                    <androidx.constraintlayout.widget.ConstraintLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:paddingStart="20dp"
                        android:paddingTop="20dp"
                        android:paddingEnd="20dp">

                        <TextView
                            android:id="@+id/tv_user_name"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:ellipsize="end"
                            android:maxLines="1"
                            android:text="@{@string/welcome_back(userData.userName)}"
                            android:textColor="@color/main_text_color"
                            android:textSize="18sp"
                            android:textStyle="bold"
                            app:layout_constraintEnd_toStartOf="@+id/iv_avatar"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            tools:text="欢迎回来，超级无敌长名字测试一下哈哈哈哈哈哈！" />

                        <TextView
                            android:id="@+id/tv_1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="7dp"
                            android:text="@string/welcome"
                            android:textColor="@color/main_text_color"
                            android:textSize="18sp"
                            android:textStyle="bold"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toBottomOf="@id/tv_user_name" />

                        <androidx.appcompat.widget.AppCompatImageView
                            android:id="@+id/iv_avatar"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:adjustViewBounds="true"
                            app:layout_constraintBottom_toBottomOf="@id/tv_1"
                            app:layout_constraintEnd_toEndOf="parent"
                            app:layout_constraintTop_toTopOf="@id/tv_user_name" />

                        <!--天气情况-->
                        <androidx.constraintlayout.widget.ConstraintLayout
                            android:id="@+id/cl_weather"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="25dp"
                            android:background="@drawable/bg_home_weather"
                            app:layout_constraintTop_toBottomOf="@id/tv_1">

                            <TextView
                                android:id="@+id/tv_temp"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="20dp"
                                android:layout_marginTop="10dp"
                                android:textColor="@color/white"
                                android:text="@string/no_info"
                                android:textSize="40sp"
                                app:layout_constraintStart_toStartOf="parent"
                                app:layout_constraintTop_toTopOf="parent"
                                tools:text="27℃" />

                            <TextView
                                android:id="@+id/tv_air_quality"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="12dp"
                                android:visibility="invisible"
                                android:text="@string/excellent"
                                android:textColor="@color/white"
                                android:textSize="15sp"
                                app:layout_constraintBaseline_toBaselineOf="@id/tv_temp"
                                app:layout_constraintStart_toEndOf="@id/tv_temp" />

                            <TextView
                                android:id="@+id/tv_day"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="5dp"
                                android:layout_marginBottom="15dp"
                                android:text="9.12"
                                android:textColor="@color/white"
                                android:textSize="13sp"
                                app:layout_constraintBottom_toBottomOf="parent"
                                app:layout_constraintStart_toStartOf="@id/tv_temp"
                                app:layout_constraintTop_toBottomOf="@id/tv_temp" />

                            <TextView
                                android:id="@+id/tv_week"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="星期一"
                                android:textColor="@color/white"
                                android:textSize="13sp"
                                app:layout_constraintBottom_toBottomOf="@+id/tv_day"
                                app:layout_constraintEnd_toStartOf="@+id/tv_weather"
                                app:layout_constraintStart_toEndOf="@+id/tv_day"
                                app:layout_constraintTop_toTopOf="@id/tv_day" />

                            <TextView
                                android:id="@+id/tv_weather"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@{weatherData.now.text}"
                                android:textColor="@color/white"
                                android:textSize="13sp"
                                app:layout_constraintEnd_toEndOf="@+id/tv_air_quality"
                                app:layout_constraintStart_toStartOf="@+id/tv_air_quality"
                                app:layout_constraintTop_toTopOf="@id/tv_day"
                                tools:text="晴" />

                            <!--定位-->
                            <androidx.appcompat.widget.AppCompatImageView
                                android:id="@+id/iv_location"
                                android:layout_width="18dp"
                                android:layout_height="18dp"
                                android:layout_marginBottom="10dp"
                                app:layout_constraintBottom_toTopOf="@+id/iv_humidity"
                                app:layout_constraintStart_toStartOf="@+id/iv_humidity"
                                app:srcCompat="@mipmap/icon_location" />

                            <TextView
                                android:id="@+id/tv_location"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="3dp"
                                android:text="@string/no_info"
                                android:textColor="@color/white"
                                android:textSize="13sp"
                                app:layout_constraintBottom_toBottomOf="@+id/iv_location"
                                app:layout_constraintStart_toEndOf="@+id/iv_location"
                                app:layout_constraintTop_toTopOf="@+id/iv_location" />

                            <!--湿度-->
                            <androidx.appcompat.widget.AppCompatImageView
                                android:id="@+id/iv_humidity"
                                android:layout_width="18dp"
                                android:layout_height="18dp"
                                app:layout_constraintBottom_toBottomOf="@+id/tv_humidity"
                                app:layout_constraintEnd_toStartOf="@+id/tv_humidity"
                                app:layout_constraintHorizontal_chainStyle="packed"
                                app:layout_constraintStart_toEndOf="@+id/tv_weather"
                                app:layout_constraintTop_toTopOf="@+id/tv_humidity"
                                app:srcCompat="@mipmap/icon_humidity_home_top" />

                            <TextView
                                android:id="@+id/tv_humidity"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="3dp"
                                android:text="@{@string/weather_humidity(weatherData.now.rh)}"
                                tools:text="湿度：55%"
                                android:textColor="@color/white"
                                android:textSize="13sp"
                                app:layout_constraintBottom_toBottomOf="@id/tv_day"
                                app:layout_constraintEnd_toStartOf="@id/iv_weather"
                                app:layout_constraintStart_toEndOf="@id/iv_humidity"
                                app:layout_constraintTop_toTopOf="@id/tv_day" />

                            <!--天气图标-->
                            <androidx.appcompat.widget.AppCompatImageView
                                srcString="@{String.format(`icon_weather_%s`,weatherData.now.iconCode)}"
                                android:id="@+id/iv_weather"
                                android:layout_width="90dp"
                                android:layout_height="90dp"
                                android:layout_marginEnd="10dp"
                                app:layout_constraintBottom_toBottomOf="parent"
                                app:layout_constraintEnd_toEndOf="parent"
                                app:layout_constraintTop_toTopOf="parent"
                                app:srcCompat="@mipmap/icon_cloud" />

                        </androidx.constraintlayout.widget.ConstraintLayout>


                    </androidx.constraintlayout.widget.ConstraintLayout>
                    <!--场景-->
                    <com.ckr.pageview.view.PageView
                        android:id="@+id/pageView"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="20dp"
                        android:layout_marginEnd="10dp"
                        android:visibility="gone"
                        app:autosize="true"
                        app:clipToPadding="false"
                        app:hide_indicator="false"
                        app:indicator_container_height="@dimen/viewpager_indicator_container_height"
                        app:indicator_group_alignment="center"
                        app:indicator_group_marginBottom="10dp"
                        app:indicator_group_marginRight="10dp"
                        app:indicator_margin="@dimen/viewpager_indicator_margin"
                        app:layout_constraintTop_toBottomOf="@id/cl_weather"
                        app:layout_flag="grid"
                        app:orientation="horizontal"
                        app:overlap_layout="false"
                        app:pagePadding="@dimen/page_padding"
                        app:page_column="3"
                        app:page_row="1"
                        app:selected_indicator_color="@color/viewpager_selected_indicator_color"
                        app:selected_indicator_diameter="@dimen/viewpager_selected_indicator_diameter"
                        app:selected_indicator_drawable="@drawable/shape_point_selected"
                        app:unselected_indicator_color="@color/viewpager_unselected_indicator_color"
                        app:unselected_indicator_diameter="@dimen/viewpager_unselected_indicator_diameter"
                        app:unselected_indicator_drawable="@drawable/shape_point_unselected" />
                </LinearLayout>


            </com.google.android.material.appbar.CollapsingToolbarLayout>


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:layout_marginTop="20dp"
                android:text="@string/my_room"
                android:textColor="@color/main_text_color"
                android:textSize="18sp"
                android:textStyle="bold" />

        </com.google.android.material.appbar.AppBarLayout>


        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">


            <com.drake.brv.PageRefreshLayout
                android:id="@+id/page"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:srlEnableLoadMore="false">
                <!--有房间 显示列表-->
                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="gone" />
            </com.drake.brv.PageRefreshLayout>

            <!--无房间 显示提示-->
            <androidx.appcompat.widget.AppCompatImageView
                android:id="@+id/iv_no_room"
                android:layout_width="300dp"
                android:layout_height="300dp"
                android:layout_marginTop="30dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@mipmap/img_no_room" />

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="80dp"
                android:text="@string/no_room"
                android:textColor="@color/main_text_color"
                app:layout_constraintBottom_toBottomOf="@id/iv_no_room"
                app:layout_constraintEnd_toEndOf="@id/iv_no_room"
                app:layout_constraintStart_toStartOf="@id/iv_no_room" />

            <!--添加房间-->
            <LinearLayout
                android:id="@+id/ll_add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                android:background="@drawable/bg_home_no_room_add_btn"
                android:gravity="center"
                android:orientation="horizontal"
                android:paddingStart="20dp"
                android:paddingTop="10dp"
                android:paddingEnd="20dp"
                android:paddingBottom="10dp"
                app:layout_constraintEnd_toEndOf="@+id/textView"
                app:layout_constraintStart_toStartOf="@+id/textView"
                app:layout_constraintTop_toBottomOf="@+id/textView">

                <androidx.appcompat.widget.AppCompatImageView
                    android:layout_width="16dp"
                    android:layout_height="16dp"
                    app:srcCompat="@mipmap/icon_add_3" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="6dp"
                    android:text="@string/add_room"
                    android:textColor="@color/main_text_color"
                    app:layout_constraintEnd_toEndOf="@+id/textView"
                    app:layout_constraintStart_toStartOf="@+id/textView"
                    app:layout_constraintTop_toBottomOf="@+id/textView" />

            </LinearLayout>

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>