before rediense

This commit is contained in:
Felipe
2024-02-26 14:46:26 -05:00
parent 37b6665002
commit a1e367bdf3
10 changed files with 341 additions and 164 deletions
+18 -12
View File
@@ -11,27 +11,33 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
ProfileBloc({required UserRepository userRepository})
: _userRepository = userRepository,
super(UpdateUserInfoInitial()) {
on<UploadPicture>(_onUploadPicture);
// on<UploadPicture>(_onUploadPicture);
on<UpdateUserInfo>(_onUpdateUserInfo);
}
void _onUploadPicture(UploadPicture event, Emitter<ProfileState> emit) async {
emit(UploadPictureLoading());
try {
String userImage =
await _userRepository.uploadPicture(event.file, event.userId);
emit(UploadPictureSuccess(userImage));
} catch (e) {
emit(UploadPictureFailure());
}
}
// void _onUploadPicture(UploadPicture event, Emitter<ProfileState> emit) async {
// emit(UploadPictureLoading());
// try {
// String userImage =
// await _userRepository.uploadPicture(event.file, event.userId);
// emit(UploadPictureSuccess(userImage));
// } catch (e) {
// emit(UploadPictureFailure());
// }
// }
void _onUpdateUserInfo(
UpdateUserInfo event, Emitter<ProfileState> emit) async {
emit(UpdateUserInfoLoading());
try {
await _userRepository.updateUserInfo(event.userId, {
await _userRepository.updateUserInfo(event.userId, event.picture, {
'name': event.name,
// 'picture': event.picture,
'nickname': event.nickname,
'email': event.email,
'phone': event.phone,
'birthDate': event.birthDate,
'gender': event.gender
});
emit(const UpdateUserInfoSuccess());
} catch (e) {