import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../cubit/inspection_device_state.dart';

class InspectionItemsCard extends StatelessWidget {
  final List<InspectionItem> items;

  const InspectionItemsCard({
    super.key,
    required this.items,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          bottomLeft: Radius.circular(20.r),
          bottomRight: Radius.circular(20.r),
        ),
      ),
      padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 16.h),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '巡检项目',
            style: TextStyle(
              fontSize: 26.sp,
              fontWeight: FontWeight.bold,
              color: const Color.fromRGBO(10, 13, 20, 1.0),
            ),
          ),
          SizedBox(height: 20.h),
          ...items.map((item) => _buildInspectionItem(item)).toList(),
        ],
      ),
    );
  }

  Widget _buildInspectionItem(InspectionItem item) {
    return Padding(
      padding: EdgeInsets.only(bottom: 20.h),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
            child: Text(
              item.name,
              style: TextStyle(
                fontSize: 26.sp,
                fontWeight: FontWeight.bold,
                color: const Color.fromRGBO(10, 13, 20, 1.0),
              ),
            ),
          ),
          Row(
            children: [
              Text(
                item.value,
                style: TextStyle(
                  fontSize: 24.sp,
                  color: const Color.fromRGBO(100, 116, 139, 1.0),
                ),
              ),
              SizedBox(width: 12.w),
              Container(
                padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h),
                decoration: BoxDecoration(
                  color: const Color.fromRGBO(225, 245, 238, 1.0),
                  borderRadius: BorderRadius.circular(10.r),
                ),
                child: Row(
                  children: [
                    Icon(
                      Icons.check,
                      color: const Color.fromRGBO(26, 188, 156, 1.0),
                      size: 20.sp,
                    ),
                    SizedBox(width: 4.w),
                    Text(
                      item.result,
                      style: TextStyle(
                        fontSize: 22.sp,
                        color: const Color.fromRGBO(26, 188, 156, 1.0),
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
