import 'package:fis_common/event/event_type.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/pages/schedule/calendar/models.dart';
import 'package:get/get.dart';

class PopupLayerController extends GetxController {
  PopupLayerController();

  /// 弹出层【显示更多日程】事件通知
  FEventHandler<GlobalKey> onPopupMoreSchedule = FEventHandler<GlobalKey>();

  /// 弹出层【显示日程详情】事件通知
  FEventHandler<GlobalKey> onPopupScheduleDatail = FEventHandler<GlobalKey>();

  /// 全局点击事件通知
  FEventHandler<PointerEvent> onGlobalClick = FEventHandler<PointerEvent>();

  /// 关闭日程弹窗 事件通知
  FEventHandler<void> onCloseSchedulePopup = FEventHandler<void>();

  /// Popup 弹出层相关的数据
  /// 当前需要显示更多的日程数据
  MonthViewDayModel currMoreScheduleData = MonthViewDayModel(
    index: 1,
    date: DateTime.now(),
  );

  ScheduleModel currScheduleData = ScheduleModel(
    title: 'title',
    content: 'content',
    day: DateTime.now(),
    type: ScheduleType(
      typeName: 'typeName',
      typeEnum: TransactionStatusEnum.ToStart,
      isSelected: true,
      color: Colors.red,
    ),
    startTime: DateTime.now(),
    endTime: DateTime.now(),
  );

  void handlePopupMoreSchedule(
      GlobalKey key, MonthViewDayModel moreScheduleData) {
    currMoreScheduleData = moreScheduleData;
    onPopupMoreSchedule.emit(this, key);
  }

  void handlePopupScheduleDetail(GlobalKey key, ScheduleModel scheduleData) {
    currScheduleData = scheduleData;
    onPopupScheduleDatail.emit(this, key);
  }

  @override
  void onInit() {
    super.onInit();
  }
}
