From d6600d26a59565f4fce5bfca985a6195364c154b Mon Sep 17 00:00:00 2001 From: Balazs Bokanyi Date: Thu, 6 Jul 2023 14:00:09 +0200 Subject: [PATCH] fixed not fitted events counter --- lib/src/utils/event_utils.dart | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/src/utils/event_utils.dart b/lib/src/utils/event_utils.dart index a4e86b8..564902c 100644 --- a/lib/src/utils/event_utils.dart +++ b/lib/src/utils/event_utils.dart @@ -109,10 +109,7 @@ EventProperties? _mapSimpleEventToDrawerOrNull( /// Map EventDrawers to EventsLineDrawer and sort them by duration on current week List placeEventsToLines( - List events, int maxLines) { - final copy = [...events] - ..sort((a, b) => b.size().compareTo(a.size())); - + List copy, int maxLines) { final lines = List.generate(maxLines, (index) { final lineDrawer = EventsLineDrawer(); for (var day = 1; day <= Contract.kWeekDaysCount; day++) { @@ -139,17 +136,13 @@ List calculateOverflowedEvents( List> monthEvents, int maxLines) { final weeks = []; for (final week in monthEvents) { - var countList = List.filled(WeekDay.values.length, 0); + final countList = List.filled(WeekDay.values.length, 0); for (final event in week) { for (var i = event.begin - 1; i < event.end; i++) { countList[i]++; } } - countList = countList.map((count) { - final notFitCount = count - maxLines; - return notFitCount <= 0 ? 0 : notFitCount; - }).toList(); weeks.add(NotFittedWeekEventCount(countList)); } return weeks;