Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added babymeal/assets/images/allergy_bean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_beef.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_buckwheat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_chicken.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_crab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_egg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_mackerel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_milk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_peach.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_peanut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_pinenut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_pork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_seaweed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_shrimp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_squid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_sulfurous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_tomato.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_walnut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/allergy_wheat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/level2_none.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added babymeal/assets/images/progress2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions babymeal/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions babymeal/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions babymeal/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
25 changes: 25 additions & 0 deletions babymeal/lib/model/CustomerModel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Customer {
final String customerName;
final String rank;
final int myLikes;
final int myComments;
final int myPosts;

Customer({
required this.customerName,
required this.rank,
required this.myLikes,
required this.myComments,
required this.myPosts,
});

factory Customer.fromJson(Map<String, dynamic> json) {
return Customer(
customerName: json['customerName'],
rank: json['rank'],
myLikes: json['myLikes'],
myComments: json['myComments'],
myPosts: json['myPosts'],
);
}
}
41 changes: 41 additions & 0 deletions babymeal/lib/model/FridgeRecipe.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class FridgeRecipe {
int? simpleDietId;
String? dietName;
int? time;
String? difficulty;
bool? heart;

FridgeRecipe({
this.simpleDietId,
this.dietName,
this.time,
this.difficulty,
this.heart,
});

factory FridgeRecipe.fromJson(Map<String, dynamic> json) {
return FridgeRecipe(
simpleDietId: json['simpleDietId'],
dietName: json['dietName'],
time: json['time'],
difficulty: json['difficulty'],
heart: json['heart'],
);
}

Map<String, dynamic> toJson() {
return {
'simpleDietId': simpleDietId,
'dietName': dietName,
'time': time,
'difficulty': difficulty,
'heart': heart,
};
}

@override
String toString() {
return 'FridgeRecipe(simpleDietId: $simpleDietId, dietName: $dietName, time: $time, difficulty: $difficulty, heart: $heart)';
}

}
48 changes: 48 additions & 0 deletions babymeal/lib/model/RecipeDetailModel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class RecipeDetail {
String? dietName;
String? description;
String? ingredients;
String? recipe;
int? time;
String? difficulty;
bool? heart;

RecipeDetail({
this.dietName,
this.description,
this.ingredients,
this.recipe,
this.time,
this.difficulty,
this.heart
});

factory RecipeDetail.fromJson(Map<String, dynamic> json) {
return RecipeDetail(
dietName: json['dietName'],
description: json['description'],
ingredients: json['ingredients'],
recipe: json['recipe'],
time: json['time'],
difficulty: json['difficulty'],
heart: json['heart']
);
}

Map<String, dynamic> toJson() {
return {
'dietName': dietName,
'description': description,
'ingredients': ingredients,
'recipe': recipe,
'time': time,
'difficulty': difficulty,
'heart': heart
};
}

@override
String toString() {
return 'RecipeDetail(dietName: $dietName, description: $description, ingredients: $ingredients, time: $time, difficulty: $difficulty, recipe: $recipe)';
}
}
44 changes: 44 additions & 0 deletions babymeal/lib/model/RecipeModel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class GetRecipe {
int? simpleDietId;
String? dietName;
String? description;
int? time;
String? difficulty;
bool? heart;

GetRecipe({
this.simpleDietId,
this.dietName,
this.description,
this.time,
this.difficulty,
this.heart,
});

factory GetRecipe.fromJson(Map<String, dynamic> json) {
return GetRecipe(
simpleDietId: json['simpleDietId'],
dietName: json['dietName'],
description: json['description'],
time: json['time'],
difficulty: json['difficulty'],
heart: json['heart'],
);
}

Map<String, dynamic> toJson() {
return {
'simpleDietId': simpleDietId,
'dietName': dietName,
'description': description,
'time': time,
'difficulty': difficulty,
'heart': heart,
};
}

@override
String toString() {
return 'GetRecipe(simpleDietId: $simpleDietId, dietName: $dietName, description: $description, time: $time, difficulty: $difficulty, heart: $heart)';
}
}
133 changes: 129 additions & 4 deletions babymeal/lib/pages/mypage/ChangeChildAllergy.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'package:babymeal/pages/mypage/ViewChildInfoPage.dart';
import 'package:babymeal/pages/mypage/ViewMyPage.dart';
import 'package:babymeal/services/MyPageService.dart';
import 'package:flutter/material.dart';

