You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
import 'package:flutter/material.dart';
|
|
import 'package:thesis_shop/bloc/cart_bloc.dart';
|
|
import 'package:thesis_shop/bloc/product_bloc.dart';
|
|
import 'package:thesis_shop/bloc/user_bloc.dart';
|
|
import 'package:thesis_shop/bloc_provider.dart';
|
|
import 'package:thesis_shop/route_key.dart';
|
|
import 'package:thesis_shop/screens/cart/cart_screen.dart';
|
|
import 'package:thesis_shop/screens/product_list/product_list_screen.dart';
|
|
import 'package:thesis_shop/service/product_service.dart';
|
|
import 'package:thesis_shop/utils/map_keys_extension.dart';
|
|
|
|
class ThesisShopApp extends StatelessWidget {
|
|
final ProductService productService;
|
|
const ThesisShopApp({Key? key, required this.productService})
|
|
: super(key: key);
|
|
|
|
BlocProvider setupBlocs() {
|
|
final userBloc = UserBloc();
|
|
final productBloc = ProductBloc(productService, userBloc);
|
|
final cartBloc = CartBloc(productBloc);
|
|
return BlocProvider(
|
|
productBloc: productBloc,
|
|
userBloc: userBloc,
|
|
cartBloc: cartBloc,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppState(
|
|
blocProvider: setupBlocs(),
|
|
child: MaterialApp(
|
|
title: 'Thesis Shop',
|
|
theme: ThemeData(primarySwatch: Colors.red),
|
|
darkTheme: ThemeData(
|
|
primarySwatch: Colors.red,
|
|
brightness: Brightness.dark,
|
|
),
|
|
routes: {
|
|
RouteKey.products: (context) => const ProductListScreen(),
|
|
RouteKey.cart: (context) => const CartScreen(),
|
|
}.mapKeys((key) => key.name),
|
|
initialRoute: 'products',
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|