import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/utils/deal_utils.dart';
import 'package:smart_hotel_app/views/report/device/cubit/device_list_state.dart';

class DeviceCard extends StatelessWidget {
  final DeviceInfo device;

  const DeviceCard({
    super.key,
    required this.device,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(28.w),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(24.r),
        color: Colors.white,
      ),
      child: Row(
        children: [
          Container(
            width: 64.w,
            height: 53.h,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(8.r),
              color: const Color.fromRGBO(229, 241, 255, 1),
            ),
            child: Icon(
              DealUtils.deviceIcon(device.deviceTypeIcon),
              color: const Color.fromRGBO(73, 149, 234, 1),
              size: 36.sp,
            ),
          ),
          SizedBox(width: 20.w),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              spacing: 8.h,
              children: [
                Text(
                  device.name,
                  style: TextStyle(
                    fontSize: 26.sp,
                    fontWeight: FontWeight.bold,
                    color: const Color.fromRGBO(31, 41, 55, 1),
                  ),
                ),
                Text(
                  device.subTitle,
                  style: TextStyle(
                    fontSize: 24.sp,
                    color: const Color.fromRGBO(107, 114, 128, 1),
                  ),
                ),
              ],
            ),
          ),
          SizedBox(width: 20.w),
          Text(
            device.status,
            style: TextStyle(
              fontSize: 24.sp,
              color:
              device.color == 'danger' ? const Color.fromRGBO(220, 38, 38, 1) :
              device.color == 'success' ? const Color.fromRGBO(20, 184, 166, 1) :
              device.color == 'warning' ? const Color.fromRGBO(250, 204, 21, 1) :
              device.color == 'info' ? const Color.fromRGBO(100, 116, 139, 1) :
              const Color.fromRGBO(20, 184, 166, 1),
              fontWeight: FontWeight.w500,
            ),
          ),
        ],
      ),
    );
  }
}
