From 6e89dcde519d8c0acb728033299e778bf17013e1 Mon Sep 17 00:00:00 2001 From: MaD Date: Tue, 17 Dec 2024 20:44:47 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=BE=D0=BB=20=D0=B4=D0=B5?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B9=20=D0=BA=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D1=87=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screens/hero_detail_screen.dart | 71 ++++++++++++------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/lib/Components/screens/hero_detail_screen.dart b/lib/Components/screens/hero_detail_screen.dart index a644004..6008d64 100644 --- a/lib/Components/screens/hero_detail_screen.dart +++ b/lib/Components/screens/hero_detail_screen.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; 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'; class HeroDetailScreen extends StatelessWidget { @@ -16,43 +15,61 @@ class HeroDetailScreen extends StatelessWidget { return BlocProvider( create: (_) => HeroDetailBloc(heroRepository)..add(FetchHeroDetails(heroId)), child: Scaffold( - appBar: AppBar(title: Text('Hero Details')), + appBar: AppBar(title: const Text('Hero Details')), 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 SingleChildScrollView( // Добавляем прокрутку + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Центрируем изображение героя + Center( + child: hero.portraitUrl != null + ? Image.network(hero.portraitUrl!, height: 150) + : const Icon(Icons.image, size: 150), + ), + const SizedBox(height: 16), + + // Имя героя + Text( + hero.name, + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 16), + + // Описание героя + Text( + hero.description ?? 'No description available', + style: const TextStyle(fontSize: 16), + ), + ], + ), ), ); } else if (state is HeroDetailError) { - return Center(child: Text('Error: ${state.message}')); + // Показ сообщения об ошибке + return Center( + child: Text( + 'Error: ${state.message}', + style: const TextStyle(fontSize: 16, color: Colors.red), + ), + ); } - return SizedBox.shrink(); + // Пустое состояние по умолчанию + return const SizedBox.shrink(); }, ), ), ); } -} \ No newline at end of file +}