import 'package:food_health/providers/user_store.dart';
import 'package:food_health/router/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';

import 'config/theme/theme.dart';
import 'providers/app_store.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (context) => AppStore()),
        ChangeNotifierProvider(create: (context) => UserStore()),
      ],
      child: MyApp(),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 694),
      useInheritedMediaQuery: true,
      child: MaterialApp.router(
        debugShowCheckedModeBanner: false,
        routerConfig: goRouter,
        localizationsDelegates: [],
        themeMode: ThemeMode.light,
        theme: ThemeData(
          useMaterial3: true,
          colorScheme: scheme,
          elevatedButtonTheme: ElevatedButtonThemeData(
            style: ElevatedButton.styleFrom(
              backgroundColor: scheme.primary,
              foregroundColor: scheme.onPrimary,
            ),
          ),
          textTheme: textTheme,
          scaffoldBackgroundColor: Color(0xffFAFAFE),
          appBarTheme: AppBarTheme(
            backgroundColor: scheme.surface,
            scrolledUnderElevation: 0,
            titleTextStyle: textTheme.titleMedium,
          ),
        ),
        builder: EasyLoading.init(),
      ),
    );
  }
}
