diff --git a/lib/Components/locale/l10n/app_locale.dart b/lib/Components/locale/l10n/app_locale.dart index 71a191e..3c31ab0 100644 --- a/lib/Components/locale/l10n/app_locale.dart +++ b/lib/Components/locale/l10n/app_locale.dart @@ -72,16 +72,6 @@ abstract class AppLocale { static const LocalizationsDelegate delegate = _AppLocaleDelegate(); - /// A list of this localizations delegate along with the default localizations - /// delegates. - /// - /// Returns a list of localizations delegates containing this delegate along with - /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, - /// and GlobalWidgetsLocalizations.delegate. - /// - /// Additional delegates can be added by appending to this list in - /// MaterialApp. This list does not have to be used at all if a custom list - /// of delegates is preferred or required. static const List> localizationsDelegates = >[ delegate, GlobalMaterialLocalizations.delegate, @@ -89,35 +79,21 @@ abstract class AppLocale { GlobalWidgetsLocalizations.delegate, ]; - /// A list of this localizations delegate's supported locales. static const List supportedLocales = [ Locale('en'), Locale('ru') ]; - /// No description provided for @search. - /// - /// In ru, this message translates to: - /// **'Поиск'** + // Существующие строки String get search; - - /// No description provided for @liked. - /// - /// In ru, this message translates to: - /// **'нравится!'** String get liked; - - /// No description provided for @disliked. - /// - /// In ru, this message translates to: - /// **'не нравится :<'** String get disliked; - - /// No description provided for @arbEnding. - /// - /// In ru, this message translates to: - /// **'ЗАПЯТАЯ'** String get arbEnding; + + // Новые строки для HeroDetailScreen + String get heroDetailsTitle; + String get heroNoImage; + String get heroNoDescription; } class _AppLocaleDelegate extends LocalizationsDelegate { diff --git a/lib/Components/locale/l10n/app_locale_en.dart b/lib/Components/locale/l10n/app_locale_en.dart index 56a6d6c..0482233 100644 --- a/lib/Components/locale/l10n/app_locale_en.dart +++ b/lib/Components/locale/l10n/app_locale_en.dart @@ -16,5 +16,15 @@ class AppLocaleEn extends AppLocale { String get disliked => 'disliked :<'; @override - String get arbEnding => 'ЗАПЯТАЯ'; -} + String get arbEnding => 'COMMA'; + + // Добавленные строки + @override + String get heroDetailsTitle => 'Hero Details'; + + @override + String get heroNoImage => 'No image available'; + + @override + String get heroNoDescription => 'No description available'; +} \ No newline at end of file diff --git a/lib/Components/locale/l10n/app_locale_ru.dart b/lib/Components/locale/l10n/app_locale_ru.dart index 0fd0794..6bf80c9 100644 --- a/lib/Components/locale/l10n/app_locale_ru.dart +++ b/lib/Components/locale/l10n/app_locale_ru.dart @@ -1,6 +1,6 @@ import 'app_locale.dart'; -// ignore_for_file: type=lint +import 'app_locale.dart'; /// The translations for Russian (`ru`). class AppLocaleRu extends AppLocale { @@ -17,4 +17,14 @@ class AppLocaleRu extends AppLocale { @override String get arbEnding => 'ЗАПЯТАЯ'; -} + + // Добавленные строки + @override + String get heroDetailsTitle => 'Детали героя'; + + @override + String get heroNoImage => 'Изображение отсутствует'; + + @override + String get heroNoDescription => 'Описание отсутствует'; +} \ No newline at end of file diff --git a/lib/Components/screens/hero_detail_screen.dart b/lib/Components/screens/hero_detail_screen.dart index a644004..d9de819 100644 --- a/lib/Components/screens/hero_detail_screen.dart +++ b/lib/Components/screens/hero_detail_screen.dart @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../presentation/home_page/bloc/hero_detail_bloc.dart'; import '../../data/dtos/hero_dto.dart'; import '../../data/repositories/hero_repository.dart'; +import '../../Components/locale/l10n/app_locale.dart'; class HeroDetailScreen extends StatelessWidget { final int heroId; @@ -13,43 +14,45 @@ class HeroDetailScreen extends StatelessWidget { Widget build(BuildContext context) { final heroRepository = context.read(); + // Получаем текущую локализацию + final locale = AppLocale.of(context)!; + return BlocProvider( create: (_) => HeroDetailBloc(heroRepository)..add(FetchHeroDetails(heroId)), child: Scaffold( - appBar: AppBar(title: Text('Hero Details')), + appBar: AppBar( + title: Text(locale.heroDetailsTitle), + ), body: BlocBuilder( builder: (context, state) { if (state is HeroDetailLoading) { - return Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator()); } else if (state is HeroDetailLoaded) { final hero = state.hero; - return Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Center( - child: hero.portraitUrl != null - ? Image.network(hero.portraitUrl!, height: 150) - : Icon(Icons.image, size: 150), - ), - SizedBox(height: 16), - Text( - hero.name, - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), - ), - SizedBox(height: 16), - Text( - hero.description ?? 'No description available', - style: TextStyle(fontSize: 16), - ), - ], - ), + return Column( + children: [ + hero.portraitUrl != null + ? Image.network(hero.portraitUrl!) + : Column( + children: [ + const Icon(Icons.image, size: 100), + Text(locale.heroNoImage), + ], + ), + Text( + hero.name, + style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + Text( + hero.description ?? locale.heroNoDescription, + style: const TextStyle(fontSize: 16), + ), + ], ); } else if (state is HeroDetailError) { - return Center(child: Text('Error: ${state.message}')); + return Center(child: Text(state.message)); } - return SizedBox.shrink(); + return const SizedBox.shrink(); }, ), ), diff --git a/lib/main.dart b/lib/main.dart index 53e8297..9f149c0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,8 @@ import 'package:provider/provider.dart'; import 'presentation/home_page/bloc/hero_search_bloc.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; +import '../../Components/locale/l10n/app_locale.dart'; + @@ -47,6 +49,8 @@ class MyApp extends StatelessWidget { ); } return MaterialApp( + localizationsDelegates: AppLocale.localizationsDelegates, + supportedLocales: AppLocale.supportedLocales, home: Scaffold( body: Center( child: CircularProgressIndicator(),