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

#61 #116

Merged
merged 2 commits into from
Nov 17, 2022
Merged

#61 #116

Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ Above code will create `WeekView` with only five days, from monday to friday.
<td align="center"><a href="https://github.com/ParthBaraiya"><img src="https://avatars.githubusercontent.com/u/36261739?v=4" width="100px;" alt=""/><br /><sub><b>Parth Baraiya</b></sub></a></td>
<td align="center"><a href="https://github.com/ujas-m-simformsolutions"><img src="https://avatars.githubusercontent.com/u/76939001?v=4" width="100px;" alt=""/><br /><sub><b>Ujas Majithiya</b></sub></a></td>
<td align="center"><a href="https://github.com/AnkitPanchal10"><img src="https://avatars.githubusercontent.com/u/38405884?s=100" width="100px;" alt=""/><br /><sub><b>Ankit Panchal</b></sub></a></td>
<td align="center"><a href="https://github.com/MehulKK"><img src="https://avatars.githubusercontent.com/u/60209725?s=100" width="100px;" alt=""/><br /><sub><b>Mehul Kabaria</b></sub></a></td>
<td align="center"><a href="https://github.com/faiyaz-shaikh"><img src="https://avatars.githubusercontent.com/u/89002539?v=4" width="100px;" alt=""/><br /><sub><b>Faiyaz Shaikh</b></sub></a></td>
</tr>
</table>
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
31 changes: 16 additions & 15 deletions lib/src/event_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ class EventController<T extends Object?> extends ChangeNotifier {
}
}

/// Removes multiple [event] from this controller.
void removeWhere(bool Function(CalendarEventData<T> element) test) {
for (final e in _events.values) {
e.removeWhere(test);
}
_rangingEventList.removeWhere(test);
_eventList.removeWhere(test);
notifyListeners();
}

/// Returns events on given day.
///
/// To overwrite default behaviour of this function,
Expand All @@ -109,21 +119,12 @@ class EventController<T extends Object?> extends ChangeNotifier {
events.addAll(_events[date]!);
}

final daysFromRange = <DateTime>[];
for (final rangingEvent in _rangingEventList) {
for (var i = 0;
i <= rangingEvent.endDate.difference(rangingEvent.date).inDays;
i++) {
daysFromRange.add(rangingEvent.date.add(Duration(days: i)));
}
if (rangingEvent.date.isBefore(rangingEvent.endDate)) {
for (final eventDay in daysFromRange) {
if (eventDay.year == date.year &&
eventDay.month == date.month &&
eventDay.day == date.day) {
events.add(rangingEvent);
}
}
if (date == rangingEvent.date ||
date == rangingEvent.endDate ||
(date.isBefore(rangingEvent.endDate) &&
date.isAfter(rangingEvent.date))) {
events.add(rangingEvent);
}
}

Expand Down Expand Up @@ -163,5 +164,5 @@ class EventController<T extends Object?> extends ChangeNotifier {
notifyListeners();
}

//#endregion
//#endregion
}