From 199e7e1b3ac717417efbe2da18dcca35bf3fed99 Mon Sep 17 00:00:00 2001 From: lhaerim Date: Sat, 21 Dec 2024 17:14:20 +0900 Subject: [PATCH 1/3] Update pubspec.lock --- outfoot/pubspec.lock | 56 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/outfoot/pubspec.lock b/outfoot/pubspec.lock index 81bd194..4af6736 100644 --- a/outfoot/pubspec.lock +++ b/outfoot/pubspec.lock @@ -248,6 +248,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.1+1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -260,26 +284,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.0" mime: dependency: transitive description: @@ -292,10 +316,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_drawing: dependency: "direct main" description: @@ -377,10 +401,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" typed_data: dependency: transitive description: @@ -397,6 +421,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" + source: hosted + version: "14.2.1" web: dependency: transitive description: @@ -414,5 +446,5 @@ packages: source: hosted version: "6.5.0" sdks: - dart: ">=3.2.3 <4.0.0" - flutter: ">=3.16.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" From c063d8b2b4cfd2fe01b1dc28fc3cb30dc4f47d5c Mon Sep 17 00:00:00 2001 From: lhaerim Date: Sun, 22 Dec 2024 02:57:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20api=20=EC=97=B0=EB=8F=99=20#54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- outfoot/lib/api/profile_edit_api.dart | 44 +++++++++++++++++++ outfoot/lib/models/profile_edit_model.dart | 44 +++++++++++++++++++ outfoot/lib/screens/edit_profile_page.dart | 49 +++++++++++++++++++++- 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 outfoot/lib/api/profile_edit_api.dart create mode 100644 outfoot/lib/models/profile_edit_model.dart diff --git a/outfoot/lib/api/profile_edit_api.dart b/outfoot/lib/api/profile_edit_api.dart new file mode 100644 index 0000000..f55e670 --- /dev/null +++ b/outfoot/lib/api/profile_edit_api.dart @@ -0,0 +1,44 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:outfoot/models/profile_edit_model.dart'; + +class ProfileEditApi { + final Dio _dio = Dio(); + + /// 프로필 수정 API 요청 + Future updateProfile({ + required String nickname, + required String myIntro, + required String email, + required String token, + }) async { + final String? baseUrl = dotenv.env['BASE_URL']; + + try { + print("Request URL: $baseUrl/my"); + + final response = await _dio.put( + '$baseUrl/my', + data: { + 'nickname': nickname, + 'myIntro': myIntro, + 'email': email, + }, + options: Options( + headers: { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }, + ), + ); + + if (response.statusCode == 200) { + return ProfileEditResponse.fromJson(response.data); + } else { + throw Exception('프로필 수정 실패: ${response.data}'); + } + } catch (e) { + throw Exception('오류 발생: $e'); + } + } +} diff --git a/outfoot/lib/models/profile_edit_model.dart b/outfoot/lib/models/profile_edit_model.dart new file mode 100644 index 0000000..55e7a25 --- /dev/null +++ b/outfoot/lib/models/profile_edit_model.dart @@ -0,0 +1,44 @@ +class ProfileEditResponse { + final bool success; + final ProfileData? response; + final String? message; + + ProfileEditResponse({ + required this.success, + this.response, + this.message, + }); + + factory ProfileEditResponse.fromJson(Map json) { + return ProfileEditResponse( + success: json['success'] ?? false, + response: json['response'] != null + ? ProfileData.fromJson(json['response']) + : null, + message: json['message'], + ); + } +} + +class ProfileData { + final String nickname; + final String myIntro; + final String email; + final String? imageUrl; + + ProfileData({ + required this.nickname, + required this.myIntro, + required this.email, + this.imageUrl, + }); + + factory ProfileData.fromJson(Map json) { + return ProfileData( + nickname: json['nickname'], + myIntro: json['myIntro'], + email: json['email'], + imageUrl: json['imageUrl'], + ); + } +} diff --git a/outfoot/lib/screens/edit_profile_page.dart b/outfoot/lib/screens/edit_profile_page.dart index 41a4152..590c4d3 100644 --- a/outfoot/lib/screens/edit_profile_page.dart +++ b/outfoot/lib/screens/edit_profile_page.dart @@ -2,10 +2,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:outfoot/colors/colors.dart'; import 'package:outfoot/widgets/dashed_line_painter.dart'; +import 'package:outfoot/api/profile_edit_api.dart'; +import 'package:outfoot/models/profile_edit_model.dart'; -class EditProfile extends StatelessWidget { +class EditProfile extends StatefulWidget { const EditProfile({super.key}); + @override + _EditProfileState createState() => _EditProfileState(); +} + +class _EditProfileState extends State { + final ProfileEditApi _profileEditApi = ProfileEditApi(); + final TextEditingController _nicknameController = TextEditingController(); + final TextEditingController _introController = TextEditingController(); + final TextEditingController _emailController = TextEditingController(); + bool _isLoading = false; + TextStyle _textStyle(double fontSize, FontWeight fontWeight, Color color, double letterSpacing) { return TextStyle( @@ -37,6 +50,40 @@ class EditProfile extends StatelessWidget { ); } + Future _updateProfile() async { + + setState(() { + _isLoading = true; + }); + + try { + final response = await _profileEditApi.updateProfile( + nickname: _nicknameController.text, + myIntro: _introController.text, + email: _emailController.text, + token: 'user-access-token', + ); + + if (response.success) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('프로필이 성공적으로 수정되었습니다!')), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('수정 실패: ${response.message}')), + ); + } + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('오류 발생: $e')), + ); + } finally { + setState(() { + _isLoading = false; + }); + } + } + @override Widget build(BuildContext context) { return Scaffold( From b3a095fcc2ab54c1e546f6836cd6285d43c7c652 Mon Sep 17 00:00:00 2001 From: lhaerim Date: Sun, 22 Dec 2024 03:06:05 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Fix:=20=EC=8A=A4=ED=81=AC=EB=A6=B0=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99=20=EB=B2=84=ED=8A=BC=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?#54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- outfoot/lib/screens/edit_profile_page.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/outfoot/lib/screens/edit_profile_page.dart b/outfoot/lib/screens/edit_profile_page.dart index 590c4d3..2e07a30 100644 --- a/outfoot/lib/screens/edit_profile_page.dart +++ b/outfoot/lib/screens/edit_profile_page.dart @@ -278,14 +278,18 @@ class _EditProfileState extends State { height: 45.994, decoration: _boxDecoration(mainBrownColor), child: Center( - child: Text( - '변경하기', - textAlign: TextAlign.center, - style: _textStyle( - 14.0, FontWeight.w600, lightMainColor, -0.28), - ), + child: TextButton( + onPressed: _isLoading ? null : _updateProfile, // 로딩 중 버튼 비활성화 + child: _isLoading + ? CircularProgressIndicator(color: Colors.white) // 로딩 표시 추가 + : Text( + '변경하기', + textAlign: TextAlign.center, + style: _textStyle(14.0, FontWeight.w600, lightMainColor, -0.28), + ), ), ), + ), ], ), ),