import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:flutter/material.dart';

/// 迷你日历的日期数据结构
class MiniViewDayModel {
  final int index; // 下标
  final DateTime date; // 日期
  final bool isToday; // 是否是当天
  final bool isCurrentMonth; // 是否是当月
  bool hasSchedule; // 是否包含日程
  bool isSelected; // 是否选中

  MiniViewDayModel({
    required this.index,
    required this.date,
    this.isToday = false,
    this.isCurrentMonth = true,
    this.isSelected = false,
    this.hasSchedule = false,
  });

  setSelected() {
    isSelected = true;
  }

  setUnselected() {
    isSelected = false;
  }
}

/// 月视图的日期数据结构
class MonthViewDayModel {
  final int index; // 下标
  final DateTime date; // 日期
  final bool isToday; // 是否是当天
  final bool isCurrentMonth; // 是否是当月
  bool isSelected; // 是否选中
  List<ScheduleModel> scheduleList; // 日程列表

  MonthViewDayModel({
    required this.index,
    required this.date,
    this.isToday = false,
    this.isCurrentMonth = true,
    this.isSelected = false,
    this.scheduleList = const [],
  });

  setSelected() {
    isSelected = true;
  }

  setUnselected() {
    isSelected = false;
  }
}

class ScheduleModel {
  final String title; // 日程标题
  final String content; // 日程内容
  final DateTime day; // 日程日期
  final ScheduleType type; // 日程类型
  final DateTime? startTime; // 日程开始时间
  final DateTime? endTime; // 日程结束时间

  ScheduleModel({
    required this.title,
    required this.content,
    required this.day,
    required this.type,
    this.startTime,
    this.endTime,
  });
}

/// 结构化的日程类型数据：类型名称，类型是否选中，类型颜色
class ScheduleType {
  final String typeName; // 类型名称
  final TransactionStatusEnum typeEnum; // 类型枚举
  final Color color; // 类型颜色
  bool isSelected; // 类型是否选中

  ScheduleType({
    required this.typeName,
    required this.typeEnum,
    required this.isSelected,
    required this.color,
  });
}

class ScheduleTypeConfig {
  List<ScheduleType> scheduleTypeList = [
    ScheduleType(
      typeName: i18nBook.realTimeConsultation.toBeStarted.t,
      typeEnum: TransactionStatusEnum.ToStart,
      color: Color.fromARGB(255, 240, 184, 74),
      isSelected: true,
    ),
    ScheduleType(
      typeName: i18nBook.realTimeConsultation.haveInHand.t,
      typeEnum: TransactionStatusEnum.InProgress,
      color: Colors.green,
      isSelected: true,
    ),
    ScheduleType(
      typeName: i18nBook.realTimeConsultation.toBeReported.t,
      typeEnum: TransactionStatusEnum.PendingReport,
      color: Color.fromARGB(255, 253, 137, 176),
      isSelected: true,
    ),
    ScheduleType(
      typeName: i18nBook.realTimeConsultation.closed.t,
      typeEnum: TransactionStatusEnum.End,
      color: Colors.blue,
      isSelected: true,
    ),
  ];
}
