clean(packages): apply dart fix (close #106)
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit was merged in pull request #107.
This commit is contained in:
@@ -20,15 +20,15 @@ part 'exceptions_firebase.dart';
|
||||
|
||||
abstract class AuthenticationFailureInterface extends AppException
|
||||
implements Exception {
|
||||
|
||||
AuthenticationFailureInterface(this.code, this.msg);
|
||||
AuthenticationFailureInterface.fromCode(this.code)
|
||||
: msg = 'An unknown error occurred.';
|
||||
String code;
|
||||
String msg;
|
||||
|
||||
@override
|
||||
String get message => msg;
|
||||
|
||||
AuthenticationFailureInterface(this.code, this.msg);
|
||||
AuthenticationFailureInterface.fromCode(this.code)
|
||||
: msg = 'An unknown error occurred.';
|
||||
}
|
||||
|
||||
/// {@template apply_action_code_failure}
|
||||
|
||||
+2
-2
@@ -20,10 +20,10 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
|
||||
class AuthenticationCacheDataSourceImpl<T extends Object>
|
||||
extends AuthenticationCacheDataSource<T> {
|
||||
Account? _account;
|
||||
T? _data;
|
||||
|
||||
AuthenticationCacheDataSourceImpl();
|
||||
Account? _account;
|
||||
T? _data;
|
||||
|
||||
@override
|
||||
Future<void> storeAccount(Account? account) async {
|
||||
|
||||
+2
-2
@@ -20,11 +20,11 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
|
||||
class AuthenticationFirebaseDataSourceImpl
|
||||
extends AuthenticationRemoteDataSource {
|
||||
final FirebaseAuth _firebaseAuth;
|
||||
UserCredential? _latestCreds;
|
||||
|
||||
AuthenticationFirebaseDataSourceImpl({FirebaseAuth? firebaseAuth})
|
||||
: _firebaseAuth = firebaseAuth ?? FirebaseAuth.instance;
|
||||
final FirebaseAuth _firebaseAuth;
|
||||
UserCredential? _latestCreds;
|
||||
|
||||
Account _mapper(User user) => AccountModel(
|
||||
uid: user.uid,
|
||||
|
||||
+5
-5
@@ -21,6 +21,11 @@ import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
|
||||
class AuthenticationMockDataSourceImpl extends AuthenticationRemoteDataSource {
|
||||
|
||||
AuthenticationMockDataSourceImpl({
|
||||
this.idToken = 'fake-id-token',
|
||||
this.registeredAccounts,
|
||||
});
|
||||
Pair<Account, String>? _connectedMock;
|
||||
Pair<Account, String>? _registeredMock;
|
||||
DateTime _lastSignInTime = DateTime.now();
|
||||
@@ -30,11 +35,6 @@ class AuthenticationMockDataSourceImpl extends AuthenticationRemoteDataSource {
|
||||
final List<Pair<Account, String>>? registeredAccounts;
|
||||
final String idToken;
|
||||
|
||||
AuthenticationMockDataSourceImpl({
|
||||
this.idToken = 'fake-id-token',
|
||||
this.registeredAccounts,
|
||||
});
|
||||
|
||||
Future<void> _randomDelay() async {
|
||||
await Future<void>.delayed(
|
||||
Duration(milliseconds: Random().nextInt(400) + 200),
|
||||
|
||||
+13
-13
@@ -41,19 +41,7 @@ typedef OnAuthChange<T> = FutureOrResult<T?> Function(
|
||||
);
|
||||
|
||||
class AuthenticationRepositoryImpl<T extends Object>
|
||||
extends AuthenticationRepository<T> {
|
||||
final AuthenticationCacheDataSource<T> _authenticationLocalDataSource;
|
||||
final AuthenticationRemoteDataSource _authenticationRemoteDataSource;
|
||||
|
||||
late FormRepository _formRepository;
|
||||
|
||||
final OnSignUpSuccess<T>? _onSignUpSuccess;
|
||||
|
||||
final OnAuthChange<T>? _onAccountChanges;
|
||||
final StreamController<FutureOrResult<AccountWrapper<T>>> _signUpStream =
|
||||
StreamController();
|
||||
|
||||
bool _pause = false; // Semaphore
|
||||
extends AuthenticationRepository<T> { // Semaphore
|
||||
|
||||
AuthenticationRepositoryImpl({
|
||||
required AuthenticationCacheDataSource<T> authenticationCacheDataSource,
|
||||
@@ -106,6 +94,18 @@ class AuthenticationRepositoryImpl<T extends Object>
|
||||
),
|
||||
);
|
||||
}
|
||||
final AuthenticationCacheDataSource<T> _authenticationLocalDataSource;
|
||||
final AuthenticationRemoteDataSource _authenticationRemoteDataSource;
|
||||
|
||||
late FormRepository _formRepository;
|
||||
|
||||
final OnSignUpSuccess<T>? _onSignUpSuccess;
|
||||
|
||||
final OnAuthChange<T>? _onAccountChanges;
|
||||
final StreamController<FutureOrResult<AccountWrapper<T>>> _signUpStream =
|
||||
StreamController();
|
||||
|
||||
bool _pause = false;
|
||||
|
||||
@override
|
||||
FormRepository get formRepository => _formRepository;
|
||||
|
||||
+1
-1
@@ -26,7 +26,6 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
part 'authentication_state.dart';
|
||||
|
||||
class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> {
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
|
||||
AuthenticationCubit({
|
||||
required AuthenticationRepository<Extra> authenticationRepository,
|
||||
@@ -34,6 +33,7 @@ class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> {
|
||||
super(const AuthenticationState.unknown()) {
|
||||
_listenForAuthenticationChanges();
|
||||
}
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
|
||||
void _listenForAuthenticationChanges() {
|
||||
_authenticationRepository.streamAccount().listen((accountFutureResult) {
|
||||
|
||||
+2
-2
@@ -17,8 +17,6 @@
|
||||
part of 'authentication_cubit.dart';
|
||||
|
||||
class AuthenticationState<Extra> extends Equatable {
|
||||
final AuthenticationStatus status;
|
||||
final AccountWrapper<Extra>? accountWrapper;
|
||||
|
||||
const AuthenticationState._({required this.status, this.accountWrapper});
|
||||
|
||||
@@ -33,6 +31,8 @@ class AuthenticationState<Extra> extends Equatable {
|
||||
|
||||
const AuthenticationState.unauthenticated()
|
||||
: this._(status: AuthenticationStatus.unauthenticated);
|
||||
final AuthenticationStatus status;
|
||||
final AccountWrapper<Extra>? accountWrapper;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [status, accountWrapper];
|
||||
|
||||
+1
-1
@@ -24,12 +24,12 @@ import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
|
||||
part 'email_verification_state.dart';
|
||||
|
||||
class EmailVerificationCubit<Extra> extends Cubit<EmailVerificationState> {
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
|
||||
EmailVerificationCubit({
|
||||
required AuthenticationRepository<Extra> authenticationRepository,
|
||||
}) : _authenticationRepository = authenticationRepository,
|
||||
super(const EmailVerificationState());
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
|
||||
FutureOr<void> sendEmailVerification() async {
|
||||
emit(state.copyWith(status: FormStatus.submissionInProgress));
|
||||
|
||||
+3
-3
@@ -25,9 +25,6 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
part 'password_reset_state.dart';
|
||||
|
||||
class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> {
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
FormRepository get _formRepository =>
|
||||
_authenticationRepository.formRepository;
|
||||
|
||||
PasswordResetCubit({
|
||||
required AuthenticationRepository<Extra> authenticationRepository,
|
||||
@@ -38,6 +35,9 @@ class PasswordResetCubit<Extra> extends FormDataCubit<PasswordResetState> {
|
||||
.accessForm(AuthFormName.passwordResetForm),
|
||||
),
|
||||
);
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
FormRepository get _formRepository =>
|
||||
_authenticationRepository.formRepository;
|
||||
|
||||
@override
|
||||
String get formName => AuthFormName.passwordResetForm;
|
||||
|
||||
+1
-1
@@ -17,13 +17,13 @@
|
||||
part of 'password_reset_cubit.dart';
|
||||
|
||||
class PasswordResetState extends FormDataState {
|
||||
Email get email => form.validatorOf(AuthFormField.email);
|
||||
|
||||
const PasswordResetState({
|
||||
required super.form,
|
||||
super.status = FormStatus.pure,
|
||||
super.errorMessage,
|
||||
});
|
||||
Email get email => form.validatorOf(AuthFormField.email);
|
||||
|
||||
PasswordResetState copyWith({
|
||||
WyattForm? form,
|
||||
|
||||
+3
-3
@@ -23,9 +23,6 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
part 'sign_in_state.dart';
|
||||
|
||||
class SignInCubit<Extra> extends FormDataCubit<SignInState> {
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
FormRepository get _formRepository =>
|
||||
_authenticationRepository.formRepository;
|
||||
|
||||
SignInCubit({
|
||||
required AuthenticationRepository<Extra> authenticationRepository,
|
||||
@@ -36,6 +33,9 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> {
|
||||
.accessForm(AuthFormName.signInForm),
|
||||
),
|
||||
);
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
FormRepository get _formRepository =>
|
||||
_authenticationRepository.formRepository;
|
||||
|
||||
@override
|
||||
String get formName => AuthFormName.signInForm;
|
||||
|
||||
+4
-4
@@ -17,16 +17,16 @@
|
||||
part of 'sign_in_cubit.dart';
|
||||
|
||||
class SignInState extends FormDataState {
|
||||
FormInputValidator<String?, ValidationError> get email =>
|
||||
form.validatorOf(AuthFormField.email);
|
||||
FormInputValidator<String?, ValidationError> get password =>
|
||||
form.validatorOf(AuthFormField.password);
|
||||
|
||||
const SignInState({
|
||||
required super.form,
|
||||
super.status = FormStatus.pure,
|
||||
super.errorMessage,
|
||||
});
|
||||
FormInputValidator<String?, ValidationError> get email =>
|
||||
form.validatorOf(AuthFormField.email);
|
||||
FormInputValidator<String?, ValidationError> get password =>
|
||||
form.validatorOf(AuthFormField.password);
|
||||
|
||||
SignInState copyWith({
|
||||
WyattForm? form,
|
||||
|
||||
+3
-3
@@ -25,9 +25,6 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart';
|
||||
part 'sign_up_state.dart';
|
||||
|
||||
class SignUpCubit<Extra> extends FormDataCubit<SignUpState> {
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
FormRepository get _formRepository =>
|
||||
_authenticationRepository.formRepository;
|
||||
|
||||
SignUpCubit({
|
||||
required AuthenticationRepository<Extra> authenticationRepository,
|
||||
@@ -38,6 +35,9 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> {
|
||||
.accessForm(AuthFormName.signUpForm),
|
||||
),
|
||||
);
|
||||
final AuthenticationRepository<Extra> _authenticationRepository;
|
||||
FormRepository get _formRepository =>
|
||||
_authenticationRepository.formRepository;
|
||||
|
||||
@override
|
||||
String get formName => AuthFormName.signUpForm;
|
||||
|
||||
+4
-4
@@ -17,16 +17,16 @@
|
||||
part of 'sign_up_cubit.dart';
|
||||
|
||||
class SignUpState extends FormDataState {
|
||||
FormInputValidator<String?, ValidationError> get email =>
|
||||
form.validatorOf(AuthFormField.email);
|
||||
FormInputValidator<String?, ValidationError> get password =>
|
||||
form.validatorOf(AuthFormField.password);
|
||||
|
||||
const SignUpState({
|
||||
required super.form,
|
||||
super.status = FormStatus.pure,
|
||||
super.errorMessage,
|
||||
});
|
||||
FormInputValidator<String?, ValidationError> get email =>
|
||||
form.validatorOf(AuthFormField.email);
|
||||
FormInputValidator<String?, ValidationError> get password =>
|
||||
form.validatorOf(AuthFormField.password);
|
||||
|
||||
SignUpState copyWith({
|
||||
WyattForm? form,
|
||||
|
||||
Reference in New Issue
Block a user