import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';
import 'package:smart_hotel_app/views/home/inspection/cubit/inspection_state.dart';
import 'package:smart_hotel_app/views/home/inspection/widget/device_list_item.dart';

class DeviceList extends StatelessWidget {
  final List<InspectionDevice> deviceList;

  const DeviceList({
    super.key,
    required this.deviceList,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          '设备列表 (${deviceList.length})',
          style: TextStyle(
            fontSize: 28.sp,
            fontWeight: FontWeight.bold,
            color: const Color.fromRGBO(10, 13, 20, 1.0),
          ),
        ),
        SizedBox(height: 12.h),
        ListView.separated(
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          itemCount: deviceList.length,
          separatorBuilder: (context, index) => SizedBox(height: 12.h),
          itemBuilder: (context, index) {
            return DeviceListItem(
              device: deviceList[index],
              onTap: () {
                context.pushRoute(
                  InspectionDeviceRoute(deviceId: deviceList[index].id),
                );
              },
            );
          },
        ),
      ],
    );
  }
}
