import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:ongbut_ntmanh/app/module/course/bloc/course_bloc.dart';
import 'package:ongbut_ntmanh/app/module/coursedetail/bloc/course_detail_bloc.dart';
import 'app/module/comment/bloc/comment_bloc.dart';
import 'app/module/counter/bloc/counter_bloc.dart';
import 'app/module/lession/bloc/lesson_bloc.dart';
import 'app/module/login/bloc/login_bloc.dart';
import 'app/module/new/bloc/new_bloc.dart';
import 'app/module/school/bloc/school_bloc.dart';
import 'launcher.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return
      MultiBlocProvider(
        providers: MainBloc.allBlocs(),
        child: const MyHomePage(),
      );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
        home: LauncherPage(),
    );
  }
}

class MainBloc {
  static List<BlocProvider> allBlocs() => [
    BlocProvider<CounterBloc>(
        create: (BuildContext context) => CounterBloc()),
    BlocProvider<CourseBloc>(
        create: (BuildContext context) => CourseBloc()),
    BlocProvider<SchoolBloc>(
        create: (BuildContext context) => SchoolBloc()),
    BlocProvider<LoginBloc>(
        create: (BuildContext context) => LoginBloc()),
    BlocProvider<NewBloc>(
        create: (BuildContext context) => NewBloc()),
    BlocProvider<CommentBloc>(
        create: (BuildContext context) => CommentBloc()),
    BlocProvider<CourseDetailBloc>(
        create: (BuildContext context) => CourseDetailBloc()),
    BlocProvider<LessonBloc>(
        create: (BuildContext context) => LessonBloc()),
  ];
}
