import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:smart_hotel_app/views/report/device/cubit/device_list_state.dart';

class DeviceListCubit extends Cubit<DeviceListState> {
  DeviceListCubit() : super(const DeviceListState()) {
    _initData();
  }

  void _initData() {
    final devices = [
      const DeviceInfo(
        id: '1',
        name: '智能空开 1F-01',
        room: '101',
        type: DeviceTypeEnum.smartBreaker,
        online: true,
        status: '正常',
        lastUpdate: '10:30',
      ),
      const DeviceInfo(
        id: '2',
        name: '客控设备 1F-01',
        room: '101',
        type: DeviceTypeEnum.guestControl,
        online: true,
        status: '正常',
        lastUpdate: '10:32',
      ),
      const DeviceInfo(
        id: '3',
        name: '网络设备 1F',
        room: '一楼',
        type: DeviceTypeEnum.network,
        online: true,
        status: '正常',
        lastUpdate: '10:28',
      ),
      const DeviceInfo(
        id: '4',
        name: '智能空开 2F-01',
        room: '201',
        type: DeviceTypeEnum.smartBreaker,
        online: true,
        status: '正常',
        lastUpdate: '10:25',
      ),
      const DeviceInfo(
        id: '5',
        name: '客控设备 2F-01',
        room: '201',
        type: DeviceTypeEnum.guestControl,
        online: false,
        status: '离线',
        lastUpdate: '09:15',
      ),
      const DeviceInfo(
        id: '6',
        name: '智能空开 3F-01',
        room: '301',
        type: DeviceTypeEnum.smartBreaker,
        online: true,
        status: '正常',
        lastUpdate: '10:30',
      ),
      const DeviceInfo(
        id: '7',
        name: '客控设备 3F-01',
        room: '301',
        type: DeviceTypeEnum.guestControl,
        online: true,
        status: '正常',
        lastUpdate: '10:30',
      ),
      const DeviceInfo(
        id: '8',
        name: '网络设备 2F',
        room: '二楼',
        type: DeviceTypeEnum.network,
        online: true,
        status: '正常',
        lastUpdate: '10:30',
      ),
    ];

    emit(state.copyWith(devices: devices));
  }

  void selectType(DeviceTypeEnum type) {
    emit(state.copyWith(selectedType: type));
  }
}
