mirrored_repositories/Expenses_Tracker_App
import 'package:expense_repository/auth_repository.dart';
import 'package:expense_repository/expense_repository.dart';
import 'package:expense_repository/user_repository.dart';
import 'package:expenses_tracker/bloc/auth_bloc/auth_bloc.dart';
import 'package:expenses_tracker/bloc/get_expenses_bloc/get_expenses_bloc.dart';
import 'package:expenses_tracker/screens/auth/login/login_screen.dart';
import 'package:expenses_tracker/screens/home/views/home_screen.dart';
import 'package:expenses_tracker/utils/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class MyAppView extends StatelessWidget {
  final String initialRoute;
  const MyAppView({
    super.key,
    required this.initialRoute,
  });

  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider(
          create: (context) => GetExpensesBloc(FirebaseExpenseRepo())
            ..add(GetExpenses(Expense.empty)),
        ),
        BlocProvider(
          create: (context) => AuthBloc(FirebaseAuthRepo(), FirebaseUserRepo()),
        ),
      ],
      child: MaterialApp(
        title: 'Expense Tracker',
        themeMode: ThemeMode.system,
        theme: ExpensesTrackerAppTheme.lightTheme,
        darkTheme: ExpensesTrackerAppTheme.darkTheme,
        debugShowCheckedModeBanner: false,
        initialRoute: initialRoute,
        routes: {
          '/login': (context) => const LoginScreen(),
          '/home': (context) => const HomeScreen(),
        },
      ),
    );
  }
}
