import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hmg_qline/view_models/screen_config_view_model.dart';
import 'package:provider/provider.dart';
import 'package:hmg_qline/config/dependency_injection.dart';
import 'package:hmg_qline/config/routes.dart';
import 'package:hmg_qline/constants/app_constants.dart';
import 'package:hmg_qline/view_models/queuing_view_model.dart';
import 'package:hmg_qline/views/view_helpers/size_config.dart';
import 'package:wakelock_plus/wakelock_plus.dart';


void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await AppDependencies.addDependencies();
  WakelockPlus.enable();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        return OrientationBuilder(builder: (context, orientation) {
          SizeConfig().init(constraints, orientation);
          // SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown]);
          SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
          return MultiProvider(
              providers: [
                ChangeNotifierProvider<ScreenConfigViewModel>(create: (context) => getIt.get<ScreenConfigViewModel>()),
                ChangeNotifierProvider<QueuingViewModel>(create: (context) => getIt.get<QueuingViewModel>()),
              ],
              child: MaterialApp(
                showSemanticsDebugger: false,
                title: AppStrings.appName,
                theme: ThemeData(
                  fontFamily: AppStrings.fontNamePoppins,
                  colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(
                    surface: const Color.fromRGBO(255, 255, 255, 1),
                  ),
                ),
                initialRoute: AppRoutes.initialRoute,
                routes: AppRoutes.routes,
                debugShowCheckedModeBanner: false,
              ));
        });
      },
    );
  }
}
