calendar_util.dart 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import 'package:flutter/material.dart';
  2. /// 迷你日历的日期数据结构
  3. class MiniViewDayStructure {
  4. final int index; // 下标
  5. final DateTime date; // 日期
  6. final bool isToday; // 是否是当天
  7. final bool isCurrentMonth; // 是否是当月
  8. bool hasSchedule; // 是否包含日程
  9. bool isSelected; // 是否选中
  10. MiniViewDayStructure({
  11. required this.index,
  12. required this.date,
  13. this.isToday = false,
  14. this.isCurrentMonth = true,
  15. this.isSelected = false,
  16. this.hasSchedule = false,
  17. });
  18. setSelected() {
  19. isSelected = true;
  20. }
  21. setUnselected() {
  22. isSelected = false;
  23. }
  24. }
  25. /// 月视图的日期数据结构
  26. class MonthViewDayStructure {
  27. final int index; // 下标
  28. final DateTime date; // 日期
  29. final bool isToday; // 是否是当天
  30. final bool isCurrentMonth; // 是否是当月
  31. bool isSelected; // 是否选中
  32. List<Schedule> scheduleList; // 日程列表
  33. MonthViewDayStructure({
  34. required this.index,
  35. required this.date,
  36. this.isToday = false,
  37. this.isCurrentMonth = true,
  38. this.isSelected = false,
  39. this.scheduleList = const [],
  40. });
  41. setSelected() {
  42. isSelected = true;
  43. }
  44. setUnselected() {
  45. isSelected = false;
  46. }
  47. }
  48. /// 结构化的日程类型数据:类型名称,类型是否选中,类型颜色
  49. class ScheduleType {
  50. final String typeName; // 类型名称
  51. final Color color; // 类型颜色
  52. bool isSelected; // 类型是否选中
  53. ScheduleType({
  54. required this.typeName,
  55. required this.isSelected,
  56. required this.color,
  57. });
  58. }
  59. class Schedule {
  60. final String title; // 日程标题
  61. final String content; // 日程内容
  62. final DateTime day; // 日程日期
  63. final ScheduleType type; // 日程类型
  64. final DateTime? startTime; // 日程开始时间
  65. final DateTime? endTime; // 日程结束时间
  66. Schedule({
  67. required this.title,
  68. required this.content,
  69. required this.day,
  70. required this.type,
  71. this.startTime,
  72. this.endTime,
  73. });
  74. }