Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not fitted event counter fix #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lib/src/utils/event_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ EventProperties? _mapSimpleEventToDrawerOrNull(

/// Map EventDrawers to EventsLineDrawer and sort them by duration on current week
List<EventsLineDrawer> placeEventsToLines(
List<EventProperties> events, int maxLines) {
final copy = <EventProperties>[...events]
..sort((a, b) => b.size().compareTo(a.size()));

List<EventProperties> copy, int maxLines) {
final lines = List.generate(maxLines, (index) {
final lineDrawer = EventsLineDrawer();
for (var day = 1; day <= Contract.kWeekDaysCount; day++) {
Expand All @@ -139,17 +136,13 @@ List<NotFittedWeekEventCount> calculateOverflowedEvents(
List<List<EventProperties>> monthEvents, int maxLines) {
final weeks = <NotFittedWeekEventCount>[];
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;
Expand Down