скрол детальной карочки
This commit is contained in:
parent
aececde5c2
commit
6e89dcde51
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import '../../presentation/home_page/bloc/hero_detail_bloc.dart';
|
import '../../presentation/home_page/bloc/hero_detail_bloc.dart';
|
||||||
import '../../data/dtos/hero_dto.dart';
|
|
||||||
import '../../data/repositories/hero_repository.dart';
|
import '../../data/repositories/hero_repository.dart';
|
||||||
|
|
||||||
class HeroDetailScreen extends StatelessWidget {
|
class HeroDetailScreen extends StatelessWidget {
|
||||||
@ -16,40 +15,58 @@ class HeroDetailScreen extends StatelessWidget {
|
|||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => HeroDetailBloc(heroRepository)..add(FetchHeroDetails(heroId)),
|
create: (_) => HeroDetailBloc(heroRepository)..add(FetchHeroDetails(heroId)),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(title: Text('Hero Details')),
|
appBar: AppBar(title: const Text('Hero Details')),
|
||||||
body: BlocBuilder<HeroDetailBloc, HeroDetailState>(
|
body: BlocBuilder<HeroDetailBloc, HeroDetailState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is HeroDetailLoading) {
|
if (state is HeroDetailLoading) {
|
||||||
return Center(child: CircularProgressIndicator());
|
// Показ индикатора загрузки
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is HeroDetailLoaded) {
|
} else if (state is HeroDetailLoaded) {
|
||||||
final hero = state.hero;
|
final hero = state.hero;
|
||||||
return Padding(
|
return SingleChildScrollView( // Добавляем прокрутку
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
// Центрируем изображение героя
|
||||||
Center(
|
Center(
|
||||||
child: hero.portraitUrl != null
|
child: hero.portraitUrl != null
|
||||||
? Image.network(hero.portraitUrl!, height: 150)
|
? Image.network(hero.portraitUrl!, height: 150)
|
||||||
: Icon(Icons.image, size: 150),
|
: const Icon(Icons.image, size: 150),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Имя героя
|
||||||
Text(
|
Text(
|
||||||
hero.name,
|
hero.name,
|
||||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Описание героя
|
||||||
Text(
|
Text(
|
||||||
hero.description ?? 'No description available',
|
hero.description ?? 'No description available',
|
||||||
style: TextStyle(fontSize: 16),
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else if (state is HeroDetailError) {
|
} 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();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user