comp
This commit is contained in:
@@ -13,6 +13,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
super(AuthStateInitial()) {
|
||||
on<AuthEventLoginOAuth>(_onAuthEventLoginOAuth);
|
||||
on<AuthEventVerifyOAuth>(_onAuthEventVerifyOAuth);
|
||||
on<AuthEventAddEmailAndPassword>(_onAuthEventAddEmailAndPassword);
|
||||
}
|
||||
|
||||
void _onAuthEventLoginOAuth(
|
||||
@@ -46,4 +47,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
emit(const AuthStateFailure());
|
||||
}
|
||||
}
|
||||
|
||||
void _onAuthEventAddEmailAndPassword(
|
||||
AuthEventAddEmailAndPassword event, Emitter<AuthState> emit) async {
|
||||
emit(AuthStateProcess());
|
||||
try {
|
||||
await _userRepository.addEmailAndPassword(event.email, event.password);
|
||||
} catch (e) {
|
||||
emit(const AuthStateFailure());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,3 +18,16 @@ class AuthEventVerifyOAuth extends AuthEvent {
|
||||
|
||||
const AuthEventVerifyOAuth({required this.code});
|
||||
}
|
||||
|
||||
class AuthEventAddEmailAndPassword extends AuthEvent {
|
||||
final String email;
|
||||
final String password;
|
||||
|
||||
const AuthEventAddEmailAndPassword({
|
||||
required this.email,
|
||||
required this.password,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [email, password];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
|
||||
part 'profile_event.dart';
|
||||
@@ -7,25 +8,17 @@ part 'profile_state.dart';
|
||||
|
||||
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||
final UserRepository _userRepository;
|
||||
// final AuthBloc _authBloc; // lo nuevo
|
||||
|
||||
ProfileBloc({required UserRepository userRepository})
|
||||
: _userRepository = userRepository,
|
||||
ProfileBloc({
|
||||
required UserRepository userRepository,
|
||||
// required AuthBloc authBloc
|
||||
}) : _userRepository = userRepository,
|
||||
// _authBloc = authBloc,
|
||||
super(UpdateUserInfoInitial()) {
|
||||
// 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 _onUpdateUserInfo(
|
||||
UpdateUserInfo event, Emitter<ProfileState> emit) async {
|
||||
emit(UpdateUserInfoLoading());
|
||||
|
||||
Reference in New Issue
Block a user