diff --git a/lib/views/course_view/components/course_section.dart b/lib/views/course_view/components/course_section.dart index a383298..967b21e 100644 --- a/lib/views/course_view/components/course_section.dart +++ b/lib/views/course_view/components/course_section.dart @@ -7,6 +7,8 @@ import 'package:gocast_mobile/utils/section_kind.dart'; import 'package:gocast_mobile/views/components/view_all_button.dart'; import 'package:gocast_mobile/views/course_view/components/course_card.dart'; import 'package:gocast_mobile/views/course_view/course_detail_view/course_detail_view.dart'; +import 'dart:math' as math; + /// CourseSection /// @@ -26,7 +28,7 @@ import 'package:gocast_mobile/views/course_view/course_detail_view/course_detail class CourseSection extends StatelessWidget { final String sectionTitle; final SectionKind - sectionKind; //0 for livestreams, 1 cor mycourses, 2 for puliccourses + sectionKind; final List courses; final List streams; final VoidCallback? onViewAll; @@ -74,9 +76,11 @@ class CourseSection extends StatelessWidget { Widget _buildCourseList(BuildContext context) { bool isTablet = MediaQuery.of(context).size.width >= 600 ? true : false; + int displayCount = math.min(courses.length, 3); + double cardHeight = 75; return ConstrainedBox( - constraints: BoxConstraints(maxHeight: isTablet ? 600 : 400), + constraints: BoxConstraints(maxHeight: isTablet ? double.infinity : cardHeight * displayCount,), child: ListView.builder( physics: const ClampingScrollPhysics(), shrinkWrap: true, diff --git a/lib/views/course_view/list_courses_view/courses_list_view.dart b/lib/views/course_view/list_courses_view/courses_list_view.dart index 26f3c6a..c49c8cf 100644 --- a/lib/views/course_view/list_courses_view/courses_list_view.dart +++ b/lib/views/course_view/list_courses_view/courses_list_view.dart @@ -50,9 +50,7 @@ class CoursesList extends ConsumerWidget { final userPinned = ref.watch(pinnedCourseViewModelProvider).userPinned ?? []; List liveCourses = courses.where((course) => liveCourseIds.contains(course.id)).toList(); - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: isTablet ? 600 : 400), - child: ListView.builder( + return ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), scrollDirection: Axis.vertical, @@ -88,8 +86,6 @@ class CoursesList extends ConsumerWidget { ); }, ); - }, - ), - ); + }); } }