import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart';

class AbnormalListCubit extends Cubit<AbnormalListState> {
  AbnormalListCubit() : super(AbnormalListState(currentFilter: AlarmStatus.all, alarmList: _getAlarmList()));

  static List<AlarmItem> _getAlarmList() {
    return [
      const AlarmItem(
        id: '1',
        title: '温度异常告警',
        deviceInfo: 'A-301智能空开·客房301',
        alarmTime: '2026-5-30 16:32:31',
        processTime: '2026-5-30 16:32:31',
        status: AlarmStatus.pending,
        level: '高警',
        urgency: '紧急',
      ),
      const AlarmItem(
        id: '2',
        title: '温度异常告警',
        deviceInfo: 'A-301智能空开·客房301',
        alarmTime: '2026-5-30 16:32:31',
        processTime: '2026-5-30 16:32:31',
        status: AlarmStatus.processed,
        level: '高警',
        urgency: '紧急',
      ),
      const AlarmItem(
        id: '3',
        title: '温度异常告警',
        deviceInfo: 'A-301智能空开·客房301',
        alarmTime: '2026-5-30 16:32:31',
        processTime: '2026-5-30 16:32:31',
        status: AlarmStatus.falseAlarm,
        level: '高警',
        urgency: '紧急',
      ),
    ];
  }

  void setFilter(AlarmStatus filter) {
    emit(state.copyWith(currentFilter: filter));
  }

  void onAlarmItemTap(AlarmItem item) {
    print('点击告警: ${item.title}');
  }
}
