lab7 ready

This commit is contained in:
Kirill 2024-12-09 15:28:52 +04:00
parent 3588ff0f02
commit 168a9e287c

View File

@ -1,8 +1,14 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:testlab/presentaition/home_page/home_page.dart'; import 'package:testlab/presentaition/home_page/home_page.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:testlab/presentaition/home_page/bloc/bloc.dart'; import 'package:testlab/presentaition/home_page/bloc/bloc.dart';
import 'data/repositories/potter_films_repository.dart'; import 'data/repositories/potter_films_repository.dart';
import 'package:testlab/presentaition/like_bloc/like_bloc.dart';
import 'package:testlab/presentaition/locale_bloc/locale_bloc.dart';
import 'package:testlab/presentaition/locale_bloc/locale_state.dart';
import 'components/locale/l10n/app_locale.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
@ -13,21 +19,36 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return BlocProvider<LocaleBloc>(
title: 'Flutter Demo', lazy: false,
debugShowCheckedModeBanner: false, create: (context) => LocaleBloc(Locale(Platform.localeName)),
theme: ThemeData( child: BlocBuilder<LocaleBloc, LocaleState>(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red), builder: (context, state) {
useMaterial3: true, return MaterialApp(
), title: 'Flutter Demo',
home: RepositoryProvider<PotterFilmsRepository>( locale: state.currentLocale,
lazy: true, localizationsDelegates: AppLocale.localizationsDelegates,
create: (_) => PotterFilmsRepository(), supportedLocales: AppLocale.supportedLocales,
child: BlocProvider<HomeBloc>( debugShowCheckedModeBanner: false,
lazy: false, theme: ThemeData(
create: (context) => HomeBloc(context.read<PotterFilmsRepository>()), colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
child: const MyHomePage(title: 'Фирсов Кирилл Алексеевич'), useMaterial3: true,
), ),
home: RepositoryProvider<PotterFilmsRepository>(
lazy: true,
create: (_) => PotterFilmsRepository(),
child: BlocProvider<LikeBloc>(
lazy: false,
create: (context) => LikeBloc(),
child: BlocProvider<HomeBloc>(
lazy: false,
create: (context) => HomeBloc(context.read<PotterFilmsRepository>()),
child: const MyHomePage(title: 'Фирсов Кирилл Алексеевич'),
),
),
),
);
},
), ),
); );
} }