import 'package:get/get.dart';
import 'package:location/di/get_it.dart';
import 'package:location/module/about/about_controller.dart';
import 'package:location/module/about/about_page.dart';
import 'package:location/module/analyse/location_analyse_page.dart';
import 'package:location/module/browser/browser_controller.dart';
import 'package:location/module/browser/browser_view.dart';
import 'package:location/module/feedback/feed_back_controller.dart';
import 'package:location/module/feedback/feed_back_page.dart';
import 'package:location/module/friend/friend_controller.dart';
import 'package:location/module/friend/friend_page.dart';
import 'package:location/module/friend/setting/friend_setting_controller.dart';
import 'package:location/module/friend/setting/friend_setting_page.dart';
import 'package:location/module/login/login_controller.dart';
import 'package:location/module/main/main_page.dart';
import 'package:location/module/member/activity/member_activity_controller.dart';
import 'package:location/module/member/member_controller.dart';
import 'package:location/module/member/member_page.dart';
import 'package:location/module/mine/mine_page.dart';
import 'package:location/module/news/news_page.dart';
import 'package:location/module/news/pending_list/news_pending_list_controller.dart';
import 'package:location/module/news/pending_list/news_pending_list_page.dart';
import 'package:location/module/permission/permission_setting_controller.dart';
import 'package:location/module/permission/permission_setting_page.dart';
import 'package:location/module/track/track_detail/track_detail_controller.dart';
import 'package:location/module/track/track_detail/track_detail_page.dart';
import 'package:location/module/urgent_contact/add_contact/add_urgent_contact_controller.dart';
import 'package:location/module/urgent_contact/urgent_contact_controller.dart';
import 'package:location/module/urgent_contact/urgent_contact_page.dart';
import '../module/add_friend/add_friend_dialog_controller.dart';
import '../module/analyse/location_analyse_controller.dart';
import '../module/login/login_page.dart';
import '../module/main/main_controller.dart';
import '../module/member/activity/member_activity_page.dart';
import '../module/mine/mine_controller.dart';
import '../module/news/news_controller.dart';
import '../module/news/news_report/news_report_controller.dart';
import '../module/news/news_report/news_report_page.dart';
import '../module/splash/splash_page.dart';
import '../module/track/track_controller.dart';
import '../module/track/track_page.dart';

abstract class AppPage {
  static final pages = <GetPage>[...generalPages];
}

abstract class RoutePath {
  static const splash = '/';

  static const mainTab = '/mainTab';
  static const login = '/login';
  static const mine = '/mine';
  static const browser = '/browser';
  static const friend = '/friend';
  static const friendSetting = '/friendSetting';
  static const member = '/member';
  static const memberActivity = '/memberActivity';
  static const track = '/track';
  static const trackDetail = '/trackDetail';
  static const news = '/news';
  static const newsReport = '/newsReport';
  static const newsPendingList = '/newsPendingList';
  static const urgentContact = '/urgentContact';
  static const feedback = '/feedback';
  static const about = '/about';
  static const permissionSetting = '/permissionSetting';
  static const locationAnalyse = '/locationAnalyse';
}

class AppBinding extends Bindings {
  @override
  void dependencies() {
    lazyPut(() => getIt.get<MainController>());
    lazyPut(() => getIt.get<AddFriendDialogController>());
    lazyPut(() => getIt.get<LoginController>());
    lazyPut(() => getIt.get<MineController>());
    lazyPut(() => getIt.get<BrowserController>());
    lazyPut(() => getIt.get<FriendController>());
    lazyPut(() => getIt.get<FriendSettingController>());
    lazyPut(() => getIt.get<MemberController>());
    lazyPut(() => getIt.get<TrackController>());
    lazyPut(() => getIt.get<NewsController>());
    lazyPut(() => getIt.get<NewsReportController>());
    lazyPut(() => getIt.get<NewsPendingListController>());
    lazyPut(() => getIt.get<UrgentContactController>());
    lazyPut(() => getIt.get<AddUrgentContactController>());
    lazyPut(() => getIt.get<FeedBackController>());
    lazyPut(() => getIt.get<AboutController>());
    lazyPut(() => getIt.get<PermissionSettingController>());
    lazyPut(() => getIt.get<TrackDetailController>());
    lazyPut(() => getIt.get<LocationAnalyseController>());
    lazyPut(() => getIt.get<MemberActivityController>());
  }

  void lazyPut<S>(InstanceBuilderCallback<S> builder) {
    Get.lazyPut(builder, fenix: true);
  }
}

final generalPages = [
  GetPage(name: RoutePath.splash, page: () => SplashPage()),
  GetPage(name: RoutePath.mainTab, page: () => MainPage()),
  GetPage(name: RoutePath.login, page: () => LoginPage()),
  GetPage(name: RoutePath.browser, page: () => BrowserPage()),
  GetPage(name: RoutePath.mine, page: () => MinePage()),
  GetPage(name: RoutePath.friend, page: () => FriendPage()),
  GetPage(name: RoutePath.friendSetting, page: () => FriendSettingPage()),
  GetPage(name: RoutePath.member, page: () => MemberPage()),
  GetPage(name: RoutePath.track, page: () => TrackPage()),
  GetPage(name: RoutePath.news, page: () => NewsPage()),
  GetPage(name: RoutePath.newsReport, page: () => NewsReportPage()),
  GetPage(name: RoutePath.newsPendingList, page: () => NewsPendingListPage()),
  GetPage(name: RoutePath.urgentContact, page: () => UrgentContactPage()),
  GetPage(name: RoutePath.feedback, page: () => FeedBackPage()),
  GetPage(name: RoutePath.about, page: () => AboutPage()),
  GetPage(name: RoutePath.trackDetail, page: () => TrackDetailPage()),
  GetPage(
      name: RoutePath.permissionSetting, page: () => PermissionSettingPage()),
  GetPage(name: RoutePath.locationAnalyse, page: () => LocationAnalysePage()),
  GetPage(name: RoutePath.memberActivity, page: () => MemberActivityPage()),
];
