feat: integrate city poultry feature by adding routes, DI setup, and updating UI components to reflect new data handling and localization changes
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'package:rasadyar_chicken/features/city_poultry/data/datasources/remote/city_poultry_remote_data_source.dart';
|
||||
import 'package:rasadyar_chicken/features/city_poultry/data/datasources/remote/city_poultry_remote_data_source_impl.dart';
|
||||
import 'package:rasadyar_chicken/features/city_poultry/data/repositories/city_poultry_repository.dart';
|
||||
import 'package:rasadyar_chicken/features/city_poultry/data/repositories/city_poultry_repository_impl.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
/// Setup dependency injection for city_poultry feature
|
||||
Future<void> setupCityPoultryDI(GetIt di, DioRemote dioRemote) async {
|
||||
di.registerLazySingleton<CityPoultryRemoteDataSource>(
|
||||
() => CityPoultryRemoteDataSourceImpl(dioRemote),
|
||||
);
|
||||
|
||||
di.registerLazySingleton<CityPoultryRepository>(
|
||||
() => CityPoultryRepositoryImpl(di.get<CityPoultryRemoteDataSource>()),
|
||||
);
|
||||
}
|
||||
|
||||
/// Re-register city_poultry dependencies (used when base URL changes)
|
||||
Future<void> reRegisterCityPoultryDI(GetIt di, DioRemote dioRemote) async {
|
||||
await reRegister(di, () => CityPoultryRemoteDataSourceImpl(dioRemote));
|
||||
await reRegister(
|
||||
di,
|
||||
() => CityPoultryRepositoryImpl(di.get<CityPoultryRemoteDataSource>()),
|
||||
);
|
||||
}
|
||||
|
||||
/// Helper function to re-register a dependency
|
||||
Future<void> reRegister<T extends Object>(
|
||||
GetIt di,
|
||||
T Function() factory,
|
||||
) async {
|
||||
if (di.isRegistered<T>()) {
|
||||
await di.unregister<T>();
|
||||
}
|
||||
di.registerLazySingleton<T>(factory);
|
||||
}
|
||||
Reference in New Issue
Block a user