Skip to content

Commit

Permalink
feat(profile): added user profile edit page
Browse files Browse the repository at this point in the history
Added a new feature page, where user can change his username, full name, avatar photo and bio, but it is not implemented yet.
  • Loading branch information
itsezlife committed Feb 15, 2024
1 parent cf8e114 commit 773f832
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 14 deletions.
29 changes: 28 additions & 1 deletion lib/app/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ GoRouter router(AppBloc appBloc) => GoRouter(
pageBuilder: (context, state) {
return CustomTransitionPage(
key: state.pageKey,
child: const UserProfileCreatePost(),
child: const UserProfileEdit(),
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
return SharedAxisTransition(
Expand All @@ -445,6 +445,33 @@ GoRouter router(AppBloc appBloc) => GoRouter(
},
);
},
routes: [
GoRoute(
path: 'info/:label',
name: 'edit_profile_info',
parentNavigatorKey: _rootNavigatorKey,
pageBuilder: (context, state) {
final query = state.uri.queryParameters;
final label = state.pathParameters['label']!;
final appBarTitle = query['title']!;
final description = query['description'];
final infoValue = query['value'];
final infoType =
state.extra as ProfileEditInfoType?;

return MaterialPage<void>(
fullscreenDialog: true,
child: ProfileInfoEditPage(
appBarTitle: appBarTitle,
description: description,
infoValue: infoValue,
infoLabel: label,
infoType: infoType!,
),
);
},
),
],
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/components/login/components/email_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class _EmailTextFieldState extends State<EmailTextField> {
final isLoading = context.select<LoginCubit, bool>(
(b) => b.state.status.isLoading,
);

return AppTextField(
key: const ValueKey('loginEmailTextField'),
filled: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
focusNode: _focusNode,
hintText: 'Email',
enabled: !isLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class _PasswordTextFieldState extends State<PasswordTextField> {
return AppTextField(
key: const ValueKey('loginPasswordTextField'),
filled: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
focusNode: _focusNode,
hintText: 'Password',
enabled: !isLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ class _FullNameTextFieldState extends State<FullNameTextField> {
context.select<SignupCubit, bool>((c) => c.state.isLoading);
final fullNameError =
context.select<SignupCubit, String?>((c) => c.state.fullNameError);

return AppTextField(
filled: true,
focusNode: _focusNode,
hintText: 'Full name',
hintText: 'Name',
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
textInputAction: TextInputAction.next,
textCapitalization: TextCapitalization.words,
Expand Down
2 changes: 2 additions & 0 deletions lib/user_profile/bloc/user_profile_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ class UserProfileBloc extends Bloc<UserProfileEvent, UserProfileState> {
fullName: event.fullName,
pushToken: event.pushToken,
);
emit(state.copyWith(status: UserProfileStatus.userUpdated));
} catch (error, stackTrace) {
logE('Failed to update user.', error: error, stackTrace: stackTrace);
addError(error, stackTrace);
emit(state.copyWith(status: UserProfileStatus.userUpdateFailed));
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/user_profile/bloc/user_profle_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum UserProfileStatus {
togglingNotificationsFailed,
togglingNotificationsSucceeded,
userUpdated,
userUpdateFailed,
}

class UserProfileState extends Equatable {
Expand Down
Loading

0 comments on commit 773f832

Please sign in to comment.