import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_modular/flutter_modular.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';
import 'src/presentation/blocs/client_settings_bloc.dart';
import 'src/presentation/pages/client_settings_page.dart';

/// A [Module] for the client settings feature.
class ClientSettingsModule extends Module {
  @override
  void binds(Injector i) {
    // Repositories
    i.addLazySingleton<SettingsRepositoryInterface>(
      () => SettingsRepositoryImpl(firebaseAuth: FirebaseAuth.instance),
    );

    // UseCases
    i.addLazySingleton(SignOutUseCase.new);

    // BLoCs
    i.add<ClientSettingsBloc>(
      () => ClientSettingsBloc(signOutUseCase: i.get<SignOutUseCase>()),
    );
  }

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