Skip to content

Commit

Permalink
프로필 변경 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
devunt committed Jun 30, 2024
1 parent 01af001 commit a55bb20
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mutation ProfileScreen_UpdateUserProfile_Mutation($input: UpdateUserProfileInput!) {
updateUserProfile(input: $input) {
id
name

avatar {
id
url
}
}
}
25 changes: 24 additions & 1 deletion apps/mobile/lib/screens/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import 'package:gap/gap.dart';
import 'package:glyph/components/button.dart';
import 'package:glyph/components/forms/form_text_field.dart';
import 'package:glyph/components/pressable.dart';
import 'package:glyph/context/toast.dart';
import 'package:glyph/ferry/extension.dart';
import 'package:glyph/ferry/widget.dart';
import 'package:glyph/graphql/__generated__/profile_screen_query.req.gql.dart';
import 'package:glyph/graphql/__generated__/profile_screen_update_user_profile_mutation.req.gql.dart';
import 'package:glyph/icons/tabler.dart';
import 'package:glyph/shells/default.dart';
import 'package:glyph/themes/colors.dart';
Expand Down Expand Up @@ -47,7 +50,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
operation: GProfileScreen_QueryReq(),
builder: (context, client, data) {
return Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
child: Column(
children: [
Center(
Expand Down Expand Up @@ -134,7 +137,27 @@ class _ProfileScreenState extends State<ProfileScreen> {
const Spacer(),
Button(
'변경',
size: ButtonSize.large,
enabled: _isFormValid,
onPressed: () async {
if (!_formKey.currentState!.saveAndValidate()) {
return;
}

final values = _formKey.currentState!.value;

final req = GProfileScreen_UpdateUserProfile_MutationReq(
(b) => b
..vars.input.avatarId = data.me!.profile.avatar.id
..vars.input.name = values['name'],
);

await client.req(req);
if (context.mounted) {
context.toast.show('프로필이 변경되었어요');
await context.router.maybePop();
}
},
),
],
),
Expand Down

0 comments on commit a55bb20

Please sign in to comment.