simplified code across the app and consolidated duplicated helpers
This commit is contained in:
@@ -12,20 +12,22 @@ class MarianumDatesBloc
|
||||
MarianumDatesRepository
|
||||
> {
|
||||
MarianumDatesBloc() {
|
||||
on<SetPastEventsVisible>((event, emit) {
|
||||
add(
|
||||
on<SetPastEventsVisible>(
|
||||
(event, emit) => add(
|
||||
Emit((state) => state.copyWith(showPastEvents: event.shouldBeVisible)),
|
||||
);
|
||||
});
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool showPastEvents() => innerState?.showPastEvents ?? false;
|
||||
|
||||
List<MarianumDate>? getEvents() =>
|
||||
innerState?.events
|
||||
.where((e) => showPastEvents() || e.end.isAfter(DateTime.now()))
|
||||
.toList() ??
|
||||
[];
|
||||
List<MarianumDate> getEvents() {
|
||||
final now = DateTime.now();
|
||||
return innerState?.events
|
||||
.where((e) => showPastEvents() || e.end.isAfter(now))
|
||||
.toList() ??
|
||||
[];
|
||||
}
|
||||
|
||||
@override
|
||||
MarianumDatesState fromNothing() =>
|
||||
|
||||
Reference in New Issue
Block a user