import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_data_connect/krow_data_connect.dart';
import 'data/repositories_impl/coverage_repository_impl.dart';
import 'domain/repositories/coverage_repository.dart';
import 'domain/usecases/get_coverage_stats_usecase.dart';
import 'domain/usecases/get_shifts_for_date_usecase.dart';
import 'presentation/blocs/coverage_bloc.dart';
import 'presentation/pages/coverage_page.dart';

/// Modular module for the coverage feature.
class CoverageModule extends Module {
  @override
  void binds(Injector i) {
    // Repositories
    i.addSingleton<CoverageRepository>(
      () => CoverageRepositoryImpl(dataConnect: ExampleConnector.instance),
    );

    // Use Cases
    i.addSingleton(GetShiftsForDateUseCase.new);
    i.addSingleton(GetCoverageStatsUseCase.new);

    // BLoCs
    i.addSingleton<CoverageBloc>(
      () => CoverageBloc(
        getShiftsForDate: i.get<GetShiftsForDateUseCase>(),
        getCoverageStats: i.get<GetCoverageStatsUseCase>(),
      ),
    );
  }

  @override
  void routes(RouteManager r) {
    r.child('/', child: (_) => const CoveragePage());
  }
}
