2024-12-19 02:16:35 +04:00
|
|
|
import 'dart:io';
|
|
|
|
|
2024-11-07 16:23:34 +04:00
|
|
|
import 'package:flutter/material.dart';
|
2024-12-18 03:01:46 +04:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2024-12-18 13:10:57 +04:00
|
|
|
import 'package:pmu_flutter_labs/presentation/home_page/bloc/events.dart';
|
|
|
|
import 'package:pmu_flutter_labs/presentation/like_bloc/like_bloc.dart';
|
2024-12-19 02:16:35 +04:00
|
|
|
import 'package:pmu_flutter_labs/presentation/locale_bloc/locale_bloc.dart';
|
|
|
|
import 'package:pmu_flutter_labs/presentation/locale_bloc/locale_state.dart';
|
2024-12-18 13:10:57 +04:00
|
|
|
import 'components/locale/l10n/app_locale.dart';
|
2024-12-18 03:01:46 +04:00
|
|
|
import 'data/repositories/quotes_repository.dart';
|
|
|
|
import '/presentation/home_page/bloc/bloc.dart';
|
|
|
|
import '/presentation/home_page/home_page.dart';
|
2024-11-07 16:23:34 +04:00
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
2024-11-13 02:38:05 +04:00
|
|
|
@override
|
2024-11-07 16:23:34 +04:00
|
|
|
Widget build(BuildContext context) {
|
2024-12-19 02:16:35 +04:00
|
|
|
return BlocProvider<LocaleBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create:(context) => LocaleBloc(Locale(Platform.localeName)),
|
|
|
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Цитаты',
|
|
|
|
locale: state.currentLocale,
|
|
|
|
localizationsDelegates: AppLocale.localizationsDelegates,
|
|
|
|
supportedLocales: AppLocale.supportedLocales,
|
|
|
|
theme: ThemeData(
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
|
|
|
home: RepositoryProvider<QuotesRepository>(
|
|
|
|
lazy: true,
|
|
|
|
create: (_) => QuotesRepository(),
|
|
|
|
child: BlocProvider<LikeBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create: (context) => LikeBloc(), // Add LikeBloc here
|
|
|
|
child: BlocProvider<HomeBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create: (context) => HomeBloc(context.read<QuotesRepository>()),
|
|
|
|
child: const MyHomePage(title: "Цитаты"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
),
|
2024-11-13 03:40:53 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-12-18 13:10:57 +04:00
|
|
|
|