Skip to content

Commit

Permalink
#61 (#116)
Browse files Browse the repository at this point in the history
* Enhancement/remove where (#53)

* Add removeWhere to EventController

* Fix merge and remove events

* 馃悰 : Duplicate item in cells while adding events in the same session #61

Signed-off-by: Mehul Kabaria <mehul.kabaria@gmail.com>

Signed-off-by: Mehul Kabaria <mehul.kabaria@gmail.com>
Co-authored-by: Alexandre <97731236+AlexandreMaul@users.noreply.github.com>
  • Loading branch information
MehulKK and AlexandreMaul committed Nov 17, 2022
1 parent 1306b46 commit abc55bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
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
}

0 comments on commit abc55bb

Please sign in to comment.