59 lines
2.1 KiB
Dart
59 lines
2.1 KiB
Dart
import 'package:get_it/get_it.dart';
|
|
import '../data/datasources/dashboard_remote_datasource.dart';
|
|
import '../data/repositories/dashboard_repository_impl.dart';
|
|
import '../domain/repositories/dashboard_repository.dart';
|
|
import '../domain/usecases/get_dashboard_data.dart';
|
|
import '../presentation/bloc/dashboard_bloc.dart';
|
|
import '../../../core/network/dio_client.dart';
|
|
import '../../../core/network/network_info.dart';
|
|
|
|
/// Configuration de l'injection de dépendances pour le module Dashboard
|
|
class DashboardDI {
|
|
static final GetIt _getIt = GetIt.instance;
|
|
|
|
/// Enregistre toutes les dépendances du module Dashboard
|
|
static void registerDependencies() {
|
|
// Data Sources
|
|
_getIt.registerLazySingleton<DashboardRemoteDataSource>(
|
|
() => DashboardRemoteDataSourceImpl(
|
|
dioClient: _getIt<DioClient>(),
|
|
),
|
|
);
|
|
|
|
// Repositories
|
|
_getIt.registerLazySingleton<DashboardRepository>(
|
|
() => DashboardRepositoryImpl(
|
|
remoteDataSource: _getIt<DashboardRemoteDataSource>(),
|
|
networkInfo: _getIt<NetworkInfo>(),
|
|
),
|
|
);
|
|
|
|
// Use Cases
|
|
_getIt.registerLazySingleton(() => GetDashboardData(_getIt<DashboardRepository>()));
|
|
_getIt.registerLazySingleton(() => GetDashboardStats(_getIt<DashboardRepository>()));
|
|
_getIt.registerLazySingleton(() => GetRecentActivities(_getIt<DashboardRepository>()));
|
|
_getIt.registerLazySingleton(() => GetUpcomingEvents(_getIt<DashboardRepository>()));
|
|
|
|
// BLoC
|
|
_getIt.registerFactory(
|
|
() => DashboardBloc(
|
|
getDashboardData: _getIt<GetDashboardData>(),
|
|
getDashboardStats: _getIt<GetDashboardStats>(),
|
|
getRecentActivities: _getIt<GetRecentActivities>(),
|
|
getUpcomingEvents: _getIt<GetUpcomingEvents>(),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Nettoie les dépendances du module Dashboard
|
|
static void unregisterDependencies() {
|
|
_getIt.unregister<DashboardBloc>();
|
|
_getIt.unregister<GetUpcomingEvents>();
|
|
_getIt.unregister<GetRecentActivities>();
|
|
_getIt.unregister<GetDashboardStats>();
|
|
_getIt.unregister<GetDashboardData>();
|
|
_getIt.unregister<DashboardRepository>();
|
|
_getIt.unregister<DashboardRemoteDataSource>();
|
|
}
|
|
}
|