<?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.DeviceTypeData" />

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

        <variable
            name="context"
            type="android.content.Context" />

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

    </data>


    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/item_device_type"
        android:layout_width="match_parent"
        android:layout_height="110dp"
        android:background="@{RoomUtils.getBgColor(vm.code, context)}"
        tools:background="@drawable/bg_room_device">


        <ImageView
            android:id="@+id/item_device_type_icon"
            android:layout_width="45dp"
            android:layout_height="45dp"
            android:layout_marginStart="20dp"
            android:contentDescription="@string/item_room_icon"
            app:imageUrl="@{vm.icon}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:elevation="-1dp"
            android:background="@{RoomUtils.getIconColor(vm.code, context)}"
            app:layout_constraintTop_toBottomOf="@id/item_device_type_icon"
            app:layout_constraintStart_toEndOf="@id/item_device_type_icon"
            android:layout_marginTop="-20dp"
            android:layout_marginStart="-20dp"
            android:contentDescription="@string/item_room_icon_s" />

        <!--名称-->
        <TextView
            android:id="@+id/tv_device_type_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="40dp"
            android:layout_marginEnd="15dp"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="@{vm.name}"
            android:textColor="@{RoomUtils.getTextColor(vm.code, context)}"
            android:textSize="18sp"
            android:textStyle="bold"
            app:layout_constraintBottom_toTopOf="@id/desc"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@id/item_device_type_icon"
            app:layout_constraintTop_toTopOf="@id/item_device_type_icon"
            tools:text="客厅"
            tools:textColor="@color/tab_text" />

        <TextView
            android:id="@+id/desc"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="40dp"
            android:layout_marginTop="5dp"
            android:layout_marginEnd="15dp"
            android:text="@{RoomUtils.getDesc(vm.code)}"
            android:textColor="@{RoomUtils.getTextColor(vm.code, context)}"
            android:textSize="13sp"
            app:layout_constraintBottom_toBottomOf="@id/item_device_type_icon"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@id/item_device_type_icon"
            app:layout_constraintTop_toBottomOf="@id/tv_device_type_name"
            tools:text="主控制器"
            tools:textColor="@color/c_999999" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>