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,22 +19,37 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider<LocaleBloc>(
lazy: false,
create: (context) => LocaleBloc(Locale(Platform.localeName)),
child: BlocBuilder<LocaleBloc, LocaleState>(
builder: (context, state) {
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Flutter Demo',
locale: state.currentLocale,
localizationsDelegates: AppLocale.localizationsDelegates,
supportedLocales: AppLocale.supportedLocales,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: ThemeData( theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red), colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true, useMaterial3: true,
), ),
home: RepositoryProvider<PotterFilmsRepository>( home: RepositoryProvider<PotterFilmsRepository>(
lazy: true, lazy: true,
create: (_) => PotterFilmsRepository(), create: (_) => PotterFilmsRepository(),
child: BlocProvider<LikeBloc>(
lazy: false,
create: (context) => LikeBloc(),
child: BlocProvider<HomeBloc>( child: BlocProvider<HomeBloc>(
lazy: false, lazy: false,
create: (context) => HomeBloc(context.read<PotterFilmsRepository>()), create: (context) => HomeBloc(context.read<PotterFilmsRepository>()),
child: const MyHomePage(title: 'Фирсов Кирилл Алексеевич'), child: const MyHomePage(title: 'Фирсов Кирилл Алексеевич'),
), ),
), ),
),
);
},
),
); );
} }
} }