PIbd-31_MasenkinMS_PMU/lib/main.dart

57 lines
2.0 KiB
Dart
Raw Normal View History

2024-10-02 02:39:17 +04:00
import 'dart:io';
2024-09-10 01:32:13 +04:00
import 'package:flutter/material.dart';
2024-09-30 22:15:55 +04:00
import 'package:flutter_bloc/flutter_bloc.dart';
2024-10-02 02:39:17 +04:00
import 'package:pmu_labworks/components/extensions/context_x.dart';
import 'package:pmu_labworks/components/locale/l10n/app_locale.dart';
2024-09-30 22:15:55 +04:00
import 'package:pmu_labworks/data/repositories/potterdb_repository.dart';
import 'package:pmu_labworks/view/home_page/bloc/bloc.dart';
2024-09-30 02:09:26 +04:00
import 'package:pmu_labworks/view/home_page/home_page.dart';
2024-10-02 02:39:17 +04:00
import 'package:pmu_labworks/view/reaction_bloc/reaction_bloc.dart';
import 'package:pmu_labworks/view/locale_bloc/locale_bloc.dart';
import 'package:pmu_labworks/view/locale_bloc/locale_state.dart';
2024-09-10 01:32:13 +04:00
void main() {
2024-09-13 00:51:36 +04:00
runApp(const MyApp());
2024-09-10 01:32:13 +04:00
}
class MyApp extends StatelessWidget {
2024-09-13 00:51:36 +04:00
const MyApp({super.key});
2024-09-10 01:32:13 +04:00
@override
Widget build(BuildContext context) {
2024-10-02 02:39:17 +04:00
return BlocProvider<LocaleBloc>(
lazy: false,
create: (context) => LocaleBloc(Locale(Platform.localeName)),
child: BlocBuilder<LocaleBloc, LocaleState>(
builder: (context, state) {
return MaterialApp(
title: "Comments App",
locale: state.currentLocale,
localizationsDelegates: AppLocale.localizationsDelegates,
supportedLocales: AppLocale.supportedLocales,
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: RepositoryProvider<PotterDBRepository>(
lazy: true,
create: (_) => PotterDBRepository(),
child: BlocProvider<ReactionBloc>(
lazy: false,
create: (context) => ReactionBloc(),
child: BlocProvider<HomeBloc>(
lazy: false,
create: (context) => HomeBloc(context.read<PotterDBRepository>()),
child: HomePage(title: "Comments App"),
),
),
),
);
},
2024-09-30 22:15:55 +04:00
),
2024-09-10 01:32:13 +04:00
);
}
}