import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
class ChangeChildAllergyPageWidget extends StatefulWidget {
const ChangeChildAllergyPageWidget({Key? key}) : super(key: key);

Expand Down Expand Up @@ -32,6 +37,29 @@ class _ChangeChildAllergyPageWidgetState
"조개류",
"잣"
];

List<String> imageList = [
'assets/images/allergy_egg.png',
'assets/images/allergy_milk.png',
'assets/images/allergy_buckwheat.png',
'assets/images/allergy_peanut.png',
'assets/images/allergy_bean.png',
'assets/images/allergy_wheat.png',
'assets/images/allergy_mackerel.png',
'assets/images/allergy_crab.png',
'assets/images/allergy_shrimp.png',
'assets/images/allergy_pork.png',
'assets/images/allergy_peach.png',
'assets/images/allergy_tomato.png',
'assets/images/allergy_sulfurous.png',
'assets/images/allergy_pinenut.png',
'assets/images/allergy_chicken.png',
'assets/images/allergy_beef.png',
'assets/images/allergy_squid.png',
'assets/images/allergy_seaweed.png',
'assets/images/allergy_pork.png',
];

List<bool> isSelected = List.generate(19, (index) => false);
@override
void initState() {
Expand All @@ -43,6 +71,71 @@ class _ChangeChildAllergyPageWidgetState
super.dispose();
}


Future<void> updateBabyData(String newAllergy) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? userToken = prefs.getString('accessToken');

MyPageService myPageService = MyPageService();
String babyId = await myPageService.getBabyId(userToken!);

final currentData = await myPageService.fetchCurrentBabyData(babyId);

if (currentData == null) {
print('Failed to fetch current data');
return;
}

// 변경하고자 하는 필드만 새로운 값으로 업데이트합니다.
currentData['data'][0]['allergy'] = newAllergy;
print('newBabyName: $newAllergy');
print('Current data: $currentData');

final babyData = currentData['data'][0];
babyData['babyId'] = babyId;

print('babyData: $babyData');



if (userToken == null) {
print('No token found');
return;
}

final response = await http.put(
Uri.parse('http://ec2-43-200-210-159.ap-northeast-2.compute.amazonaws.com:8080/customer/baby'),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $userToken',
},
body: jsonEncode(babyData), // 변경된 전체 데이터를 서버에 보냅니다.

);

if (response.statusCode == 200) {
print('Baby data updated successfully');
} else {
print('Failed to update baby data');
}
}

Future<void> navigateFromChangeChildAllergyPage() async {
final result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) => ViewChildInfoPageWidget()),
);

if (result == true) {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final String? userToken = prefs.getString('accessToken');
MyPageService myPageService = MyPageService();
String babyId = await myPageService.getBabyId(userToken!);
myPageService.fetchCurrentBabyData(babyId);

}
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -52,9 +145,23 @@ class _ChangeChildAllergyPageWidgetState
height: 55,
child: FloatingActionButton.extended(
elevation: 0,
backgroundColor: Color(
0xFFFF5C39), //////////////////////////////////////////////////////
onPressed: () {},
backgroundColor: Color(0xFFFF5C39),
onPressed: () async{
List<String> selectedAllergies = [];
for (int i = 0; i < isSelected.length; i++) {
if (isSelected[i]) {
selectedAllergies.add(allergyList[i]);
}
}
String newAllergies = selectedAllergies.join(', ');
await updateBabyData(newAllergies);
await navigateFromChangeChildAllergyPage();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ViewMyPageWidget()));
},
label: Container(
width: MediaQuery.of(context).size.width * 0.88,
child: Row(
Expand Down Expand Up @@ -158,6 +265,24 @@ class _ChangeChildAllergyPageWidgetState
borderRadius: BorderRadius.circular(12),
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Stack(
children: [
Image.asset(
imageList[index],
fit: BoxFit.cover,
),
if (isSelected[index]) // isSelected가 true일 때만 오버레이 표시
Container(
decoration: BoxDecoration(
color: Color(0xFFFF582C).withOpacity(0.2), // 투명한 주황색
borderRadius: BorderRadius.circular(12),
),
),
],
),
),
),
Text(
allergyList[index],
Expand Down
Loading