2024-12-10 20:49:23 +04:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
2024-09-06 22:39:54 +04:00
|
|
|
import 'package:flutter/material.dart';
|
2024-11-26 01:44:56 +04:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:pmd_labs/data/repositories/album_repository.dart';
|
2024-11-08 13:07:43 +04:00
|
|
|
import 'package:pmd_labs/home_page/home_page.dart';
|
2024-09-06 22:39:54 +04:00
|
|
|
|
2024-12-10 20:49:23 +04:00
|
|
|
import 'components/locale/l10n/app_locale.dart';
|
2024-11-26 01:44:56 +04:00
|
|
|
import 'home_page/bloc/home_bloc.dart';
|
|
|
|
import 'home_page/home_page.dart';
|
2024-12-10 20:49:23 +04:00
|
|
|
import 'like_bloc/like_bloc.dart';
|
|
|
|
import 'locale_bloc/locale_bloc.dart';
|
|
|
|
import 'locale_bloc/locale_state.dart';
|
2024-11-26 01:44:56 +04:00
|
|
|
|
2024-09-06 22:39:54 +04:00
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
2024-11-08 13:07:43 +04:00
|
|
|
@override
|
2024-09-06 22:39:54 +04:00
|
|
|
Widget build(BuildContext context) {
|
2024-12-10 20:49:23 +04:00
|
|
|
// Устанавливаем локаль по умолчанию
|
|
|
|
final initialLocale = kIsWeb
|
|
|
|
? const Locale('ru') // Измените это на необходимую локаль для веба
|
|
|
|
: Locale(Platform.localeName);// локаль по умолчанию для мобильных приложений или веба
|
|
|
|
|
|
|
|
return BlocProvider<LocaleBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create: (context) => LocaleBloc(initialLocale),
|
|
|
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Лабы ПМУ',
|
|
|
|
locale: state.currentLocale,
|
|
|
|
localizationsDelegates: AppLocale.localizationsDelegates,
|
|
|
|
supportedLocales: AppLocale.supportedLocales,
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
theme: ThemeData(
|
|
|
|
textTheme: const TextTheme(
|
|
|
|
headlineLarge: TextStyle(fontFamily: 'Correction_Tape'),
|
|
|
|
bodyLarge: TextStyle(fontFamily: 'Correction_Tape'),
|
|
|
|
bodyMedium: TextStyle(fontFamily: 'Correction_Tape'),
|
|
|
|
headlineSmall: TextStyle(fontFamily: 'Correction_Tape'),
|
|
|
|
),
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
|
|
|
home: RepositoryProvider<AlbumRepository>(
|
|
|
|
lazy: true,
|
|
|
|
create: (_) => AlbumRepository(),
|
|
|
|
child: BlocProvider<LikeBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create: (context) => LikeBloc(),
|
|
|
|
child: BlocProvider<HomeBloc>(
|
|
|
|
lazy: false,
|
|
|
|
create: (context) =>
|
|
|
|
HomeBloc(context.read<AlbumRepository>()),
|
|
|
|
child: const MyHomePage(title: 'Catalog of Music Albums'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2024-09-06 22:39:54 +04:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2024-11-08 13:07:43 +04:00
|
|
|
}
|