Skip to content

Commit

Permalink
Merge pull request #5 from hiranthaR/feature/register
Browse files Browse the repository at this point in the history
Sign up Feature
  • Loading branch information
charithccmc authored Aug 15, 2021
2 parents 3a3f371 + a1dabc0 commit d1952ea
Show file tree
Hide file tree
Showing 36 changed files with 3,227 additions and 1,486 deletions.
Binary file modified assets/icons/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 16 additions & 67 deletions lib/application/login/login_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ part 'login_bloc.freezed.dart';
part 'login_event.dart';
part 'login_state.dart';

@LazySingleton()
@Injectable()
class LoginBloc extends Bloc<LoginEvent, LoginState> {
final AuthRepository _authRepository;
LoginBloc(this._authRepository) : super(LoginState.initial());
Expand All @@ -22,7 +22,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
LoginEvent event,
) async* {
yield* event.map(
signInWithGoogle: (e) async* {
signInWithGoogle: (_) async* {
yield state.copyWith.call(
isSubmitting: true,
authFailureOrSuccessOption: none(),
Expand All @@ -33,64 +33,6 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
authFailureOrSuccessOption: some(failureOrSuccess),
);
},
signInWithFacebook: (e) async* {
yield state.copyWith.call(
isSubmitting: true,
authFailureOrSuccessOption: none(),
);
final failureOrSuccess =
await _authRepository.signInWithFacebook(e.url);
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: some(failureOrSuccess),
);
},
signInWithGithub: (e) async* {
yield state.copyWith.call(
isSubmitting: true,
authFailureOrSuccessOption: none(),
);
final failureOrSuccess = await _authRepository.signInWithGithub();
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: some(failureOrSuccess),
);
},
signInWithTwitter: (e) async* {
yield state.copyWith.call(
isSubmitting: true,
authFailureOrSuccessOption: none(),
);
final failureOrSuccess = await _authRepository.signInWithTwitter();
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: some(failureOrSuccess),
);
},
signInWithFacebookClicked: (_) async* {
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: none(),
);
},
signInWithGithubClicked: (_) async* {
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: none(),
);
},
signInWithTwitterClicked: (_) async* {
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: none(),
);
},
backPressFromWebView: (_) async* {
yield state.copyWith.call(
isSubmitting: false,
authFailureOrSuccessOption: none(),
);
},
emailChanged: (e) async* {
yield state.copyWith(
emailAddress: Email(e.emailStr),
Expand All @@ -103,9 +45,14 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
authFailureOrSuccessOption: none(),
);
},
signInWithEmailAndPasswordPressed:
(SignInWithEmailAndPasswordPressed value) async* {
late Either<AuthFailure, Unit> failureOrSuccess;
togglePasswordVisibility: (_) async* {
yield state.copyWith(
showPassword: !state.showPassword,
authFailureOrSuccessOption: none(),
);
},
signInWithEmailAndPasswordPressed: (_) async* {
Option<Either<AuthFailure, Unit>> failureOrSuccess = none();

final isEmailValid = state.emailAddress.isValid();
final isPasswordValid = state.password.isValid();
Expand All @@ -116,15 +63,17 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
authFailureOrSuccessOption: none(),
);

failureOrSuccess = await _authRepository.signInWithEmailAndPassword(
emailAddress: state.emailAddress,
password: state.password,
failureOrSuccess = some(
await _authRepository.signInWithEmailAndPassword(
email: state.emailAddress,
password: state.password,
),
);
}
yield state.copyWith(
isSubmitting: false,
showErrorMessages: true,
authFailureOrSuccessOption: optionOf(failureOrSuccess),
authFailureOrSuccessOption: failureOrSuccess,
);
},
);
Expand Down
Loading

0 comments on commit d1952ea

Please sign in to comment.