64 lines
1.3 KiB
Dart
64 lines
1.3 KiB
Dart
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
/// EVENTS
|
|
abstract class EmailVerify {}
|
|
|
|
class SetEmailEvent extends EmailVerify {
|
|
final String email;
|
|
SetEmailEvent(this.email);
|
|
}
|
|
|
|
class CheckOtpFilled extends EmailVerify {
|
|
final bool isOtpFilled;
|
|
CheckOtpFilled(this.isOtpFilled);
|
|
}
|
|
|
|
class CheckIsLoggedIn extends EmailVerify{}
|
|
|
|
/// STATE
|
|
class EmailVerifyState {
|
|
final String email;
|
|
final bool isOtpFilled;
|
|
final bool loggedIn;
|
|
|
|
EmailVerifyState({
|
|
required this.email,
|
|
required this.isOtpFilled,
|
|
required this.loggedIn
|
|
});
|
|
|
|
EmailVerifyState copyWith({
|
|
String? email,
|
|
bool? isOtpFilled,
|
|
bool? loggedIn
|
|
}) {
|
|
return EmailVerifyState(
|
|
email: email ?? this.email,
|
|
isOtpFilled: isOtpFilled ?? this.isOtpFilled,
|
|
loggedIn: loggedIn ?? this.loggedIn
|
|
);
|
|
}
|
|
}
|
|
|
|
/// BLOC
|
|
class EmailVerifyBloc extends Bloc<EmailVerify, EmailVerifyState> {
|
|
EmailVerifyBloc()
|
|
: super(EmailVerifyState(email: "", isOtpFilled: false,
|
|
loggedIn: false
|
|
)) {
|
|
|
|
on<SetEmailEvent>((event, emit) {
|
|
emit(state.copyWith(email: event.email));
|
|
});
|
|
|
|
on<CheckOtpFilled>((event, emit) {
|
|
emit(state.copyWith(isOtpFilled: event.isOtpFilled));
|
|
});
|
|
|
|
on<CheckIsLoggedIn>((event,emit){
|
|
emit(state.copyWith(loggedIn: true));
|
|
});
|
|
|
|
}
|
|
}
|