import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:smart_hotel_app/views/report/index/cubit/report_index_state.dart';

class ReportIndexCubit extends Cubit<ReportIndexState> {
  ReportIndexCubit() : super(const ReportIndexState()) {
    initData();
  }

  void initData() {
    emit(state.copyWith(
      reportHeader: {
        'title': '经营概览看板',
        'subtitle': '管理层视角 · 关键指标一览',
      },
      reportMetrics: {
        'powerUsage': {
          'value': 1284,
          'unit': 'kWh',
          'change': -8,
          'changeText': '↓ 8%',
          'progress': 0.6,
        },
        'pendingAlerts': {
          'value': 3,
          'unit': '条',
          'change': null,
          'changeText': '需关注',
          'progress': 0.3,
        },
      },
      weeklyPowerUsage: {
        'title': '本周用电趋势',
        'unit': 'kWh',
        'dateRange': '5.7 - 5.13',
        'data': [
          {'day': '一', 'value': 120},
          {'day': '二', 'value': 180},
          {'day': '三', 'value': 150},
          {'day': '四', 'value': 200},
          {'day': '五', 'value': 250},
          {'day': '六', 'value': 220},
          {'day': '日', 'value': 164},
        ],
      },
      roomStatusDistribution: {
        'title': '客房状态分布',
        'totalRooms': 52,
        'statuses': [
          {'name': '入住中', 'count': 45, 'color': const Color.fromRGBO(59, 130, 246, 1)},
          {'name': '空闲', 'count': 7, 'color': const Color.fromRGBO(148, 163, 184, 1)},
          {'name': '已预订', 'count': 5, 'color': const Color.fromRGBO(96, 165, 250, 1)},
          {'name': '设备告警', 'count': 3, 'color': const Color.fromRGBO(249, 115, 22, 1)},
        ],
      },
      deviceOnlineRate: {
        'title': '设备在线率',
        'rate': 1.0,
        'rateText': '100%',
        'devices': [
          {'name': '智能空开', 'count': 16},
          {'name': '客控设备', 'count': 24},
          {'name': '网络设备', 'count': 8},
        ],
      },
      quickActions: {
        'title': '快捷操作',
        'actions': [
          {'name': '告警记录', 'icon': Icons.warning_amber_outlined},
          {'name': '联动规则', 'icon': Icons.tune},
        ],
      },
    ));
  }
}