2024-11-13 21:23:25 +03:00
|
|
|
import 'dart:io';
|
|
|
|
|
2024-09-09 20:40:52 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2024-11-13 21:23:25 +03:00
|
|
|
import 'package:pmd_labs/data/repositories/movie_repository.dart';
|
|
|
|
import 'package:pmd_labs/presentation/home_page/bloc/bloc.dart';
|
2024-10-14 16:24:22 +03:00
|
|
|
import 'package:pmd_labs/presentation/home_page/home_page.dart';
|
2024-11-13 21:23:25 +03:00
|
|
|
import 'package:pmd_labs/presentation/like_bloc/like_bloc.dart';
|
|
|
|
import 'package:pmd_labs/presentation/locale_bloc/locale_bloc.dart';
|
|
|
|
import 'package:pmd_labs/presentation/locale_bloc/locale_state.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
|
|
|
import 'components/locale/l10n/app_locale.dart';
|
2024-09-09 20:40:52 +03:00
|
|
|
|
|
|
|
void main() {
|
2024-10-14 16:24:22 +03:00
|
|
|
runApp(const MyApp());
|
2024-09-09 20:40:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
2024-10-14 16:24:22 +03:00
|
|
|
const MyApp({super.key});
|
|
|
|
|
2024-11-13 21:23:25 +03:00
|
|
|
// This widget is the root of your application.
|
2024-09-09 20:40:52 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-11-14 16:44:44 +03:00
|
|
|
return BlocProvider<LocaleBloc>( //
|
2024-11-13 21:23:25 +03:00
|
|
|
lazy: false,
|
|
|
|
create: (context) => LocaleBloc(Locale(Platform.localeName)),
|
2024-11-14 16:44:44 +03:00
|
|
|
child: BlocBuilder<LocaleBloc, LocaleState>( //
|
2024-11-13 21:23:25 +03:00
|
|
|
builder: (context, state) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Flutter Demo',
|
2024-11-14 16:44:44 +03:00
|
|
|
locale: state.currentLocale, // передаем текущую локаль
|
|
|
|
localizationsDelegates: AppLocale.localizationsDelegates, // делегат (подключение локали)
|
|
|
|
supportedLocales: AppLocale.supportedLocales, // список доступных локалей (подключение локали)
|
2024-11-13 21:23:25 +03:00
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
theme: ThemeData(
|
|
|
|
colorScheme:
|
|
|
|
ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
|
|
|
home: RepositoryProvider<MovieRepository>(
|
|
|
|
lazy: true,
|
|
|
|
create: (_) => MovieRepository(),
|
2024-11-14 16:44:44 +03:00
|
|
|
child: BlocProvider<LikeBloc>( // добавили BlocProvider
|
2024-11-13 21:23:25 +03:00
|
|
|
lazy: false,
|
|
|
|
create: (context) => LikeBloc(),
|
|
|
|
child: BlocProvider<HomeBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create: (context) =>
|
|
|
|
HomeBloc(context.read<MovieRepository>()),
|
|
|
|
child: const HomePage(),
|
|
|
|
),
|
|
|
|
)));
|
|
|
|
},
|
|
|
|
));
|
2024-09-09 20:40:52 +03:00
|
|
|
}
|
|
|
|
}
|