feat: Enhance calendar event data model to support multiple constructors and recursive settings using built-in weekday enums.#510
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces significant breaking changes to enhance the calendar event model and add multi-day view support to the desktop demo. The changes refactor the event data structure to use TimeOfDay instead of DateTime for time representation, introduce multiple factory constructors for different event types, and update the recurrence model to use WeekDays enum.
Changes:
- Refactored
CalendarEventDatato useTimeOfDayfor start/end times and added factory constructors (timeRanged,wholeDay,multiDay) for better API clarity - Updated
RecurrenceSettingsto useWeekDaysenum instead of integer indices for weekday representation - Added
weekDayEnumextension toDateTimeand new extensions toTimeOfDayfor time manipulation and comparison
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/calendar_event_data.dart | Refactored to use TimeOfDay for times and added three factory constructors for different event types |
| lib/src/modals.dart | Updated RecurrenceSettings to use WeekDays enum for weekday representation |
| lib/src/extensions.dart | Added weekDayEnum to DateTime, new TimeOfDay extensions (isDayStart, toDateTime, isSameAs), and static copyFromMinutes method |
| lib/src/event_controller.dart | Updated weekday comparison to use WeekDays enum |
| lib/src/event_arrangers/side_event_arranger.dart | Updated to use new TimeOfDay extension methods for duration calculation |
| lib/src/event_arrangers/merge_event_arranger.dart | Updated to use new TimeOfDay extension methods for duration calculation |
| lib/src/week_view/week_view.dart | Changed weekday indexing to use weekDayEnum |
| lib/src/multi_day_view/multi_day_view.dart | Changed weekday indexing to use weekDayEnum |
| lib/src/month_view/month_view.dart | Changed weekday indexing to use weekDayEnum |
| test/src/event_controller_test.dart | Updated tests to use new CalendarEventData API with TimeOfDay |
| test/extensions_test.dart | Refactored to use weekDayEnum extension |
| test/event_arranger_test/merge_event_arranger_test.dart | Updated all test events to use new API |
| test/custom_sort_test.dart | Updated test events to use new API |
| example/lib/pages/home_page.dart | Demonstrated new factory methods with example events |
| example/lib/widgets/add_event_form.dart | Updated to handle TimeOfDay and WeekDays enum |
| example/lib/widgets/calendar_views.dart | Added multi-day view to calendar options |
| example/lib/widgets/calendar_configs.dart | Added multi-day view translation |
| example/lib/widgets/week_view_widget.dart | Removed maxWidth parameter from SideEventArranger |
| example/lib/widgets/multi_day_view_widget.dart | Removed maxWidth parameter and added backgroundColor |
| example/lib/l10n/*.arb | Added translations for new multi-day event examples |
| example/lib/extension.dart | Added TimeOfDayExtension with time formatting |
| example/lib/enumerations.dart | Added multiDay to CalendarView enum |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
06f9035 to
d4453d7
Compare
d4453d7 to
e3adbc3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…a model to use multiple constructors and TimeOfDay where applicable
e3adbc3 to
5b00792
Compare
| required DateTime date, | ||
| required this.date, | ||
| required this.startTime, | ||
| required this.endTime, |
There was a problem hiding this comment.
Make this optional. Start time and end time should not be required in common constructor.
| Text( | ||
| widget.weekDayStringBuilder?.call(date.weekday - 1) ?? | ||
| PackageStrings.currentLocale.weekdays[date.weekday - 1], | ||
| widget.weekDayStringBuilder?.call(date.weekDayEnum.index) ?? |
There was a problem hiding this comment.
We can update the builders use WeekDays only instead of index. This will increase the readability
| Text( | ||
| widget.weekDayStringBuilder?.call(date.weekday - 1) ?? | ||
| PackageStrings.currentLocale.weekdays[date.weekday - 1], | ||
| widget.weekDayStringBuilder?.call(date.weekDayEnum.index) ?? |
| width: _cellWidth, | ||
| child: | ||
| _weekBuilder(weekDays[index].weekday - 1), | ||
| child: _weekBuilder( |
| right: 0, | ||
| startDuration: startTime.copyFromMinutes(eventStart), | ||
| endDuration: endTime.copyFromMinutes(eventEnd), | ||
| startDuration: TimeOfDayExtension.copyFromMinutes(eventStart) |
There was a problem hiding this comment.
Check if this is valid implementation.
…a model to use multiple constructors and TimeOfDay where applicable
Description
Added multi-day calendar view support to the desktop demo for better visualization of extended events.
Refactors the calendar event data model to support Multiple constructors and Used TimeOfDay instead of DateTime for only hours and minutes usage.
Refactors the recursive settings model to support in-built enum of weekdays.
Checklist
fix:,feat:,docs:etc).docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
#509
#293