테마 기능 분리

구글 가변 폰트 추가
업커밍 존 카드 추출
This commit is contained in:
girinb
2025-07-14 21:20:10 +09:00
parent 2e825bbae2
commit 2209ec64e3
7 changed files with 302 additions and 133 deletions

View File

@@ -3,6 +3,7 @@ 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:flutter_native_timezone/flutter_native_timezone.dart'; // 주석 처리된 상태 유지
import '../plan_page.dart'; // PlanPage import
@@ -24,7 +25,7 @@ class CaseStudyPlan {
return CaseStudyPlan(
planId: json['casestudy lesson id'] ?? '아이디 없음',
planTitle: json['course_name'] ?? '제목 없음',
planTeacher: json['planTeacher'] ?? '',
planTeacher: json['planTeacher'] ?? '선생님',
thumbnail: json['course_thumbnail'] ?? '',
);
}
@@ -220,17 +221,20 @@ class _HomePageState extends State<HomePage> {
final String formattedDate = DateFormat.yMMMMd().format(displayTime);
final String formattedTime = DateFormat.jms().format(displayTime);
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
color: Theme.of(context).primaryColor.withAlpha(25),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor.withAlpha(25),
borderRadius: BorderRadius.circular(8.0),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center, // 세로 중앙 정렬
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Your Local Time', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0)),
const SizedBox(height: 6.0),
Text('$formattedDate, $formattedTime', style: const TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500)),
const SizedBox(height: 4.0),
Text('Timezone: $_currentTimeZone', style: TextStyle(fontSize: 13.0, color: Colors.grey[700])),
Text('$formattedTime', style: const TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500)),
// const SizedBox(height: 4.0),
// Text('Timezone: $_currentTimeZone', style: TextStyle(fontSize: 13.0, color: Colors.grey[700])),
],
),
);
@@ -238,59 +242,79 @@ class _HomePageState extends State<HomePage> {
);
}
Widget _buildButtons() {
return Column(
mainAxisAlignment: MainAxisAlignment.center, // 세로 중앙 정렬
crossAxisAlignment: CrossAxisAlignment.stretch, // 버튼이 가로로 꽉 차게 설정
children: [
Expanded( // 버튼이 할당된 세로 공간을 모두 차지하도록 설정
child: ElevatedButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 20),
label: const Text('Book Class', style: TextStyle(fontSize: 20)),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Book Class 버튼 기능 구현 예정')),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue, // 배경색을 파란색으로 설정
foregroundColor: Colors.white, // 글자색을 흰색으로 설정
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
),
// const SizedBox(height: 8.0),
// ElevatedButton.icon(
// icon: const Icon(Icons.schedule, size: 20),
// label: const Text('Schedule', style: TextStyle(fontSize: 14)),
// onPressed: () {
// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(content: Text('Schedule 버튼 기능 구현 예정')),
// );
// },
// style: ElevatedButton.styleFrom(
// padding: const EdgeInsets.symmetric(vertical: 12.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(8.0),
// ),
// ),
// ),
],
);
}
Widget _buildHomeContent() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildLocalTimeBar(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 20),
label: const Text('Book Class', style: TextStyle(fontSize: 14)),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Book Class 버튼 기능 구현 예정')),
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
child: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
flex: 1,
child: _buildLocalTimeBar(),
),
),
const SizedBox(width: 12.0),
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.schedule, size: 20),
label: const Text('Schedule', style: TextStyle(fontSize: 14)),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Schedule 버튼 기능 구현 예정')),
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
const SizedBox(width: 12.0),
Expanded(
flex: 1,
child: _buildButtons(),
),
),
],
],
),
),
),
const Padding(
padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), // vertical을 위아래 다르게 조정
child: Text('Upcoming Classes', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
Expanded(
SizedBox(
height: 250, // 가로 리스트의 높이를 지정합니다.
child: FutureBuilder<List<CaseStudyPlan>>(
future: _caseStudyPlans,
builder: (context, snapshot) {
@@ -306,79 +330,16 @@ class _HomePageState extends State<HomePage> {
} else {
final plans = snapshot.data!;
return ListView.builder(
padding: const EdgeInsets.only(top: 8.0),
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 InkWell(
return UpcomingClassCard(
plan: plan,
onTap: () {
// *** 부모 위젯(MyHomePage)에게 Plan 탭으로 이동하라고 알림 ***
// *** PlanPage가 _widgetOptions 리스트에서 두 번째(인덱스 1)라고 가정 ***
widget.onNavigateToPlanTab(1); // *** 전달받은 콜백 호출 ***
widget.onNavigateToPlanTab(1);
},
child: Card(
margin: const EdgeInsets.symmetric(vertical: 6.0, horizontal: 16.0),
elevation: 2.0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
plan.planTitle,
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
),
const SizedBox(width: 8.0),
Text(
// plan.planTeacher,
"",
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey[600]),
),
],
),
const SizedBox(height: 8.0),
if (plan.thumbnail.isNotEmpty)
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
plan.thumbnail,
height: 150,
width: double.infinity,
fit: BoxFit.cover,
loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Container(
height: 150,
color: Colors.grey[200],
child: Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null
? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
: null,
),
),
);
},
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Container(height: 150, color: Colors.grey[200], child: const Center(child: Icon(Icons.broken_image, color: Colors.grey, size: 50)));
},
),
)
else
Container(height: 150, color: Colors.grey[200], child: const Center(child: Text('No Image', style: TextStyle(color: Colors.grey)))),
],
),
),
),
);
},
);