70 lines
2.6 KiB
Dart
70 lines
2.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:pmd_labs/data/repositories/album_repository.dart';
|
|
import 'package:pmd_labs/home_page/home_page.dart';
|
|
|
|
import 'components/locale/l10n/app_locale.dart';
|
|
import 'home_page/bloc/home_bloc.dart';
|
|
import 'home_page/home_page.dart';
|
|
import 'like_bloc/like_bloc.dart';
|
|
import 'locale_bloc/locale_bloc.dart';
|
|
import 'locale_bloc/locale_state.dart';
|
|
|
|
void main() {
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Устанавливаем локаль по умолчанию
|
|
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'),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
} |