From ad3faf3a1a8f3126168db893c50404d200f37088 Mon Sep 17 00:00:00 2001 From: ntut-xuan Date: Mon, 4 Mar 2024 13:40:54 +0800 Subject: [PATCH 1/2] Implement: Improved UI and add student count --- lib/ui/pages/coursedetail/screen/course_info_page.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ui/pages/coursedetail/screen/course_info_page.dart b/lib/ui/pages/coursedetail/screen/course_info_page.dart index 21f434e1..61c0f79b 100644 --- a/lib/ui/pages/coursedetail/screen/course_info_page.dart +++ b/lib/ui/pages/coursedetail/screen/course_info_page.dart @@ -70,6 +70,9 @@ class _CourseInfoPageState extends State with AutomaticKeepAlive courseExtraInfo = task.result; } widget.courseInfo.extra = courseExtraInfo; + List students = await _getCourseStudent(); + Map departmentMap = await _getCourseDepartmentMap(); + courseData.add(_buildCourseInfo(sprintf("%s: %s", [R.current.courseId, courseMainInfo.course.id]))); courseData.add(_buildCourseInfo(sprintf("%s: %s", [R.current.courseName, courseMainInfo.course.name]))); courseData.add(_buildCourseInfo(sprintf("%s: %s ", [R.current.credit, courseMainInfo.course.credits]))); @@ -88,15 +91,17 @@ class _CourseInfoPageState extends State with AutomaticKeepAlive courseMainInfo.getClassroomNameList(), courseMainInfo.getClassroomHrefList(), )); + courseData.add(_buildCourseInfo(sprintf("%s: %s", [R.current.numberOfStudent, students.length]))); listItem.removeRange(0, listItem.length); listItem.add(_buildInfoTitle(R.current.courseData)); listItem.addAll(courseData); - List students = await _getCourseStudent(); - Map departmentMap = await _getCourseDepartmentMap(); + if (students.isNotEmpty) { + listItem.add(_buildInfoTitle("")); + listItem.add(_buildInfoTitle(R.current.studentList)); listItem.add( Padding( padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 0), From 04972d07f8d24bee650c75c14540f19016c3e10d Mon Sep 17 00:00:00 2001 From: ntut-xuan Date: Mon, 4 Mar 2024 13:50:35 +0800 Subject: [PATCH 2/2] Chore: Format --- lib/ui/pages/coursedetail/screen/course_info_page.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/ui/pages/coursedetail/screen/course_info_page.dart b/lib/ui/pages/coursedetail/screen/course_info_page.dart index 61c0f79b..7af33044 100644 --- a/lib/ui/pages/coursedetail/screen/course_info_page.dart +++ b/lib/ui/pages/coursedetail/screen/course_info_page.dart @@ -97,8 +97,6 @@ class _CourseInfoPageState extends State with AutomaticKeepAlive listItem.add(_buildInfoTitle(R.current.courseData)); listItem.addAll(courseData); - - if (students.isNotEmpty) { listItem.add(_buildInfoTitle("")); listItem.add(_buildInfoTitle(R.current.studentList));