import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';


import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaper/routes/app_routes.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';


class WallPaperApp extends StatefulWidget {
  @override
  const WallPaperApp({super.key});

  @override
  State<WallPaperApp> createState() => _WallPaperAppState();
}

class _WallPaperAppState extends State<WallPaperApp> {
  @override
  Widget build(BuildContext context){
    // return MaterialApp(
    //   title: 'wall paper',
    //   debugShowCheckedModeBanner: false,
    //   theme: ThemeData(
    //     colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
    //     useMaterial3: true,
    //   ),
    //   home: const RootWidget(title:'root widget title'),
    // );
    return const RootWidget(title:'root widget title');
  }
}

class RootWidget extends StatefulWidget {
  @override
  const RootWidget({super.key,required this.title});
  final String title;
  @override
  State<RootWidget> createState() => _RootWidgetState();
}

class _RootWidgetState extends State<RootWidget> {
  @override
  Widget build(BuildContext context) {
    final easyLoading = EasyLoading.init();

      return ScreenUtilInit(
          builder: (context,widget){
            return GetMaterialApp(
              title:'Getmaterial app title',
              debugShowCheckedModeBanner: false,
              theme: ThemeData.light(useMaterial3: true).copyWith(
                primaryColor: Colors.blue,
                bottomNavigationBarTheme: const BottomNavigationBarThemeData(
                  backgroundColor: Colors.black,
                  unselectedItemColor:Colors.grey,
                  selectedItemColor: Colors.white,
                  showSelectedLabels: false,
                  showUnselectedLabels: false,
                ),
                appBarTheme: const AppBarTheme(
                  backgroundColor: Colors.black,
                  centerTitle: true,
                  titleTextStyle: TextStyle(
                    color: Colors.white,
                    fontSize: 18,
                  ),
                  foregroundColor:Colors.white
                )
              ),
              themeMode: ThemeMode.light,
              getPages: AppRoutes.routes,
              initialRoute: AppRoutes.initialPage,
              builder: (context,widget){
                return MediaQuery(
                  // 设置文字大小不随系统设置改变
                  data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
                  child: KeyboardDismissOnTap(
                    // 点击其他交互式组件，也关闭键盘
                    dismissOnCapturedTaps: true,
                    child: easyLoading(context, widget),
                  ),
                );
              },
            );
          },
      );
  }
}