display a maximum of three upcoming events on the home page
This commit is contained in:
parent
cb9ccc1865
commit
662a1ae157
|
@ -83,15 +83,13 @@ class _HomeContentState extends State<HomeContent> {
|
|||
),
|
||||
const SizedBox(height: 20),
|
||||
const HeaderWidget(
|
||||
title: "Today's Events",
|
||||
link: HeaderLink(
|
||||
text: "View more",
|
||||
href: EventsRoute()
|
||||
),
|
||||
title: "Upcoming Events",
|
||||
link:
|
||||
HeaderLink(text: "View more", href: EventsRoute()),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: EventsList(),
|
||||
child: EventsList(limit: 3),
|
||||
),
|
||||
const HeaderWidget(title: "Food & Dining"),
|
||||
const RestaurantsList(),
|
||||
|
|
|
@ -8,14 +8,17 @@ import 'event_card.dart';
|
|||
|
||||
class EventsList extends StatefulWidget {
|
||||
final DateTimeRange dateRange;
|
||||
final int? limit;
|
||||
|
||||
const EventsList._({
|
||||
required this.dateRange,
|
||||
this.limit,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
factory EventsList({
|
||||
DateTimeRange? dateRange,
|
||||
int? limit,
|
||||
Key? key,
|
||||
}) {
|
||||
if (dateRange == null) {
|
||||
|
@ -27,6 +30,7 @@ class EventsList extends StatefulWidget {
|
|||
}
|
||||
return EventsList._(
|
||||
dateRange: dateRange,
|
||||
limit: limit,
|
||||
key: key,
|
||||
);
|
||||
}
|
||||
|
@ -49,6 +53,9 @@ class _EventsListState extends State<EventsList> {
|
|||
return event.time.isAfter(widget.dateRange.start) &&
|
||||
event.time.isBefore(widget.dateRange.end);
|
||||
});
|
||||
if (widget.limit != null) {
|
||||
events = events.take(widget.limit!);
|
||||
}
|
||||
if (events.isNotEmpty) {
|
||||
return Column(
|
||||
children: events.map((event) {
|
||||
|
|
Loading…
Reference in New Issue