import 'package:app_gaslieferung/bloc/authentication/auth_bloc.dart';
import 'package:app_gaslieferung/bloc/tour/tour_bloc.dart';
import 'package:app_gaslieferung/bloc/tour_select/bloc.dart';
import 'package:app_gaslieferung/repository/tour_repository.dart';
import 'package:app_gaslieferung/service/tour_service.dart';
import 'package:app_gaslieferung/ui/page/login.dart';
import 'package:app_gaslieferung/ui/theme/theme.dart';
import 'package:app_gaslieferung/ui/widgets/message_wrapper/message_wrapper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'bloc/message_wrapper/message_bloc.dart';

void main() {
  runApp(GasDeliveryApp());
}

class GasDeliveryApp extends StatefulWidget {
  const GasDeliveryApp({super.key});

  @override
  State<StatefulWidget> createState() => _GasDeliveryAppState();
}

class _GasDeliveryAppState extends State<GasDeliveryApp> {
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider(create: (context) => MessageBloc()),
        BlocProvider(
          create: (context) => AuthBloc(
            url: "http://127.0.0.1:3000/login",
            msgBloc: context.read<MessageBloc>(),
          ),
        ),
        BlocProvider(
          create: (context) => TourBloc(
            tour: TourRepository(
              service: TourService(baseUrl: "http://127.0.0.1:3000"),
            ),
          ),
        ),
      ],
      child: MaterialApp(
        builder: (context, child) => MessageWrapperWidget(child: child!),
        theme: AppTheme.light(),
        darkTheme: AppTheme.dark(),
        themeMode: ThemeMode.light,
        // oder ThemeMode.dark / light
        home: LoginPage(),
      ),
    );
  }
}
