하단 광고 추가

This commit is contained in:
girinb
2025-07-15 01:17:16 +09:00
parent deda09ff84
commit 5fbabe9238

View File

@@ -6,7 +6,6 @@ import 'package:intl/intl.dart';
import 'package:csp2/common/widgets/upcoming_class_card.dart'; import 'package:csp2/common/widgets/upcoming_class_card.dart';
import 'package:csp2/common/widgets/course_card.dart'; import 'package:csp2/common/widgets/course_card.dart';
import 'package:csp2/course.dart'; // Course 클래스 import import 'package:csp2/course.dart'; // Course 클래스 import
// import 'package:flutter_native_timezone/flutter_native_timezone.dart'; // 주석 처리된 상태 유지
import '../plan_page.dart'; // PlanPage import import '../plan_page.dart'; // PlanPage import
// CaseStudyPlan 클래스 (변경 없음) // CaseStudyPlan 클래스 (변경 없음)
@@ -309,110 +308,110 @@ class _HomePageState extends State<HomePage> {
} }
Widget _buildHomeContent() { Widget _buildHomeContent() {
return Column( return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0), padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
child: IntrinsicHeight( child: IntrinsicHeight(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Expanded( Expanded(
flex: 1, flex: 1,
child: _buildLocalTimeBar(), child: _buildLocalTimeBar(),
), ),
const SizedBox(width: 12.0), const SizedBox(width: 12.0),
Expanded( Expanded(
flex: 1, flex: 1,
child: _buildButtons(), child: _buildButtons(),
), ),
], ],
),
), ),
), ),
), const Padding(
const Padding( padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), // vertical을 위아래 다르게 조정
padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), // vertical을 위아래 다르게 조정 child: Text('Upcoming Study', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
child: Text('Upcoming Study', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
SizedBox(
height: 200, // 가로 리스트의 높이를 줄입니다.
child: FutureBuilder<List<CaseStudyPlan>>(
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: 16.0, right: 16.0, top: 8.0),
itemCount: plans.length,
itemBuilder: (context, index) {
final plan = plans[index];
return Align(
alignment: Alignment.topCenter, // 항목을 상단 중앙에 정렬
child: UpcomingClassCard(
plan: plan,
onTap: () {
widget.onNavigateToPlanTab(1);
},
),
);
},
);
}
},
), ),
), SizedBox(
// --- ▼▼▼ Find Your New Course 섹션 ▼▼▼ --- height: 200, // 가로 리스트의 높이를 줄입니다.
const Padding( child: FutureBuilder<List<CaseStudyPlan>>(
padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), future: _caseStudyPlans,
child: Text('Find Your New Course', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)), builder: (context, snapshot) {
), if (snapshot.connectionState == ConnectionState.waiting) {
SizedBox( return const Center(child: CircularProgressIndicator());
height: 175, // 가로 리스트의 높이 } else if (snapshot.hasError) {
child: FutureBuilder<List<Course>>( return Center(child: Padding(
future: _newCoursesFuture, padding: const EdgeInsets.all(16.0),
builder: (context, snapshot) { child: Text('Error loading upcoming classes: ${snapshot.error}', textAlign: TextAlign.center),
if (snapshot.connectionState == ConnectionState.waiting) { ));
return const Center(child: CircularProgressIndicator()); } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
} else if (snapshot.hasError) { return const Center(child: Text('No upcoming classes available.'));
return Center(child: Padding( } else {
padding: const EdgeInsets.all(16.0), final plans = snapshot.data!;
child: Text('Error loading new courses: ${snapshot.error}', textAlign: TextAlign.center), return ListView.builder(
)); scrollDirection: Axis.horizontal, // 가로 스크롤로 변경
} else if (!snapshot.hasData || snapshot.data!.isEmpty) { padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 8.0),
return const Center(child: Text('No new courses available.')); itemCount: plans.length,
} else { itemBuilder: (context, index) {
final courses = snapshot.data!; final plan = plans[index];
return ListView.builder( return Align(
scrollDirection: Axis.horizontal, alignment: Alignment.topCenter, // 항목을 상단 중앙에 정렬
padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 8.0), child: UpcomingClassCard(
itemCount: courses.length, plan: plan,
itemBuilder: (context, index) { onTap: () {
final course = courses[index]; widget.onNavigateToPlanTab(1);
return CourseCard(course: course,); },
}, ),
); );
} },
}, );
}
},
),
), ),
), // --- ▼▼▼ Find Your New Course 섹션 ▼▼▼ ---
// --- ▲▲▲ Find Your New Course 섹션 끝 ▲▲▲ --- const Padding(
// --- ▼▼▼ 추천 클래스 섹션 호출 ▼▼▼ --- padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
// _buildRecommendSection(), child: Text('Find Your New Course', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
// --- ▲▲▲ 추천 클래스 섹션 호출 끝 ▲▲▲ --- ),
SizedBox(
], height: 180,
child: FutureBuilder<List<Course>>(
future: _newCoursesFuture,
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 new courses: ${snapshot.error}', textAlign: TextAlign.center),
));
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
return const Center(child: Text('No new courses available.'));
} else {
final courses = snapshot.data!;
return ListView.builder(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 16.0, right: 16.0, top: 8.0),
itemCount: courses.length,
itemBuilder: (context, index) {
final course = courses[index];
return CourseCard(course: course);
},
);
}
},
),
),
// --- ▲▲▲ Find Your New Course 섹션 끝 ▲▲▲ ---
// --- ▼▼▼ 추천 클래스 섹션 호출 ▼▼▼ ---
_buildRecommendSection(),
// --- ▲▲▲ 추천 클래스 섹션 호출 끝 ▲▲▲ ---
],
),
); );
} }
@@ -474,8 +473,8 @@ class _HomePageState extends State<HomePage> {
final currentPlan = _recommendPlans[_currentRecommendIndex]; final currentPlan = _recommendPlans[_currentRecommendIndex];
return Container( return Container(
margin: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 16.0), // 하단 마진 추가 margin: const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 0.0), // 하단 마진 추가
padding: const EdgeInsets.all(12.0), // padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).cardColor, // 카드 색상 사용 color: Theme.of(context).cardColor, // 카드 색상 사용
borderRadius: BorderRadius.circular(12.0), borderRadius: BorderRadius.circular(12.0),
@@ -491,26 +490,9 @@ class _HomePageState extends State<HomePage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(
'✨ Recommend Classes', // 이모지 추가
style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 12.0),
Text(
currentPlan.planName,
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w500),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
// Test: Plan ID 표시 (디버깅용)
// Text('ID: ${currentPlan.planId}', style: TextStyle(fontSize: 10, color: Colors.grey)),
AspectRatio( AspectRatio(
aspectRatio: 16 / 9, aspectRatio: 6 / 1,
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: currentPlan.thumbnail.isNotEmpty child: currentPlan.thumbnail.isNotEmpty
? Image.network( ? Image.network(
currentPlan.thumbnail, currentPlan.thumbnail,