import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
import 'package:tm_app/core/network/network_manager.dart';
import 'package:tm_app/core/theme/theme_provider.dart';
import 'package:tm_app/data/repositories/home_repository.dart';
import 'package:tm_app/data/repositories/liked_tenders_repository.dart';
import 'package:tm_app/data/repositories/notification_repository.dart';
import 'package:tm_app/data/repositories/tender_detail_repository.dart';
import 'package:tm_app/data/repositories/tenders_repository.dart';
import 'package:tm_app/data/repositories/your_tenders_repository.dart';
import 'package:tm_app/data/services/home_service.dart';
import 'package:tm_app/data/services/liked_tenders_service.dart';
import 'package:tm_app/data/services/notification_service.dart';
import 'package:tm_app/data/services/tender_detail_service.dart';
import 'package:tm_app/data/services/your_tenders_service.dart';
import 'package:tm_app/view_models/final_completion_of_documents_view_model.dart';
import 'package:tm_app/view_models/liked_tenders_view_model.dart';
import 'package:tm_app/view_models/notification_view_model.dart';
import 'package:tm_app/view_models/tender_detail_view_model.dart';
import 'package:tm_app/view_models/tenders_view_model.dart';
import 'package:tm_app/view_models/your_tenders_view_model.dart';

import '../../data/repositories/auth_repository.dart';
import '../../data/repositories/profile_repository.dart';
import '../../data/services/auth_service.dart';
import '../../data/services/profile_service.dart';
import '../../data/services/tenders_service.dart';
import '../../view_models/auth_view_model.dart';
import '../../view_models/home_view_model.dart';
import '../../view_models/profile_view_model.dart';

List<SingleChildWidget> get providersRemote {
  return [...cores, ...apiClients, ...repositories, ...viewModels, ...others];
}

List<SingleChildWidget> get cores {
  return [
    Provider(create: (context) => NetworkManager(context.read())),
    ChangeNotifierProvider(create: (context) => ThemeProvider()),
  ];
}

List<SingleChildWidget> get apiClients {
  return [
    Provider(create: (context) => AuthService(networkManager: context.read())),
    Provider(create: (context) => HomeService(networkManager: context.read())),
    Provider(
      create: (context) => TenderDetailService(networkManager: context.read()),
    ),

    Provider(
      create: (context) => YourTendersService(networkManager: context.read()),
    ),
    Provider(
      create: (context) => LikedTendersService(networkManager: context.read()),
    ),
    Provider(
      create: (context) => TendersService(networkManager: context.read()),
    ),
    Provider(
      create: (context) => ProfileService(networkManager: context.read()),
    ),
    Provider(
      create: (context) => NotificationsService(networkManager: context.read()),
    ),
  ];
}

List<SingleChildWidget> get repositories {
  return [
    Provider(create: (context) => AuthRepository(authService: context.read())),
    Provider(
      create:
          (context) => YourTendersRepository(
            yourTendersService: context.read(),
            likedTendersService: context.read(),
          ),
    ),
    Provider(
      create:
          (context) => HomeRepository(
            homeService: context.read(),
            yourTendersService: context.read(),
          ),
    ),
    Provider(
      create:
          (context) =>
              TenderDetailRepository(tenderDetailService: context.read()),
    ),

    Provider(
      create:
          (context) =>
              LikedTendersRepository(likedTendersService: context.read()),
    ),
    Provider(
      create: (context) => TendersRepository(tendersService: context.read()),
    ),
    Provider(
      create: (context) => ProfileRepository(profileService: context.read()),
    ),
    Provider(
      create:
          (context) =>
              NotificationsRepository(notificationsService: context.read()),
    ),
  ];
}

List<SingleChildWidget> get viewModels {
  return [
    ChangeNotifierProvider(
      create: (context) => AuthViewModel(authRepository: context.read()),
    ),
    ChangeNotifierProvider(
      create: (context) => HomeViewModel(homeRepository: context.read()),
    ),
    ChangeNotifierProvider(
      create:
          (context) => TendersViewModel(
            tendersRepository: context.read(),
            homeViewModel: context.read(),
          ),
    ),
    ChangeNotifierProvider(
      create:
          (context) => TenderDetailViewModel(
            tenderDetailRepository: context.read(),
            tendersRepository: context.read(),
            tendersViewModel: context.read(),
            homeViewModel: context.read(),
          ),
    ),

    ChangeNotifierProvider(
      create:
          (context) =>
              YourTendersViewModel(yourTendersRepository: context.read()),
    ),
    ChangeNotifierProvider(
      create:
          (context) => LikedTendersViewModel(
            likedTendersRepository: context.read(),
            tendersRepository: context.read(),
            homeViewModel: context.read(),
          ),
    ),
    ChangeNotifierProvider(
      create:
          (context) => ProfileViewModel(
            profileRepository: context.read(),
            authRepository: context.read(),
            authViewModel: context.read(),
          ),
    ),
    ChangeNotifierProvider(
      create: (context) => FinalCompletionOfDocumentsViewModel(),
    ),
    ChangeNotifierProvider(
      create:
          (context) =>
              NotificationViewModel(repositoryViewModel: context.read()),
    ),
  ];
}

List<SingleChildWidget> get others {
  return [];
}
