저장용
This commit is contained in:
14
android/.gitignore
vendored
Normal file
14
android/.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
gradle-wrapper.jar
|
||||
/.gradle
|
||||
/captures/
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
/local.properties
|
||||
GeneratedPluginRegistrant.java
|
||||
.cxx/
|
||||
|
||||
# Remember to never publicly share your keystore.
|
||||
# See https://flutter.dev/to/reference-keystore
|
||||
key.properties
|
||||
**/*.keystore
|
||||
**/*.jks
|
||||
44
android/app/build.gradle.kts
Normal file
44
android/app/build.gradle.kts
Normal file
@@ -0,0 +1,44 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.example.csp2"
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = "27.0.12077973"// flutter.ndkVersion
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_17.toString()
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId = "com.example.csp2"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
minSdk = flutter.minSdkVersion
|
||||
targetSdk = flutter.targetSdkVersion
|
||||
versionCode = flutter.versionCode
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
7
android/app/src/debug/AndroidManifest.xml
Normal file
7
android/app/src/debug/AndroidManifest.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
45
android/app/src/main/AndroidManifest.xml
Normal file
45
android/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application
|
||||
android:label="csp2"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
the Android process has started. This theme is visible to the user
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
to determine the Window background behind the Flutter UI. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
|
||||
|
||||
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.csp2
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
12
android/app/src/main/res/drawable-v21/launch_background.xml
Normal file
12
android/app/src/main/res/drawable-v21/launch_background.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="?android:colorBackground" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
12
android/app/src/main/res/drawable/launch_background.xml
Normal file
12
android/app/src/main/res/drawable/launch_background.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
||||
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 544 B |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 442 B |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 721 B |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
18
android/app/src/main/res/values-night/styles.xml
Normal file
18
android/app/src/main/res/values-night/styles.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">?android:colorBackground</item>
|
||||
</style>
|
||||
</resources>
|
||||
18
android/app/src/main/res/values/styles.xml
Normal file
18
android/app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<item name="android:windowBackground">?android:colorBackground</item>
|
||||
</style>
|
||||
</resources>
|
||||
7
android/app/src/profile/AndroidManifest.xml
Normal file
7
android/app/src/profile/AndroidManifest.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
||||
21
android/build.gradle.kts
Normal file
21
android/build.gradle.kts
Normal file
@@ -0,0 +1,21 @@
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
|
||||
rootProject.layout.buildDirectory.value(newBuildDir)
|
||||
|
||||
subprojects {
|
||||
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
|
||||
project.layout.buildDirectory.value(newSubprojectBuildDir)
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(":app")
|
||||
}
|
||||
|
||||
tasks.register<Delete>("clean") {
|
||||
delete(rootProject.layout.buildDirectory)
|
||||
}
|
||||
663
android/build/reports/problems/problems-report.html
Normal file
663
android/build/reports/problems/problems-report.html
Normal file
File diff suppressed because one or more lines are too long
3
android/gradle.properties
Normal file
3
android/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
5
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
|
||||
589
android/new.dart
Normal file
589
android/new.dart
Normal file
@@ -0,0 +1,589 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import 'dart:async'; // Timer를 사용하기 위해 추가
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
// import 'package:flutter_native_timezone/flutter_native_timezone.dart'; // 주석 처리된 상태 유지
|
||||
// import '../plan_page.dart'; // HomePage는 이제 PlanPage를 직접 포함하지 않음
|
||||
|
||||
// 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['planId'] ?? '아이디 없음',
|
||||
planTitle: json['planTitle'] ?? '제목 없음',
|
||||
planTeacher: json['planTeacher'] ?? '선생님 정보 없음',
|
||||
thumbnail: json['thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 새로운 추천 플랜 모델 (변경 없음)
|
||||
class RecommendPlan {
|
||||
final String planId;
|
||||
final String planName;
|
||||
final String thumbnail;
|
||||
|
||||
RecommendPlan({
|
||||
required this.planId,
|
||||
required this.planName,
|
||||
required this.thumbnail,
|
||||
});
|
||||
|
||||
factory RecommendPlan.fromJson(Map<String, dynamic> json) {
|
||||
return RecommendPlan(
|
||||
planId: json['plan id'] ?? 'ID 없음',
|
||||
planName: json['plane name'] ?? '이름 없음',
|
||||
thumbnail: json['thumbnail'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// *** 추가: 콜백 함수의 타입을 정의 ***
|
||||
typedef OnNavigateToPage = void Function(int pageIndex);
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
// *** 추가: 콜백 함수를 받을 프로퍼티 ***
|
||||
final OnNavigateToPage onNavigateToPlanTab;
|
||||
|
||||
const HomePage({
|
||||
super.key,
|
||||
required this.onNavigateToPlanTab, // *** 생성자에서 콜백 함수를 받도록 수정 ***
|
||||
});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
late Future<List<CaseStudyPlan>> _caseStudyPlans;
|
||||
DateTime _currentTime = DateTime.now();
|
||||
String _currentTimeZone = 'Loading timezone...';
|
||||
late Stream<DateTime> _clockStream;
|
||||
|
||||
// int _selectedIndex = 0; // *** HomePage 자체에서 선택된 인덱스를 관리할 필요가 없어짐 ***
|
||||
|
||||
// --- 추천 클래스 관련 상태 변수 ---
|
||||
List<RecommendPlan> _recommendPlans = [];
|
||||
int _currentRecommendIndex = 0;
|
||||
Timer? _recommendTimer;
|
||||
bool _isLoadingRecommends = true;
|
||||
bool _hasRecommendError = false;
|
||||
String _recommendErrorText = '';
|
||||
|
||||
// --- 추천 클래스 관련 상태 변수 끝 ---
|
||||
|
||||
// *** _buildPageContents() 메소드는 HomePage에서 더 이상 사용되지 않음 ***
|
||||
// List<Widget> _buildPageContents() {
|
||||
// return [
|
||||
// _buildHomeContent(context), // context 전달 필요
|
||||
// // const PlanPage(), // HomePage가 PlanPage를 직접 포함하지 않음
|
||||
// ];
|
||||
// }
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_caseStudyPlans = _fetchCaseStudyPlans();
|
||||
_fetchTimezone();
|
||||
_clockStream = Stream.periodic(const Duration(seconds: 1), (_) {
|
||||
return DateTime.now();
|
||||
});
|
||||
_currentTime = DateTime.now();
|
||||
_fetchRecommendPlans(); // 추천 클래스 데이터 로드
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_recommendTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<List<CaseStudyPlan>> _fetchCaseStudyPlans() async {
|
||||
final response = await http
|
||||
.get(Uri.parse('https://helloworld2-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) =>
|
||||
CaseStudyPlan.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 case study plans. Status Code: ${response
|
||||
.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _fetchTimezone() async {
|
||||
try {
|
||||
final String timeZone = DateTime
|
||||
.now()
|
||||
.timeZoneName;
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentTimeZone = timeZone;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentTimeZone = 'Failed to get timezone.';
|
||||
});
|
||||
}
|
||||
print('Could not get timezone: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _fetchRecommendPlans() async {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_isLoadingRecommends = true;
|
||||
_hasRecommendError = false;
|
||||
_recommendErrorText = '';
|
||||
});
|
||||
try {
|
||||
final response = await http
|
||||
.get(Uri.parse('https://helloworld3-ad2uqhckxq-uc.a.run.app'));
|
||||
if (!mounted) return;
|
||||
|
||||
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'];
|
||||
setState(() {
|
||||
_recommendPlans = plansJson
|
||||
.map((jsonItem) =>
|
||||
RecommendPlan.fromJson(jsonItem as Map<String, dynamic>))
|
||||
.toList();
|
||||
_isLoadingRecommends = false;
|
||||
if (_recommendPlans.isNotEmpty) {
|
||||
_currentRecommendIndex = 0;
|
||||
_startRecommendTimer();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw Exception(
|
||||
'Invalid data format for recommend plans: "data" field is missing or not a list.');
|
||||
}
|
||||
} else {
|
||||
throw Exception(
|
||||
'Failed to load recommend plans. Status Code: ${response
|
||||
.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching recommend plans: $e');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoadingRecommends = false;
|
||||
_hasRecommendError = true;
|
||||
_recommendErrorText = e.toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _startRecommendTimer() {
|
||||
_recommendTimer?.cancel();
|
||||
if (_recommendPlans.isEmpty || !mounted) return;
|
||||
|
||||
_recommendTimer = Timer.periodic(const Duration(seconds: 10), (timer) {
|
||||
if (!mounted || _recommendPlans.isEmpty) {
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_currentRecommendIndex =
|
||||
(_currentRecommendIndex + 1) % _recommendPlans.length;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildLocalTimeBar() {
|
||||
return StreamBuilder<DateTime>(
|
||||
stream: _clockStream,
|
||||
initialData: _currentTime,
|
||||
builder: (context, snapshot) {
|
||||
final DateTime displayTime = snapshot.data ?? DateTime.now();
|
||||
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
|
||||
.withOpacity(0.1),
|
||||
child: Column(
|
||||
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])),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRecommendSection() {
|
||||
if (_isLoadingRecommends) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
if (_hasRecommendError) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20.0, horizontal: 16.0),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.red, size: 40),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Failed to load recommendations.\n$_recommendErrorText',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: Colors.redAccent),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
onPressed: _fetchRecommendPlans,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (_recommendPlans.isEmpty) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0),
|
||||
child: Center(
|
||||
child: Text('No recommendations available at the moment.')),
|
||||
);
|
||||
}
|
||||
|
||||
final currentPlan = _recommendPlans[_currentRecommendIndex];
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 16.0),
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme
|
||||
.of(context)
|
||||
.cardColor,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'✨ Recommend Classes',
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.titleLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 12.0),
|
||||
AspectRatio(
|
||||
aspectRatio: 16 / 9,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
child: currentPlan.thumbnail.isNotEmpty
|
||||
? Image.network(
|
||||
currentPlan.thumbnail,
|
||||
fit: BoxFit.cover,
|
||||
loadingBuilder: (BuildContext context, Widget child,
|
||||
ImageChunkEvent? loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Container(
|
||||
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(
|
||||
color: Colors.grey[200],
|
||||
child: const Center(child: Icon(
|
||||
Icons.broken_image, color: Colors.grey, size: 50)),
|
||||
);
|
||||
},
|
||||
)
|
||||
: Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Center(child: Text('No Image Available',
|
||||
style: TextStyle(color: Colors.grey))),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
Text(
|
||||
currentPlan.planName,
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.w500),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHomeContent(BuildContext context) {
|
||||
// *** BuildContext를 받도록 수정 ***
|
||||
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( // *** context 사용 ***
|
||||
const SnackBar(content: Text('Book Class 버튼 기능 구현 예정')),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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( // *** context 사용 ***
|
||||
const SnackBar(content: Text('Schedule 버튼 기능 구현 예정')),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
|
||||
child: Text('Upcoming Classes',
|
||||
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
Expanded(
|
||||
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(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
itemCount: plans.length,
|
||||
itemBuilder: (context, index) {
|
||||
final plan = plans[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
// *** 부모 위젯(MyHomePage)에게 Plan 탭으로 이동하라고 알림 ***
|
||||
// *** PlanPage가 _widgetOptions 리스트에서 두 번째(인덱스 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)))),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildRecommendSection(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// *** _onItemTapped 메소드는 HomePage에서 더 이상 사용되지 않음 (상위 위젯에서 관리) ***
|
||||
// void _onItemTapped(int index) {
|
||||
// setState(() {
|
||||
// _selectedIndex = index;
|
||||
// if (index == 0 && _recommendPlans.isNotEmpty && (_recommendTimer == null || !_recommendTimer!.isActive)) {
|
||||
// _startRecommendTimer();
|
||||
// } else if (index != 0) {
|
||||
// _recommendTimer?.cancel();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// *** HomePage는 이제 Scaffold나 BottomNavigationBar를 직접 빌드하지 않음 ***
|
||||
// *** _buildHomeContent가 context를 사용하므로 전달 ***
|
||||
return _buildHomeContent(context);
|
||||
}
|
||||
}
|
||||
25
android/settings.gradle.kts
Normal file
25
android/settings.gradle.kts
Normal file
@@ -0,0 +1,25 @@
|
||||
pluginManagement {
|
||||
val flutterSdkPath = run {
|
||||
val properties = java.util.Properties()
|
||||
file("local.properties").inputStream().use { properties.load(it) }
|
||||
val flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
|
||||
flutterSdkPath
|
||||
}
|
||||
|
||||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||
id("com.android.application") version "8.7.3" apply false
|
||||
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
|
||||
}
|
||||
|
||||
include(":app")
|
||||
Reference in New Issue
Block a user