import 'package:flyinsono/pages/schedule/calendar/models.dart';
import 'package:flyinsono/views/mobile/mobile_calendar/models.dart';
import 'package:get/get.dart';

class MobileCalendarState {
  final _currDateTime = DateTime.now().obs;
  final _selectedDate4MonthView = DateTime.now().obs;
  final _realPageIndex = 0.obs;
  final _pageChanging = false.obs;
  final _monthIndexList = <int>[].obs;
  final _monthViewScheduleMaxLines = 1.obs;
  final _monthViewScheduleList = RxList<List<MonthViewScheduleModel>>(
      List.generate(42, (index) => <MonthViewScheduleModel>[]));
  final _scheduleTypeList = <ScheduleType>[].obs;
  final _isShowMonthViewDetailPopup = false.obs;
  final _monthViewPopupScheduleList = <MonthViewScheduleModel>[].obs;
  final _selectedIndex4MonthPopup = 0.obs;
  final _selectedDateTime4MonthPopup = DateTime.now().obs;

  /// 当前时间
  DateTime get currDateTime => _currDateTime.value;

  /// 选中的日期 [用于月视图，指定月份]
  get selectedDate4MonthView => _selectedDate4MonthView.value;
  set selectedDate4MonthView(value) => _selectedDate4MonthView.value = value;

  /// 维护一个日程类型列表
  List<ScheduleType> get scheduleTypeList => _scheduleTypeList;
  set scheduleTypeList(value) => _scheduleTypeList.value = value;

  /// ** 月视图相关控制参数 **
  /// 真实页面下标
  int get realPageIndex => _realPageIndex.value;
  set realPageIndex(value) => _realPageIndex.value = value;

  /// 月视图滑动切换控制器-总虚拟页数 [必须设为奇数]
  int get monthViewPageCount => 51;

  /// 中间虚拟页面下标
  int get centerPageIndex => monthViewPageCount ~/ 2;

  /// 月份间隔数组【长度应该等于 monthViewPageCount】
  List<int> get monthIndexList => _monthIndexList;
  set monthIndexList(value) => _monthIndexList.value = value;

  /// 月视图日程最大行数
  int get monthViewScheduleMaxLines => _monthViewScheduleMaxLines.value;
  set monthViewScheduleMaxLines(value) =>
      _monthViewScheduleMaxLines.value = value;

  /// 月视图日程列表
  List<List<MonthViewScheduleModel>> get monthViewScheduleList =>
      _monthViewScheduleList;
  set monthViewScheduleList(List<List<MonthViewScheduleModel>> value) =>
      _monthViewScheduleList.value = value;

  /// 页面切换中
  bool get isPageChanging => _pageChanging.value;
  set isPageChanging(value) => _pageChanging.value = value;

  /// 是否显示弹出层
  bool get isShowMonthViewDetailPopup => _isShowMonthViewDetailPopup.value;
  set isShowMonthViewDetailPopup(value) =>
      _isShowMonthViewDetailPopup.value = value;

  /// 选中的弹出层日程下标
  int get selectedIndex4MonthPopup => _selectedIndex4MonthPopup.value;
  set selectedIndex4MonthPopup(value) =>
      _selectedIndex4MonthPopup.value = value;

  /// 选中的弹出层日程时间
  DateTime get selectedDateTime4MonthPopup =>
      _selectedDateTime4MonthPopup.value;
  set selectedDateTime4MonthPopup(value) =>
      _selectedDateTime4MonthPopup.value = value;

  /// 月视图弹出层日程列表
  List<MonthViewScheduleModel> get monthViewPopupScheduleList =>
      _monthViewPopupScheduleList;
  set monthViewPopupScheduleList(value) =>
      _monthViewPopupScheduleList.value = value;
}
