import 'package:cs_resources/constants/color_constants.dart';
import 'package:domain/entity/response/device_list_entity.dart';
import 'package:domain/entity/response/job_list_entity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:plugin_basic/basic_export.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_button.dart';
import 'package:widgets/my_text_view.dart';

/**
 * 设备列表
 */
class DeviceListItem extends StatelessWidget {
  final int index;
  final DeviceListRows item;

  DeviceListItem({
    required this.index,
    required this.item,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 21),
      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
      decoration: BoxDecoration(
        color: const Color(0xFF4DCFF6).withOpacity(0.2), // 设置背景颜色和不透明度
        borderRadius: BorderRadius.circular(5), // 设置圆角
      ),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // 设备Mac
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Device No:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //文本
              MyTextView(
                item.deviceNo ?? "-",
                marginLeft: 5,
                isFontMedium: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ),

          // 设备名称
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Device Name:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              MyTextView(
                item.deviceName ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 15),

          // 设备Mac
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Device MAC:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              MyTextView(
                item.deviceMac ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 15),

          // 位置
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Type:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              MyTextView(
                item.siteShow ?? "",
                marginLeft: 5,
                isFontRegular: true,
                textColor: ColorConstants.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 15),

          // 状态
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Alive State:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //状态
              MyTextView(
                item.isOnline == "0" ? "Offline".tr : "Online".tr,
                marginLeft: 5,
                isFontRegular: true,
                textColor:  item.aliveState == 0 ? ColorConstants.textRedFF6262 : ColorConstants.textGreen0AC074,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 15),

          // 创建时间
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Created At:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //发布状态
              MyTextView(
                item.createdAt ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 15),

        ],
      ),
    );
  }
}
