From 475fff93206db30b310f66813ba4c44786c49b20 Mon Sep 17 00:00:00 2001 From: Parth Baraiya Date: Thu, 2 Jun 2022 15:14:13 +0530 Subject: [PATCH] :bookmark: calculate week difference based on start day. (#74) Update package version Update CHANGELOG.md Co-authored-by: Parth Baraiya --- CHANGELOG.md | 15 ++++++++------- lib/src/extensions.dart | 8 ++++++-- lib/src/week_view/week_view.dart | 3 ++- pubspec.yaml | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb19d3ac..69551f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,24 @@ -# [0.0.5]() - 15 March 2022 [Unreleased] +# [0.0.5 - 2 Jun 2022](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.5) - Fixed issue [#48 - WeekView header date is different from the calendar view](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/48) -- Fixed issue [#46 - Change beginning of week in MonthView](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/46) +- Added feature [#46 - Change beginning of week in MonthView](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/46) - Fixed issue [#42 - WeekDayTile causes RenderFlex-Overflow](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/42) - Fixed issue [#65 - Adding onCellTap callback breaks whole calendar](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/65) - Fixed issue [#62 - Missing redraw events](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/62) +- Show live time indicator line above event tiles. PR [#67](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/pull/67) -# [0.0.4](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.4) +# [0.0.4 - 2 Mar 2022](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.4) - Fixed issue [#39 - Detect a long press on the calendar](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/39) - Fixed issue [#38 - Modifying CalendarEventData](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/38) - Fixed issue [#27 - EventController remove event don't work](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/27) -- Fixed issue [#13 - Give the option to show weekdays in a weekview.](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/13) +- Fixed issue [#13 - Give the option to show weekdays in a WeekView.](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/13) -# [0.0.3](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.3) +# [0.0.3 - 12 Oct 2021](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.3) - Added support for multiple day events -# [0.0.2](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.2) +# [0.0.2 - 3 Sep 2021](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.2) - Update `README.md` file. - Add license information in package files. @@ -28,6 +29,6 @@ - Add `onCellTap` callback in `MonthView`. - Make `controller` optional parameter in all views where `CalendarControllerProvider` is provided. -# [0.0.1](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.1) +# [0.0.1 - 26 Aug 2021](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/0.0.1) - Initial release \ No newline at end of file diff --git a/lib/src/extensions.dart b/lib/src/extensions.dart index 809a966e..ceaca6b0 100644 --- a/lib/src/extensions.dart +++ b/lib/src/extensions.dart @@ -35,8 +35,12 @@ extension DateTimeExtensions on DateTime { int getDayDifference(DateTime date) => difference(date).inDays.abs(); /// Gets difference of weeks between [date] and calling object. - int getWeekDifference(DateTime date) => - (firstDayOfWeek().difference(date.firstDayOfWeek()).inDays.abs() / 7) + int getWeekDifference(DateTime date, {WeekDays start = WeekDays.monday}) => + (firstDayOfWeek(start: start) + .difference(date.firstDayOfWeek(start: start)) + .inDays + .abs() / + 7) .ceil(); /// Returns The List of date of Current Week diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 8570b27a..3225a1e2 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -456,7 +456,8 @@ class WeekViewState extends State> { _currentStartDate = _currentWeek.firstDayOfWeek(start: widget.startDay); _currentEndDate = _currentWeek.lastDayOfWeek(start: widget.startDay); - _currentIndex = _minDate.getWeekDifference(_currentEndDate); + _currentIndex = + _minDate.getWeekDifference(_currentEndDate, start: widget.startDay); } /// Sets the minimum and maximum dates for current view. diff --git a/pubspec.yaml b/pubspec.yaml index 74bc22ae..0b7f3125 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: calendar_view description: A Flutter package allows you to easily implement all calendar UI and calendar event functionality. -version: 0.0.4 +version: 0.0.5 homepage: https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view issue_tracker: https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues