// ignore_for_file: deprecated_member_use

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
import 'screens/auth/bloc/auth_bloc.dart';
import 'widgets/animated_splash_screen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'utils/theme_manager.dart';
import 'simple_auth_gate.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (context) => ThemeManager()),
        BlocProvider(
          create: (context) => AuthBloc(),
        ),
      ],
      child: Consumer<ThemeManager>(
        builder: (context, themeManager, child) {
          return MaterialApp(
            title: 'LBA',
            theme: themeManager.lightTheme,
            darkTheme: themeManager.darkTheme,
            themeMode:
                themeManager.isDarkMode ? ThemeMode.dark : ThemeMode.light,
            themeAnimationDuration: const Duration(milliseconds: 300),
            themeAnimationCurve: Curves.easeInOutCubic,
            home: CoolSplashScreen(
              nextScreen: const SimpleAuthGate(),
              duration: const Duration(seconds: 3),
            ),
          );
        },
      ),
    );
  }
}