<?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="editMode"
            type="boolean" />

        <variable
            name="vm"
            type="com.rdiot.yx485.bean.RoomData" />

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

        <import type="com.rdiot.yx485.util.RoomUtils"/>

    </data>


    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/cl_item"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="@drawable/bg_room_device"
        tools:background="@drawable/bg_room_device">
        <ImageView
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:id="@+id/item_room_icon"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginStart="20dp"
            app:layout_constraintStart_toStartOf="parent"
            app:imageUrl="@{vm.icon}"
            android:contentDescription="@string/item_room_icon" />

        <!--名称-->
        <TextView
            android:id="@+id/tv_room_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="12dp"
            android:layout_marginTop="18dp"
            android:layout_marginEnd="5dp"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{vm.name}"
            android:textColor="@color/tab_text"
            android:textSize="16sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toStartOf="@id/iv_switch"
            app:layout_constraintStart_toEndOf="@id/item_room_icon"
            app:layout_constraintTop_toTopOf="parent"
            tools:text="客厅"
            tools:textColor="@color/tab_text" />


        <!--温度-->
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginTop="2dp"
            android:layout_marginStart="12dp"
            android:layout_marginEnd="5dp"
            app:layout_constraintTop_toBottomOf="@id/tv_room_name"
            app:layout_constraintStart_toEndOf="@id/item_room_icon"
            android:gravity="center_horizontal"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{vm.deviceTypeName}"
                android:textColor="@color/c_999999"
                android:textSize="12sp"
                tools:text="主控制器"
                tools:textColor="@color/c_999999" />

            <TextView
                android:layout_width="1dp"
                android:layout_height="10dp"
                android:layout_marginTop="5dp"
                android:background="@color/c_999999"
                android:layout_marginStart="8dp"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{@string/humidity_temperature(vm.humidity, vm.temperature)}"
                tools:text="湿度：55%"
                android:textSize="12sp"
                app:drawableStartCompat="@drawable/bg_item_room_humidity_temperature"
                android:visibility="@{vm.isOnline&amp;!vm.infrared?View.VISIBLE:View.GONE}"
                tools:textColor="@color/c_14C9C8"
                android:textColor="@color/c_14C9C8"
                android:layout_marginStart="8dp"/>

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="18dp"
                android:layout_marginStart="8dp"
                android:text="@{vm.onlineStr}"
                android:textColor="@{vm.isOnline?@color/c_14C9C8:@color/c_FAAD14}"
                android:textSize="12sp"
                android:visibility="@{vm.isOnline&amp;!vm.infrared?View.GONE:View.VISIBLE}"
                app:drawableStartCompat="@drawable/bg_item_room_disconnect"
                tools:text="已离线"
                tools:textColor="@color/c_FAAD14" />

        </LinearLayout>

        <!--开关-->
        <androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/iv_switch"
            srcString="@{vm.power?`icon_on`:`icon_off`}"
            android:layout_width="48dp"
            android:layout_height="24dp"
            android:layout_marginEnd="16dp"
            android:visibility="@{vm.editMode||vm.infrared?View.GONE:View.VISIBLE}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:srcCompat="@mipmap/icon_on" />


        <!--删除-->
        <androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/iv_del"
            android:layout_width="44dp"
            android:layout_height="44dp"
            android:layout_marginEnd="16dp"
            android:padding="10dp"
            android:visibility="@{vm.editMode?View.VISIBLE:View.GONE}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@mipmap/icon_delete"
            tools:visibility="gone" />

    </androidx.constraintlayout.widget.ConstraintLayout>


</layout>