feat: Refactor repositories and modules to remove FirebaseAuth dependency and utilize DataConnectService
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'src/data/repositories_impl/settings_repository_impl.dart';
|
||||
import 'src/domain/repositories/settings_repository_interface.dart';
|
||||
import 'src/domain/usecases/sign_out_usecase.dart';
|
||||
@@ -9,20 +9,19 @@ import 'src/presentation/pages/client_settings_page.dart';
|
||||
|
||||
/// A [Module] for the client settings feature.
|
||||
class ClientSettingsModule extends Module {
|
||||
@override
|
||||
List<Module> get imports => <Module>[DataConnectModule()];
|
||||
|
||||
@override
|
||||
void binds(Injector i) {
|
||||
// Repositories
|
||||
i.addLazySingleton<SettingsRepositoryInterface>(
|
||||
() => SettingsRepositoryImpl(firebaseAuth: FirebaseAuth.instance),
|
||||
);
|
||||
i.addLazySingleton<SettingsRepositoryInterface>(SettingsRepositoryImpl.new);
|
||||
|
||||
// UseCases
|
||||
i.addLazySingleton(SignOutUseCase.new);
|
||||
|
||||
// BLoCs
|
||||
i.add<ClientSettingsBloc>(
|
||||
() => ClientSettingsBloc(signOutUseCase: i.get<SignOutUseCase>()),
|
||||
);
|
||||
i.add<ClientSettingsBloc>(ClientSettingsBloc.new);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
||||
|
||||
import '../../domain/repositories/settings_repository_interface.dart';
|
||||
|
||||
/// Implementation of [SettingsRepositoryInterface].
|
||||
///
|
||||
/// This implementation delegates authentication operations to [FirebaseAuth].
|
||||
/// This implementation delegates authentication operations to [DataConnectService].
|
||||
class SettingsRepositoryImpl implements SettingsRepositoryInterface {
|
||||
/// Creates a [SettingsRepositoryImpl] with the required [_firebaseAuth].
|
||||
const SettingsRepositoryImpl({required this.firebaseAuth});
|
||||
/// Creates a [SettingsRepositoryImpl] with the required [_service].
|
||||
const SettingsRepositoryImpl({required dc.DataConnectService service}) : _service = service;
|
||||
|
||||
/// The Firebase Auth instance.
|
||||
final FirebaseAuth firebaseAuth;
|
||||
/// The Data Connect service.
|
||||
final dc.DataConnectService _service;
|
||||
|
||||
@override
|
||||
Future<void> signOut() async {
|
||||
try {
|
||||
await firebaseAuth.signOut();
|
||||
} catch (e) {
|
||||
throw Exception('Error signing out: ${e.toString()}');
|
||||
}
|
||||
return _service.run(() async {
|
||||
await _service.auth.signOut();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user