Skip to content

Commit 6e46c4b

Browse files
committed
회원정보 수정
1 parent cbc185d commit 6e46c4b

File tree

10 files changed

+368
-244
lines changed

10 files changed

+368
-244
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ migrate_working_dir/
3333
/build/
3434

3535
# Web related
36-
lib/generated_plugin_registrant.dart
3736

3837
# Symbolication related
3938
app.*.symbols
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:provider/provider.dart';
4+
import 'package:restaurant/inmat/auth/inmat_auth.dart';
5+
import 'package:restaurant/inmat/inMatAPI/inMatHttp.dart';
6+
import 'package:restaurant/widget/account/change_profile/change_profile_model.dart';
7+
8+
class ChangeProfile extends StatelessWidget {
9+
const ChangeProfile({Key? key}) : super(key: key);
10+
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
appBar: AppBar(title: Text("프로필 변경"),),
15+
body: ChangeNotifierProvider<ChangeProfileModel>(
16+
create: (context) => ChangeProfileModel(),
17+
child: Consumer<ChangeProfileModel>(builder: (context, model, child) {
18+
return SafeArea(
19+
child: Padding(
20+
padding: const EdgeInsets.symmetric(horizontal: 16.0),
21+
child: Column(
22+
children: [
23+
SizedBox(height: 30),
24+
//Text(Provider.of<ChangeProfileModel>(context).nickname),
25+
nicknameField(),
26+
CupertinoButton(
27+
child: Text("변경"),
28+
onPressed: () async {
29+
try {
30+
await Provider.of<ChangeProfileModel>(context,
31+
listen: false)
32+
.change();
33+
} on ExpirationAccessToken {
34+
// 액세스 토큰 만료: 로그아웃 후 다시 로그인
35+
print('액세스 토큰 만료');
36+
} on AccessDenied {
37+
// 접근 권한 없음
38+
print('접근 권한 없음');
39+
} on OverlappingNickName {
40+
// 닉네임 중복 알림
41+
print('닉네임 중복');
42+
} catch (e) {
43+
print(e);
44+
// 오류 메세지 알림
45+
}
46+
},
47+
)
48+
],
49+
),
50+
),
51+
);
52+
}),
53+
),
54+
);
55+
}
56+
}
57+
58+
class nicknameField extends StatefulWidget {
59+
const nicknameField({
60+
Key? key,
61+
}) : super(key: key);
62+
63+
@override
64+
State<nicknameField> createState() => _nicknameFieldState();
65+
}
66+
67+
class _nicknameFieldState extends State<nicknameField> {
68+
@override
69+
Widget build(BuildContext context) {
70+
return Column(
71+
crossAxisAlignment: CrossAxisAlignment.start,
72+
children: [
73+
Text(
74+
'닉네임',
75+
style: TextStyle(fontSize: 18),
76+
),
77+
TextField(
78+
decoration: InputDecoration(
79+
hintText: InMatAuth.instance.currentUser!.nickName,
80+
),
81+
onChanged: (text) {
82+
Provider.of<ChangeProfileModel>(context, listen: false)
83+
.setNickname(text);
84+
},
85+
),
86+
],
87+
);
88+
}
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:restaurant/inmat/auth/inmat_auth.dart';
3+
import 'package:restaurant/inmat/inMatAPI/inMatHttp.dart';
4+
5+
class ChangeProfileModel with ChangeNotifier {
6+
ChangeProfileModel() {
7+
profile = InMatAuth.instance.currentUser!.toMap();
8+
}
9+
10+
Map<String, dynamic> profile = {};
11+
12+
String nickname ='';
13+
14+
void setNickname(name) {
15+
nickname = name;
16+
notifyListeners();
17+
}
18+
19+
Future<void> change() async {
20+
profile['nickName'] = nickname;
21+
print(profile);
22+
23+
try {
24+
await InMatAuth.instance.updateProfile(profile);
25+
} on ExpirationAccessToken {
26+
// 액세스 토큰 만료: 로그아웃 후 다시 로그인
27+
} on AccessDenied {
28+
// 접근 권한 없음
29+
} on OverlappingNickName {
30+
// 닉네임 중복 알림
31+
} catch (e) {
32+
print(e);
33+
// 오류 메세지 알림
34+
}
35+
}
36+
}

lib/Widget/account/sign_up/sign_up_page.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,14 @@ class GuestLoginText extends StatelessWidget {
381381
child: const Text(
382382
'비회원으로 앱을 사용',
383383
style: TextStyle(
384-
fontSize: 15,
384+
fontSize: 12,
385385
decoration: TextDecoration.underline,
386386
color: Color(0xff191818)),
387387
)),
388388
const Text(
389389
'해보실 수 있습니다',
390390
style: TextStyle(
391-
fontSize: 15,
391+
fontSize: 12,
392392
color: Color(0xff848484),
393393
),
394394
),

0 commit comments

Comments
 (0)