diff --git a/lib/src/screens/home/content.dart b/lib/src/screens/home/content.dart index 1807865..276c6b3 100644 --- a/lib/src/screens/home/content.dart +++ b/lib/src/screens/home/content.dart @@ -83,15 +83,13 @@ class _HomeContentState extends State { ), 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(), diff --git a/lib/src/widgets/events/events_list.dart b/lib/src/widgets/events/events_list.dart index f0e0f71..c6945b1 100644 --- a/lib/src/widgets/events/events_list.dart +++ b/lib/src/widgets/events/events_list.dart @@ -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, ); } @@ -46,21 +50,24 @@ class _EventsListState extends State { builder: (context, snapshot) { if (snapshot.hasData) { var events = snapshot.data!.where((event) { - return event.time.isAfter(widget.dateRange.start) && - event.time.isBefore(widget.dateRange.end); - }); - if (events.isNotEmpty) { - return Column( - children: events.map((event) { - return Padding( - padding: const EdgeInsets.only(bottom: 15), - child: EventCard(event), - ); - }).toList()); - } else { + 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) { return Padding( padding: const EdgeInsets.only(bottom: 15), - child: SizedBox( + child: EventCard(event), + ); + }).toList()); + } else { + return Padding( + padding: const EdgeInsets.only(bottom: 15), + child: SizedBox( width: double.infinity, height: 50, child: Center(