From 00f11a423a910746b3638ab2ebd220b562e95825 Mon Sep 17 00:00:00 2001 From: Nam Jin Date: Mon, 11 Dec 2023 21:15:07 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:safety=5Fvest:=20Feat=20:=20RootPage=20?= =?UTF-8?q?=EB=92=A4=EB=A1=9C=EA=B0=80=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat : RootPage 뒤로가기 버튼 삭제 --- lib/root_page.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/root_page.dart b/lib/root_page.dart index a0486d0..36a1dd1 100644 --- a/lib/root_page.dart +++ b/lib/root_page.dart @@ -171,6 +171,7 @@ class _RootPageState extends State { preferredSize: const Size.fromHeight(40.0), child: AppBar( backgroundColor: AppColor.backgroudColor, + automaticallyImplyLeading: false, ), ), backgroundColor: AppColor.backgroudColor, From 1a524ae7b9f0c331dcdf1c455452bea3b2ad1450 Mon Sep 17 00:00:00 2001 From: Nam Jin Date: Mon, 11 Dec 2023 21:16:39 +0900 Subject: [PATCH 2/4] =?UTF-8?q?:recycle:=20Refactor=20:=20ChatPage=20?= =?UTF-8?q?=EC=9A=B0=EC=B8=A1=20=EC=83=81=EB=8B=A8=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor : ChatPage 우측 상단 버튼 삭제 --- lib/pages/chat_page.dart | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/pages/chat_page.dart b/lib/pages/chat_page.dart index 8eb9226..2ff6abc 100644 --- a/lib/pages/chat_page.dart +++ b/lib/pages/chat_page.dart @@ -125,19 +125,6 @@ class _ChatPageState extends State { ), ], ), - Row( - children: [ - IconButton( - onPressed: () {}, - icon: const Icon(Icons.more_horiz), - color: AppColor.swatchColor, - iconSize: 35, - ), - const SizedBox( - width: 20, - ), - ], - ) ], ), Expanded( From 00ec952e9747cf4066e9d0d04008e7a2f89bb624 Mon Sep 17 00:00:00 2001 From: Nam Jin Date: Mon, 11 Dec 2023 22:01:47 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:recycle:=20Refactor=20:=20AlarmPage=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=AA=85=EB=8F=84=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor : AlarmPage 이미지 명도 처리 --- lib/pages/alarm_page.dart | 70 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/lib/pages/alarm_page.dart b/lib/pages/alarm_page.dart index 0b8848d..a7fc4f1 100644 --- a/lib/pages/alarm_page.dart +++ b/lib/pages/alarm_page.dart @@ -24,14 +24,11 @@ class _AlarmPageState extends State with TickerProviderStateMixin { late Future _familyMember; int familyMemberId = 0; - @override void initState() { super.initState(); } - - @override Widget build(BuildContext context) { familyMemberId = context.watch().familyMemberId; @@ -110,61 +107,79 @@ class _AlarmPageState extends State with TickerProviderStateMixin { children: [ Container( child: FutureBuilder>( - future: FamilyInteractionApiService.getFamilyInteraction(familyMemberId), // Replace with your actual data-fetching method + future: FamilyInteractionApiService.getFamilyInteraction( + familyMemberId), // Replace with your actual data-fetching method builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { // While data is being fetched, show a loading indicator return CircularProgressIndicator(); } else if (snapshot.hasError) { // If there's an error, display an error message return Text('Error: ${snapshot.error}'); - } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + } else if (!snapshot.hasData || + snapshot.data!.isEmpty) { // If no data is available, display a message indicating no interactions return Container( height: 450, - child: Center(child: Text('No reactions yet.'))); + child: + Center(child: Text('No reactions yet.'))); } else { // Data has been successfully fetched, display the interactions - List interactions = snapshot.data!; + List interactions = + snapshot.data!; return ListView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemCount: interactions.length, itemBuilder: (BuildContext context, int index) { - final item = interactions[interactions.length - 1 - index]; + final item = interactions[ + interactions.length - 1 - index]; bool isChecked = item.isChecked == 0; return Container( height: 60, - color: isChecked ? Colors.white : Colors.grey[200], + color: isChecked + ? Colors.white + : Colors.grey[200], child: Row( children: [ SizedBox(width: 10), - CircleAvatar( - radius: 20, - child: ClipOval( - child: Center( - child: Image.asset( - getRoleImage(item.srcMemberRole), - fit: BoxFit.fill, - width: 40, // 원하는 너비로 조절 - height: 40, // 원하는 높이로 조절 + Opacity( + opacity: isChecked ? 1.0 : 0.3, + child: CircleAvatar( + radius: 20, + child: ClipOval( + child: Center( + child: Image.asset( + getRoleImage( + item.srcMemberRole), + fit: BoxFit.fill, + width: 40, // 원하는 너비로 조절 + height: 40, // 원하는 높이로 조절 + ), ), ), ), ), SizedBox(width: 10), - CircleAvatar( - radius: 12, - child: ClipOval( - child: getImageForInteractionType(item.interactionType), + Opacity( + opacity: isChecked ? 1.0 : 0.3, + child: CircleAvatar( + radius: 12, + child: ClipOval( + child: getImageForInteractionType( + item.interactionType), + ), ), ), - SizedBox(width: 10), + SizedBox(width: 10), Text( "${item.srcMemberNickname} ${getInteractionTypeText(item.interactionType)}", style: TextStyle( - color: item.isChecked == 0 ? Colors.black : Colors.grey[400], + color: item.isChecked == 0 + ? Colors.black + : Colors.grey[400], fontWeight: FontWeight.bold, fontSize: 16, ), @@ -178,7 +193,6 @@ class _AlarmPageState extends State with TickerProviderStateMixin { }, ), ) - ], ), ), @@ -195,7 +209,8 @@ class _AlarmPageState extends State with TickerProviderStateMixin { ElevatedButton( onPressed: () async { try { - FamilyInteractionApiService.deleteFamilyInteraction(familyMemberId); + FamilyInteractionApiService.deleteFamilyInteraction( + familyMemberId); Navigator.pop(context); } catch (e) { print(e.toString()); @@ -225,6 +240,7 @@ class _AlarmPageState extends State with TickerProviderStateMixin { ), ); } + String getInteractionTypeText(int interactionType) { switch (interactionType) { case 4: From 9442b70b556de7159551d2db8cb0527beed81480 Mon Sep 17 00:00:00 2001 From: Nam Jin Date: Mon, 11 Dec 2023 23:03:53 +0900 Subject: [PATCH 4/4] =?UTF-8?q?:recycle:=20Refactor=20:=20=EB=82=B4=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20(#98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor : 내 정보 수정 (#98) --- lib/pages/home_page.dart | 3 + lib/pages/setting_page.dart | 762 ++++++++++++++++------------- lib/services/user_api_service.dart | 2 +- 3 files changed, 432 insertions(+), 335 deletions(-) diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 14a9547..d6de708 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -58,6 +58,9 @@ class _HomePageState extends State { void initState() { super.initState(); _initData().then((_) {}); + setState(() { + context.read().nickname; + }); } Future _initData() async { diff --git a/lib/pages/setting_page.dart b/lib/pages/setting_page.dart index 46c787d..e9a981d 100644 --- a/lib/pages/setting_page.dart +++ b/lib/pages/setting_page.dart @@ -17,6 +17,7 @@ import '../models/family_member_model.dart'; import '../models/family_model.dart'; import '../models/family_model.dart'; import '../models/family_model.dart'; +import '../services/user_api_service.dart'; class SettingPage extends StatefulWidget { const SettingPage({Key? key}) : super(key: key); @@ -25,50 +26,61 @@ class SettingPage extends StatefulWidget { State createState() => _SettingPageState(); } -class _SettingPageState extends State with TickerProviderStateMixin { - final _familyNameController = TextEditingController(); - late Future> _familyInfo; - int familyId = 0, familyMemberId = 0; - - - String buttonText = 'Go Out'; - String buttonText2 = 'Edit'; +class _SettingPageState extends State + with TickerProviderStateMixin { + final TextEditingController _userNameController = TextEditingController(); + final TextEditingController _nickNameController = TextEditingController(); + final TextEditingController _ageController = TextEditingController(); + int familyId = 0, familyMemberId = 0; - String username = ''; - String nickname = ''; - String password = ''; int age = -1; int gender = -1; bool isEditMode = false; // Track the edit mode int familyMemberID = 0; - final _formKey = GlobalKey(); + final _formKey1 = GlobalKey(); + final _formKey2 = GlobalKey(); + final _formKey3 = GlobalKey(); @override void initState() { super.initState(); - _initData(); + _initData().then((_) {}); } Future _initData() async { - familyId = context.watch().familyId; - familyMemberId = context.watch().familyMemberId; - print('familyId: $familyId'); - print('familyMemberId: $familyMemberId'); - + _userNameController.text = context.read().name; + _nickNameController.text = context.read().nickname; + _ageController.text = context.read().age.toString(); } - String? _selectedGender; final List _genders = ['Male', 'Female']; + @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( - preferredSize: const Size.fromHeight(40.0), + preferredSize: const Size.fromHeight(50.0), child: AppBar( + leading: SizedBox( + width: 40.0, + height: 40.0, + child: Container( + margin: const EdgeInsets.only(left: 16.0, top: 8), + child: IconButton( + icon: Icon( + Icons.arrow_back_ios_new, + color: AppColor.swatchColor, + ), + onPressed: () { + Navigator.pop(context); + }, + ), + ), + ), backgroundColor: AppColor.backgroudColor, ), ), @@ -82,11 +94,17 @@ class _SettingPageState extends State with TickerProviderStateMixin children: [ Text( "My Room", - style: TextStyle(color: AppColor.textColor, fontSize: 40, fontWeight: FontWeight.bold), + style: TextStyle( + color: AppColor.textColor, + fontSize: 40, + fontWeight: FontWeight.bold), ), Text( "Tell Me Who You Are !", - style: TextStyle(color: AppColor.textColor, fontSize: 20, fontWeight: FontWeight.bold), + style: TextStyle( + color: AppColor.textColor, + fontSize: 20, + fontWeight: FontWeight.bold), ) ], ), @@ -115,231 +133,243 @@ class _SettingPageState extends State with TickerProviderStateMixin children: [ Container( margin: const EdgeInsets.only(top: 0), - child: Form( - child: Column( - children: [ - // E-mail - Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("E-mail"), - const SizedBox(height: 10), - Text(context.read().email,), // TODO: 수정해야됨 - Divider(color: AppColor.swatchColor,), - ], + child: Column( + children: [ + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("E-mail"), + const SizedBox(height: 10), + Text( + context.read().email, ), - ), - const SizedBox(height: 10), - Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Username"), - if (isEditMode) - TextFormField( - autofocus: true, - initialValue: username, - decoration: InputDecoration( - focusedBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: AppColor.swatchColor), - ), - enabledBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: AppColor.swatchColor), - ), - hintText: 'username', - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.withOpacity(0.7), - ), + Divider( + color: AppColor.swatchColor, + ), + ], + ), + ), + const SizedBox(height: 10), + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Username"), + if (isEditMode) + Form( + key: _formKey1, + child: TextFormField( + controller: _userNameController, + style: TextStyle(fontSize: 14), + decoration: InputDecoration( + focusedBorder: + const UnderlineInputBorder( + borderSide: BorderSide( + color: AppColor.swatchColor), + ), + enabledBorder: + const UnderlineInputBorder( + borderSide: BorderSide( + color: AppColor.swatchColor), + ), + hintText: 'username', + hintStyle: TextStyle( + fontSize: 12, + color: Colors.grey.withOpacity(0.7), ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter your name'; - } - return null; - }, - onSaved: (value) { - // Handle saving logic - }, ), - if (!isEditMode) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 16), - Text(context.read().username,), - const SizedBox(height: 4), - Divider(color: AppColor.swatchColor,), - ], - ) - ], - ), - ), - const SizedBox(height: 12), - Container( + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter your name'; + } + return null; + }, + onSaved: (value) { + setState(() { + _userNameController.text = value!; + }); + }, + ), + ), + if (!isEditMode) + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + const SizedBox(height: 16), + Text( + context.read().name, + ), + const SizedBox(height: 4), + Divider( + color: AppColor.swatchColor, + ), + ], + ) + ], + ), + ), + const SizedBox(height: 12), + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Nickname"), + if (isEditMode) + Form( + key: _formKey2, + child: TextFormField( + style: TextStyle(fontSize: 14), + controller: _nickNameController, + decoration: InputDecoration( + focusedBorder: + const UnderlineInputBorder( + borderSide: BorderSide( + color: AppColor.swatchColor), + ), + enabledBorder: + const UnderlineInputBorder( + borderSide: BorderSide( + color: AppColor.swatchColor), + ), + hintText: 'nickname', + hintStyle: TextStyle( + fontSize: 14, + color: Colors.grey.withOpacity(0.7), + ), + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter your name'; + } + return null; + }, + onSaved: (value) { + setState(() { + _nickNameController.text = value!; + }); + }, + ), + ), + if (!isEditMode) + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + const SizedBox(height: 16), + Text( + context.read().nickname, + ), + const SizedBox(height: 4), + Divider( + color: AppColor.swatchColor, + ), + ], + ) + ], + ), + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Age + SizedBox( + width: 120, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Nickname"), + Text("Age"), if (isEditMode) - TextFormField( - autofocus: true, - initialValue: username, - decoration: InputDecoration( - focusedBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: AppColor.swatchColor), - ), - enabledBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: AppColor.swatchColor), - ), - hintText: 'nickname', - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.withOpacity(0.7), + Form( + key: _formKey3, + child: TextFormField( + style: TextStyle(fontSize: 14), + controller: _ageController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + focusedBorder: + const UnderlineInputBorder( + // 선택 시 하단 밑줄 색상 변경 + borderSide: BorderSide( + color: AppColor.swatchColor), + ), + enabledBorder: + const UnderlineInputBorder( + // 비활성 시 하단 밑줄 색상 + borderSide: BorderSide( + color: AppColor.swatchColor), + ), + hintText: 'age', + hintStyle: TextStyle( + fontSize: 14, + color: + Colors.grey.withOpacity(0.7), + ), ), - + validator: (value) { + if (value == null || + value.isEmpty) { + return 'Please enter your age'; + } + if (int.tryParse(value) == null) { + return 'Age must be a number'; + } + return null; + }, + onSaved: (value) { + setState(() { + _ageController.text = value!; + }); + }, ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter your name'; - } - return null; - }, - onSaved: (value) { - // Handle saving logic - }, ), if (!isEditMode) Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - const SizedBox(height: 16), - Text(context.read().nickname,), - const SizedBox(height: 4), - Divider(color: AppColor.swatchColor,), + const SizedBox(height: 20), + Text(context + .read() + .age + .toString()), // TODO + Divider( + color: AppColor.swatchColor, + ), ], ) ], ), ), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + const SizedBox(width: 20), + // Gender + SizedBox( + width: 150, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Age - SizedBox( - width: 120, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Age"), - if (isEditMode) - TextFormField( - initialValue: age.toString(), - keyboardType: TextInputType.number, - decoration: InputDecoration( - focusedBorder: const UnderlineInputBorder( - // 선택 시 하단 밑줄 색상 변경 - borderSide: BorderSide(color: AppColor.swatchColor), - ), - enabledBorder: const UnderlineInputBorder( - // 비활성 시 하단 밑줄 색상 - borderSide: BorderSide(color: AppColor.swatchColor), - ), - hintText: 'age', - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.withOpacity(0.7), - ), - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter your age'; - } - if (int.tryParse(value) == null) { - return 'Age must be a number'; - } - return null; - }, - onSaved: (value) { - age = int.tryParse(value!)!; - }, - ), - if (!isEditMode) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 20), - Text(context.read().age.toString()), // TODO - Divider(color: AppColor.swatchColor,), - ], - ) - ], + Text("Gender"), + const SizedBox(height: 20), + Text( + context.read().gender == 0 + ? "Male" + : "Female", + style: TextStyle( + fontSize: 16, ), ), - const SizedBox(width: 20), - // Gender - if (isEditMode) - SizedBox( - width: 150, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Gender"), - DropdownButtonFormField( - padding: const EdgeInsets.fromLTRB(0, 0, 20, 0), - value: _selectedGender, - onChanged: (String? newValue) { - setState(() { - _selectedGender = newValue; - }); - }, - items: _genders.map>((String value) { - return DropdownMenuItem( - value: value, - child: Text( - value, - style: const TextStyle(fontSize: 14), - ), - ); - }).toList(), - validator: (value) { - if (value == null || value.isEmpty) { - return 'please choose your gender'; - } - return null; - }, - onSaved: (value) { - gender = (value! == 'Male' ? 0 : 1); - }, - ), - ], - ), - ), - if (!isEditMode) - SizedBox( - width: 150, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Gender"), - const SizedBox(height: 20), - Text( - context.read().gender == 0 ? "남자" : "여자", - // TODO: 수정해야됨 - style: TextStyle( - fontSize: 16, - ), - ), - Divider(color: AppColor.swatchColor,) - ], - ), - ), + Divider( + color: AppColor.swatchColor, + ) ], ), + ), ], - )), + ), + ], + ), ) ], ), @@ -364,132 +394,196 @@ class _SettingPageState extends State with TickerProviderStateMixin ], ), ), - if(!isEditMode) - Positioned( - left: 0, - right: 0, - top: 460, - child: Center( - child: Container( - width: 350, // Set the width of the Container - height: 120, // Set the height of the Container - margin: const EdgeInsetsDirectional.fromSTEB(20, 20, 20, 20), - padding: const EdgeInsets.all(20.0), - decoration: BoxDecoration( - color: AppColor.objectColor, - borderRadius: BorderRadius.circular(15.0), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.1), - blurRadius: 20, - spreadRadius: 5, - ), - ], - ), - child: Column( - children: [ - SizedBox(height: 5,), - Align( - child: Text( - 'Send an invitation!', - style: TextStyle( - fontSize: 18, - color: AppColor.textColor, - fontWeight: FontWeight.bold, + if (!isEditMode) + Positioned( + left: 0, + right: 0, + top: 460, + child: Center( + child: Container( + width: 350, // Set the width of the Container + height: 120, // Set the height of the Container + margin: const EdgeInsetsDirectional.fromSTEB(20, 20, 20, 20), + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + color: AppColor.objectColor, + borderRadius: BorderRadius.circular(15.0), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 20, + spreadRadius: 5, + ), + ], + ), + child: Column( + children: [ + SizedBox( + height: 5, + ), + Align( + child: Text( + 'Send an invitation!', + style: TextStyle( + fontSize: 18, + color: AppColor.textColor, + fontWeight: FontWeight.bold, + ), ), ), - ), - SizedBox(height: 15,), - Align( - alignment: Alignment.center, - child: Text( - context.read().familyKeyCode, - style: TextStyle( - fontSize: 20, - color: Colors.black, - fontWeight: FontWeight.bold, + SizedBox( + height: 15, + ), + Align( + alignment: Alignment.center, + child: Text( + context.read().familyKeyCode, + style: TextStyle( + fontSize: 20, + color: Colors.black, + fontWeight: FontWeight.bold, + ), ), ), - ), - ], + ], + ), ), ), ), - ), - Positioned( - left: 0, - right: 0, - top: 620, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - onPressed: () { - setState(() { - buttonText = 'Log Out'; - }); - showDialog( - context: context, - builder: (BuildContext buildContext) { - return AlertDialog( - backgroundColor: AppColor.objectColor, - content: const Text( - 'Do you wanna leave?', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: AppColor.swatchColor, + if (isEditMode) + Positioned( + left: 0, + right: 0, + top: 620, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () async { + try { + await UserApiService.putUser( + username: _userNameController.text, + nickname: _nickNameController.text, + age: int.parse(_ageController.text), + ).then((value) { + setState(() { + context + .read() + .setUsername(_userNameController.text); + context + .read() + .setNicKName(_nickNameController.text); + context + .read() + .setAge(int.parse(_ageController.text)); + }); + + _formKey1.currentState!.save(); + _formKey2.currentState!.save(); + _formKey3.currentState!.save(); + setState(() { + isEditMode = !isEditMode; + }); + }); + } catch (e) { + print('Error during API call: $e'); + } + }, + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(35), + ), + backgroundColor: AppColor.textColor, // 항상 활성화된 색상 + minimumSize: const Size(120, 40), + ), + child: Text( + 'Edit', + style: const TextStyle( + color: AppColor.objectColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ], + ), + ), + if (!isEditMode) + Positioned( + left: 0, + right: 0, + top: 620, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () { + showDialog( + context: context, + builder: (BuildContext buildContext) { + return AlertDialog( + backgroundColor: AppColor.objectColor, + content: const Text( + 'Do you wanna leave?', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: AppColor.swatchColor, + ), ), - ), - actions: [ - Center( - child: TextButton( - onPressed: () { - Navigator.pop(context); - Navigator.pop(context); - Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const LoginSignUpPage())); - }, - style: TextButton.styleFrom( - foregroundColor: AppColor.objectColor, - padding: const EdgeInsets.fromLTRB(40, 10, 40, 10), - minimumSize: const Size(100, 40), - backgroundColor: AppColor.textColor, - ), - child: const Text( - 'Log Out', - style: TextStyle( - fontSize: 18, - color: AppColor.objectColor, + actions: [ + Center( + child: TextButton( + onPressed: () { + Navigator.pop(context); + Navigator.pop(context); + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => + const LoginSignUpPage())); + }, + style: TextButton.styleFrom( + foregroundColor: AppColor.objectColor, + padding: const EdgeInsets.fromLTRB( + 40, 10, 40, 10), + minimumSize: const Size(100, 40), + backgroundColor: AppColor.textColor, + ), + child: const Text( + 'Go Out', + style: TextStyle( + fontSize: 18, + color: AppColor.objectColor, + ), ), ), ), - ), - ], - ); - }, - ); - }, - style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(35), + ], + ); + }, + ); + }, + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(35), + ), + backgroundColor: AppColor.textColor, // 항상 활성화된 색상 + minimumSize: const Size(120, 40), ), - backgroundColor: AppColor.textColor, // 항상 활성화된 색상 - minimumSize: const Size(120, 40), - ), - child: Text( - buttonText, - style: const TextStyle( - color: AppColor.objectColor, - fontWeight: FontWeight.bold, - fontSize: 18, + child: Text( + 'Go Out', + style: const TextStyle( + color: AppColor.objectColor, + fontWeight: FontWeight.bold, + fontSize: 18, + ), ), ), - ), - - ], + ], + ), ), - ), ], ), ); diff --git a/lib/services/user_api_service.dart b/lib/services/user_api_service.dart index e1095be..7460d71 100644 --- a/lib/services/user_api_service.dart +++ b/lib/services/user_api_service.dart @@ -89,7 +89,7 @@ class UserApiService { body: jsonEncode(data), ); - if (response.statusCode == 201) { + if (response.statusCode == 200) { return true; } // 예외 처리; 메시지를 포함한 예외를 던짐