diff --git a/lib/home_page.dart b/lib/home_page.dart index 219c17b..e76a14f 100644 --- a/lib/home_page.dart +++ b/lib/home_page.dart @@ -95,6 +95,7 @@ class _HomePageState extends State { void initState() { super.initState(); _caseStudyPlans = _fetchCaseStudyPlans(); + _newCoursesFuture = _fetchNewCourses(); // Initialize new courses future _fetchTimezone(); _clockStream = Stream.periodic(const Duration(seconds: 1), (_) { @@ -353,7 +354,7 @@ class _HomePageState extends State { final plans = snapshot.data!; return ListView.builder( scrollDirection: Axis.horizontal, // 가로 스크롤로 변경 - padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 8.0), + padding: const EdgeInsets.only(left: 10.0, right: 5.0, top: 8.0, bottom: 5.0), itemCount: plans.length, itemBuilder: (context, index) { final plan = plans[index]; @@ -395,7 +396,7 @@ class _HomePageState extends State { final courses = snapshot.data!; return ListView.builder( scrollDirection: Axis.horizontal, - padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 8.0), + padding: const EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0), itemCount: courses.length, itemBuilder: (context, index) { final course = courses[index]; @@ -410,6 +411,47 @@ class _HomePageState extends State { // --- ▼▼▼ 추천 클래스 섹션 호출 ▼▼▼ --- _buildRecommendSection(), // --- ▲▲▲ 추천 클래스 섹션 호출 끝 ▲▲▲ --- + const Padding( + padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), + child: Text('Trending On New Study', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)), + ), + SizedBox( + height: 200, // 가로 리스트의 높이를 줄입니다. + child: FutureBuilder>( + future: _caseStudyPlans, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Padding( + padding: const EdgeInsets.all(16.0), + child: Text('Error loading upcoming classes: ${snapshot.error}', textAlign: TextAlign.center), + )); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center(child: Text('No upcoming classes available.')); + } else { + final plans = snapshot.data!; + return ListView.builder( + scrollDirection: Axis.horizontal, // 가로 스크롤로 변경 + padding: const EdgeInsets.only(left: 10.0, right: 5.0, top: 8.0, bottom: 5.0), + itemCount: plans.length, + itemBuilder: (context, index) { + final plan = plans[index]; + return Align( + alignment: Alignment.topCenter, // 항목을 상단 중앙에 정렬 + child: UpcomingClassCard( + plan: plan, + onTap: () { + widget.onNavigateToPlanTab(1); + }, + ), + ); + }, + ); + } + }, + ), + ), ], ), );