import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:news_getx/global.dart';
import 'package:news_getx/routes/app_pages.dart';
import 'package:news_getx/theme/app_theme.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

Future<void> main() async {
  await Global.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: Size(375, 812),
      // 如果不把这歌参数设为true 那么column就不会随着软键盘而变化
      // useInheritedMediaQuery: true,
      builder: (BuildContext context, Widget? child) {
        return RefreshConfiguration(
          headerBuilder: () => ClassicHeader(),
          footerBuilder: () => ClassicFooter(),
          hideFooterWhenNotFull: true,
          headerTriggerDistance: 80,
          maxOverScrollExtent: 100,
          footerTriggerDistance: 150,
          child: GetMaterialApp(
            title: 'News',
            debugShowCheckedModeBanner: false,
            theme: AppTheme.light,
            initialRoute: AppRoutes.Initial,
            getPages: AppPages.pages,
            builder: EasyLoading.init(),
          ),
        );
      },
    );
  }
}
