import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:smart_hotel_app/views/home/index/cubit/home_index_state.dart';
import 'package:flutter/material.dart';

class HomeIndexCubit extends Cubit<HomeIndexState> {
  HomeIndexCubit() : super(const HomeIndexState()) {
    initData();
  }

  void initData() {
    emit(state.copyWith(
      highAlarmCount: 1,
      mediumAlarmCount: 1,
      onlineDeviceCount: 48,
      temperatureAlarmTitle: '温度异常告警',
      temperatureAlarmLocation: '客房301·A-301智能空开',
      currentTemperature: '85',
      currentVoltage: '220',
      currentCurrent: '3.2',
      waitTime: '2h37m',
      alarmLevel: '紧急',
      voltageAlarmTitle: '电压波动告警',
      voltageAlarmLocation: '会议室2F-01',
      voltageValue: '248',
      normalVoltage: '235',
      voltageWaitTime: '1h19m',
      voltageAlarmLevel: '中警',
      equipmentList: const [
        EquipmentItem(icon: Icons.power, title: '客房305空开', subtitle: '38°C·220V·520W', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.power, title: '大堂总空开L-01', subtitle: '380V·42A·28.6kW', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.wifi, title: '招牌AP-03', subtitle: '信号弱·RSSI-78dBm', status: '注意', statusColor: Color.fromRGBO(255, 193, 7, 1.0)),
        EquipmentItem(icon: Icons.power, title: '客房201空开', subtitle: '25°C·220V·380W', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.power, title: '水泵控制箱', subtitle: '运行中·2.2kW', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.thermostat, title: '冷库温控器', subtitle: '-18°C·异常波动', status: '告警', statusColor: Color.fromRGBO(255, 77, 79, 1.0)),
        EquipmentItem(icon: Icons.light, title: '走廊照明回路', subtitle: '12盏·功率240W', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.wifi, title: '会议室AP-01', subtitle: '连接数12·信号强', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.power, title: '电梯控制柜', subtitle: '运行中·电压稳定', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
        EquipmentItem(icon: Icons.thermostat, title: '空调外机', subtitle: '压力偏高·需检查', status: '注意', statusColor: Color.fromRGBO(255, 193, 7, 1.0)),
        EquipmentItem(icon: Icons.wifi, title: '楼道AP-05', subtitle: '离线·需重启', status: '离线', statusColor: Color.fromRGBO(102, 102, 102, 1.0)),
        EquipmentItem(icon: Icons.power, title: '厨房消毒柜', subtitle: '消毒中·温度120°C', status: '正常', statusColor: Color.fromRGBO(26, 188, 156, 1.0)),
      ],
    ));
  }
}