import 'package:chat/configs/app_colors.dart';
import 'package:chat/configs/themes.dart';
import 'package:chat/controllers/group_controller.dart';
import 'package:chat/controllers/moment_controller.dart';
import 'package:chat/controllers/private_controller.dart';
import 'package:chat/controllers/publish_controller.dart';
import 'package:chat/controllers/user_controller.dart';
import 'package:chat/routes/app_router.dart';
import 'package:chat/routes/app_routes.dart';
import 'package:chat/services/auth_service.dart';
import 'package:chat/services/tabbar_service.dart';
import 'package:chat/services/tim_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

Future<void> main() async {
  /// 设置状态栏样式，透明
  SystemUiOverlayStyle style = const SystemUiOverlayStyle(
    statusBarColor: AppColors.transparent, // 顶部状态栏
    systemNavigationBarColor: AppColors.nav, // 底部多出来那块
  );
  SystemChrome.setSystemUIOverlayStyle(style);

  WidgetsFlutterBinding.ensureInitialized();

  await GetStorage.init();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'ZH-CHAT',
      debugShowCheckedModeBanner: false,
      theme: Themes.light,
      darkTheme: Themes.dark,
      initialRoute: AppRoutes.transit,
      defaultTransition: Transition.cupertino,
      getPages: AppRouter.getPages,
      builder: EasyLoading.init(),
      initialBinding: BindingsBuilder(
        () {
          Get.put(AuthService());
          Get.put(TabbarService());
          Get.put(TimService());

          Get.lazyPut(
            () => GroupController(),
            fenix: true,
          );
          Get.lazyPut(
            () => PrivateController(),
            fenix: true,
          );
          Get.lazyPut(
            () => MomentController(),
            fenix: true,
          );
          Get.lazyPut(
            () => UserController(),
            fenix: true,
          );
          Get.lazyPut(
            () => PublishController(),
            fenix: true,
          );
        },
      ),
    );
  }
}
