aleksanderwozniak / table_calendar

Highly customizable, feature-packed calendar widget for Flutter
Apache License 2.0
1.84k stars 1k forks source link

feat: display static periods of time #872

Open FDuhen opened 6 months ago

FDuhen commented 6 months ago

Objective of the PR :
In my use-case, I've got events occurring over a few days.
For those specific events, I want to be able to show a view with a specific design for the start day, a specific design for the end day, and a specific design for the in-between.

Content of the PR :
To achieve what I needed, I re-used the logic you implemented with the "Range Selection".
You can now add the parameter highlightedPeriods, which takes a list of Period objects (which is just holding a start date and an end date). Those highlightedPeriod will be displayed as follows

https://github.com/aleksanderwozniak/table_calendar/assets/33631420/36cc57a7-bcee-4b7f-9ec8-a18fe0157f3e

I think that the "Range Selection" is more important than displaying those events occurring over a few days : for this reason, during the Range Selection, the design of the calendar is overwritten by the design declared for the Range Selection.

Everything can be customized thanks to the CalendarStyle and the CalendarBuilders parameters.

I didn't modify a lot of existing code, it shouldn't impact any of the current users, and I added some tests. The tests are mainly here to securise the Period object : I wrote an algorithm which job is to merge the overlapping periods that the user can pass as a parameter to the Calendar, easing the display process.