전체적인 시스템 추가.
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:csp2/common/widgets/job_card.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import 'package:csp2/job.dart';
|
||||
import 'package:csp2/common/data/job.dart';
|
||||
class JobsPage extends StatefulWidget {
|
||||
const JobsPage({super.key});
|
||||
|
||||
|
||||
23
lib/common/data/case_study_plan.dart
Normal file
23
lib/common/data/case_study_plan.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
class CaseStudyPlan {
|
||||
final String planId;
|
||||
final String planTitle;
|
||||
final String planTeacher;
|
||||
final String thumbnail;
|
||||
|
||||
CaseStudyPlan({
|
||||
required this.planId,
|
||||
required this.planTitle,
|
||||
required this.planTeacher,
|
||||
required this.thumbnail,
|
||||
});
|
||||
|
||||
factory CaseStudyPlan.fromJson(Map<String, dynamic> json) {
|
||||
return CaseStudyPlan(
|
||||
planId: json['casestudy lesson id'] ?? '아이디 없음',
|
||||
planTitle: json['course_name'] ?? '제목 없음',
|
||||
planTeacher: json['planTeacher'] ?? '',
|
||||
thumbnail: json['course_thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
22
lib/common/data/new_study.dart
Normal file
22
lib/common/data/new_study.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
class NewStudy {
|
||||
final String planId;
|
||||
final String planTitle;
|
||||
final String planTeacher;
|
||||
final String thumbnail;
|
||||
|
||||
NewStudy({
|
||||
required this.planId,
|
||||
required this.planTitle,
|
||||
required this.planTeacher,
|
||||
required this.thumbnail,
|
||||
});
|
||||
|
||||
factory NewStudy.fromJson(Map<String, dynamic> json) {
|
||||
return NewStudy(
|
||||
planId: json['casestudy lesson id'] ?? '아이디 없음',
|
||||
planTitle: json['course_name'] ?? '제목 없음',
|
||||
planTeacher: json['course_description'] ?? '선생님',
|
||||
thumbnail: json['course_thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
29
lib/common/data/plan_detail_item.dart
Normal file
29
lib/common/data/plan_detail_item.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
class PlanDetailItem {
|
||||
final String lessonId;
|
||||
final String lessonTag;
|
||||
final String lessonUrl;
|
||||
final String thumbnail;
|
||||
final String lessonName;
|
||||
final String lessonDescription;
|
||||
|
||||
PlanDetailItem({
|
||||
required this.lessonId,
|
||||
required this.lessonTag,
|
||||
required this.lessonUrl,
|
||||
required this.thumbnail,
|
||||
required this.lessonName,
|
||||
required this.lessonDescription,
|
||||
});
|
||||
|
||||
factory PlanDetailItem.fromJson(Map<String, dynamic> json) {
|
||||
return PlanDetailItem(
|
||||
lessonId: json['casestudy lesson id'] ?? 'ID 없음',
|
||||
lessonTag: json['lesson tag'] ?? '태그 없음',
|
||||
lessonUrl: json['lesson url'] ?? 'URL 없음',
|
||||
thumbnail: json['thumbnail'] ?? '',
|
||||
lessonName: json['lesson_name'] ?? '이름 없음',
|
||||
lessonDescription: json['lesson_description'] ?? '설명 없음',
|
||||
);
|
||||
}
|
||||
}
|
||||
23
lib/common/data/upcoming_study.dart
Normal file
23
lib/common/data/upcoming_study.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
class UpcomingStudy {
|
||||
final String planId;
|
||||
final String planTitle;
|
||||
final String planTeacher;
|
||||
final String thumbnail;
|
||||
|
||||
UpcomingStudy({
|
||||
required this.planId,
|
||||
required this.planTitle,
|
||||
required this.planTeacher,
|
||||
required this.thumbnail,
|
||||
});
|
||||
|
||||
factory UpcomingStudy.fromJson(Map<String, dynamic> json) {
|
||||
return UpcomingStudy(
|
||||
planId: json['casestudy lesson id'] ?? '아이디 없음',
|
||||
planTitle: json['course_name'] ?? '제목 없음',
|
||||
planTeacher: json['course_description'] ?? '선생님',
|
||||
thumbnail: json['course_thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:csp2/course.dart';
|
||||
import 'package:csp2/common/data/course.dart';
|
||||
class CourseCard extends StatelessWidget {
|
||||
final Course course;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:csp2/job.dart';
|
||||
import 'package:csp2/common/data/job.dart';
|
||||
class JobCard extends StatelessWidget {
|
||||
final Job job;
|
||||
|
||||
|
||||
91
lib/common/widgets/now_study_class_card.dart
Normal file
91
lib/common/widgets/now_study_class_card.dart
Normal file
@@ -0,0 +1,91 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../data/new_study.dart'; // NewStudy 모델을 import 합니다.
|
||||
|
||||
class StudyClassCard extends StatelessWidget {
|
||||
final NewStudy plan;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const StudyClassCard({
|
||||
super.key,
|
||||
required this.plan,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 2, // 화면 너비의 절반으로 설정
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Card(
|
||||
margin: const EdgeInsets.only(right: 12.0), // 항목 간의 간격 조정
|
||||
elevation: 2.0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
if (plan.thumbnail.isNotEmpty)
|
||||
Expanded(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: Image.network(
|
||||
plan.thumbnail,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.contain,
|
||||
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return const Center(child: Icon(Icons.broken_image, color: Colors.grey, size: 50));
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Center(child: Text('No Image', style: TextStyle(color: Colors.grey)))
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 5.0),
|
||||
SizedBox(
|
||||
height: 70, // 텍스트 영역의 고정 높이 설정 (두 줄 텍스트를 위한 충분한 공간)
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 48.0, // plan.planTitle이 항상 두 줄 공간을 차지하도록 고정
|
||||
child: Text(
|
||||
plan.planTitle,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4.0),
|
||||
Text(
|
||||
plan.planTeacher,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey[600]),
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../home_page.dart'; // CaseStudyPlan 모델을 import 합니다.
|
||||
import '../data/upcoming_study.dart'; // UpcomingStudy 모델을 import 합니다.
|
||||
|
||||
class UpcomingClassCard extends StatelessWidget {
|
||||
final CaseStudyPlan plan;
|
||||
final UpcomingStudy plan;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const UpcomingClassCard({
|
||||
|
||||
@@ -3,34 +3,13 @@ import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import 'dart:async'; // Timer를 사용하기 위해 추가
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:csp2/common/widgets/upcoming_class_card.dart';
|
||||
import 'package:csp2/common/widgets/course_card.dart';
|
||||
import 'package:csp2/course.dart'; // Course 클래스 import
|
||||
import '../plan_page.dart'; // PlanPage import
|
||||
|
||||
// CaseStudyPlan 클래스 (변경 없음)
|
||||
class CaseStudyPlan {
|
||||
final String planId;
|
||||
final String planTitle;
|
||||
final String planTeacher;
|
||||
final String thumbnail;
|
||||
|
||||
CaseStudyPlan({
|
||||
required this.planId,
|
||||
required this.planTitle,
|
||||
required this.planTeacher,
|
||||
required this.thumbnail,
|
||||
});
|
||||
|
||||
factory CaseStudyPlan.fromJson(Map<String, dynamic> json) {
|
||||
return CaseStudyPlan(
|
||||
planId: json['casestudy lesson id'] ?? '아이디 없음',
|
||||
planTitle: json['course_name'] ?? '제목 없음',
|
||||
planTeacher: json['course_description'] ?? '선생님',
|
||||
thumbnail: json['course_thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'common/widgets/upcoming_class_card.dart';
|
||||
import 'common/widgets/course_card.dart';
|
||||
import 'common/data/course.dart'; // Course 클래스 import
|
||||
import 'plan_page.dart'; // PlanPage import
|
||||
import 'common/widgets/now_study_class_card.dart';
|
||||
import 'common/data/upcoming_study.dart';
|
||||
import 'common/data/new_study.dart';
|
||||
|
||||
// 새로운 추천 플랜 모델
|
||||
class RecommendPlan {
|
||||
@@ -69,7 +48,8 @@ class HomePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
late Future<List<CaseStudyPlan>> _caseStudyPlans;
|
||||
late Future<List<UpcomingStudy>> _upcomingStudies;
|
||||
late Future<List<NewStudy>> _newStudies;
|
||||
late Future<List<Course>> _newCoursesFuture; // New: Future for new courses
|
||||
DateTime _currentTime = DateTime.now();
|
||||
String _currentTimeZone = 'Loading timezone...';
|
||||
@@ -94,8 +74,8 @@ class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_caseStudyPlans = _fetchCaseStudyPlans();
|
||||
|
||||
_upcomingStudies = _fetchUpcomingStudies();
|
||||
_newStudies = _fetchNewStudies();
|
||||
_newCoursesFuture = _fetchNewCourses(); // Initialize new courses future
|
||||
_fetchTimezone();
|
||||
_clockStream = Stream.periodic(const Duration(seconds: 1), (_) {
|
||||
@@ -114,7 +94,28 @@ class _HomePageState extends State<HomePage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<List<CaseStudyPlan>> _fetchCaseStudyPlans() async {
|
||||
Future<List<UpcomingStudy>> _fetchUpcomingStudies() async {
|
||||
final response = await http
|
||||
.get(Uri.parse('https://helloworld6-ad2uqhckxq-uc.a.run.app'));
|
||||
if (response.statusCode == 200) {
|
||||
final Map<String, dynamic> decodedJson = json.decode(response.body);
|
||||
if (decodedJson.containsKey('data') && decodedJson['data'] is List) {
|
||||
final List<dynamic> plansJson = decodedJson['data'];
|
||||
return plansJson
|
||||
.map((jsonItem) =>
|
||||
UpcomingStudy.fromJson(jsonItem as Map<String, dynamic>))
|
||||
.toList();
|
||||
} else {
|
||||
throw Exception(
|
||||
'Invalid data format: "data" field is missing or not a list.');
|
||||
}
|
||||
} else {
|
||||
throw Exception(
|
||||
'Failed to load upcoming studies. Status Code: ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<NewStudy>> _fetchNewStudies() async {
|
||||
final response = await http
|
||||
.get(Uri.parse('https://helloworld2-ad2uqhckxq-uc.a.run.app'));
|
||||
if (response.statusCode == 200) {
|
||||
@@ -123,7 +124,7 @@ class _HomePageState extends State<HomePage> {
|
||||
final List<dynamic> plansJson = decodedJson['data'];
|
||||
return plansJson
|
||||
.map((jsonItem) =>
|
||||
CaseStudyPlan.fromJson(jsonItem as Map<String, dynamic>))
|
||||
NewStudy.fromJson(jsonItem as Map<String, dynamic>))
|
||||
.toList();
|
||||
} else {
|
||||
throw Exception(
|
||||
@@ -131,13 +132,13 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
} else {
|
||||
throw Exception(
|
||||
'Failed to load case study plans. Status Code: ${response.statusCode}');
|
||||
'Failed to load new studies. Status Code: ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
// New: Fetch new courses from API
|
||||
Future<List<Course>> _fetchNewCourses() async {
|
||||
final response = await http.get(Uri.parse('https://helloworld5-ad2uqhckxq-uc.a.run.app/'));
|
||||
final response = await http.get(Uri.parse('https://helloworld5-ad2uqhckxq-uc.a.run.app'));
|
||||
if (response.statusCode == 200) {
|
||||
final Map<String, dynamic> decodedJson = json.decode(response.body);
|
||||
if (decodedJson.containsKey('data') && decodedJson['data'] is List) {
|
||||
@@ -148,7 +149,8 @@ class _HomePageState extends State<HomePage> {
|
||||
} else {
|
||||
throw Exception('Invalid data format for new courses: "data" field is missing or not a list.');
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw Exception('Failed to load new courses. Status Code: ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
@@ -338,8 +340,8 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
SizedBox(
|
||||
height: 200, // 가로 리스트의 높이를 줄입니다.
|
||||
child: FutureBuilder<List<CaseStudyPlan>>(
|
||||
future: _caseStudyPlans,
|
||||
child: FutureBuilder<List<UpcomingStudy>>(
|
||||
future: _upcomingStudies,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
@@ -415,43 +417,45 @@ class _HomePageState extends State<HomePage> {
|
||||
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<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: 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);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
FutureBuilder<List<NewStudy>>(
|
||||
future: _newStudies,
|
||||
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 studies: ${snapshot.error}', textAlign: TextAlign.center),
|
||||
));
|
||||
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return const Center(child: Text('No new studies available.'));
|
||||
} else {
|
||||
final plans = snapshot.data!;
|
||||
return GridView.builder(
|
||||
shrinkWrap: true, // Column 안에 GridView를 넣을 때 필요
|
||||
physics: const NeverScrollableScrollPhysics(), // 부모 SingleChildScrollView와 스크롤 충돌 방지
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 8.0),
|
||||
itemCount: plans.length,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2, // 한 줄에 2개씩
|
||||
crossAxisSpacing: 10.0, // 가로 간격
|
||||
mainAxisSpacing: 10.0, // 세로 간격
|
||||
childAspectRatio: 1.0, // 아이템의 가로세로 비율 (조정 필요 시 변경)
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final plan = plans[index];
|
||||
return StudyClassCard(
|
||||
plan: plan,
|
||||
onTap: () {
|
||||
// widget.onNavigateToPlanTab(1);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -568,4 +572,4 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,32 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import 'plan_page_detail.dart'; // <<< plan_page_detail.dart 파일을 import 합니다.
|
||||
|
||||
// HomePage에서 사용하던 CaseStudyPlan 모델을 PlanPage에서도 사용하거나,
|
||||
// PlanPage에 필요한 별도의 데이터 모델을 정의할 수 있습니다.
|
||||
// 여기서는 동일한 모델을 재사용한다고 가정합니다.
|
||||
class CaseStudyPlan {
|
||||
final String planId;
|
||||
final String planTitle;
|
||||
final String planTeacher;
|
||||
final String thumbnail;
|
||||
|
||||
CaseStudyPlan({
|
||||
required this.planId,
|
||||
required this.planTitle,
|
||||
required this.planTeacher,
|
||||
required this.thumbnail,
|
||||
});
|
||||
|
||||
factory CaseStudyPlan.fromJson(Map<String, dynamic> json) {
|
||||
return CaseStudyPlan(
|
||||
planId: json['casestudy lesson id'] ?? '아이디 없음',
|
||||
planTitle: json['course_name'] ?? '제목 없음',
|
||||
planTeacher: json['planTeacher'] ?? '',
|
||||
thumbnail: json['course_thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'common/data/case_study_plan.dart';
|
||||
|
||||
class PlanPage extends StatefulWidget {
|
||||
const PlanPage({super.key});
|
||||
|
||||
@@ -4,36 +4,7 @@ import 'dart:convert';
|
||||
import 'main.dart';
|
||||
import 'youtube_player_page.dart'; // YoutubePlayerPage import
|
||||
import 'common/widgets/custom_bottom_nav_bar.dart';
|
||||
|
||||
// PlanDetailItem 클래스 (이전과 동일)
|
||||
class PlanDetailItem {
|
||||
final String lessonId;
|
||||
final String lessonTag;
|
||||
final String lessonUrl;
|
||||
final String thumbnail;
|
||||
final String lessonName;
|
||||
final String lessonDescription;
|
||||
|
||||
PlanDetailItem({
|
||||
required this.lessonId,
|
||||
required this.lessonTag,
|
||||
required this.lessonUrl,
|
||||
required this.thumbnail,
|
||||
required this.lessonName,
|
||||
required this.lessonDescription,
|
||||
});
|
||||
|
||||
factory PlanDetailItem.fromJson(Map<String, dynamic> json) {
|
||||
return PlanDetailItem(
|
||||
lessonId: json['casestudy lesson id'] ?? 'ID 없음',
|
||||
lessonTag: json['lesson tag'] ?? '태그 없음',
|
||||
lessonUrl: json['lesson url'] ?? 'URL 없음',
|
||||
thumbnail: json['thumbnail'] ?? '',
|
||||
lessonName: json['lesson_name'] ?? '이름 없음',
|
||||
lessonDescription: json['lesson_description'] ?? '설명 없음',
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'common/data/plan_detail_item.dart';
|
||||
|
||||
class PlanPageDetail extends StatefulWidget {
|
||||
const PlanPageDetail({
|
||||
|
||||
Reference in New Issue
Block a user