подмела мусор
This commit is contained in:
parent
e0d78af9b7
commit
793872dcab
@ -40,7 +40,6 @@ class MovieRepository extends ApiInterface {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Теперь используйте `FilmsDto.fromJson` с response.data
|
|
||||||
final MoviesDto dto = MoviesDto.fromJson(
|
final MoviesDto dto = MoviesDto.fromJson(
|
||||||
response.data as Map<String, dynamic>);
|
response.data as Map<String, dynamic>);
|
||||||
final HomeData data = dto.toDomain();
|
final HomeData data = dto.toDomain();
|
||||||
|
@ -6,6 +6,7 @@ class CardData {
|
|||||||
final int? year;
|
final int? year;
|
||||||
final List<String>? genres;
|
final List<String>? genres;
|
||||||
final List<String>? countries;
|
final List<String>? countries;
|
||||||
|
|
||||||
CardData(this.text, {
|
CardData(this.text, {
|
||||||
required this.descriptionText,
|
required this.descriptionText,
|
||||||
this.imageUrl,
|
this.imageUrl,
|
||||||
|
@ -28,9 +28,9 @@ class MyApp extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
locale: state.currentLocale, // передаем текущую локаль
|
locale: state.currentLocale,
|
||||||
localizationsDelegates: AppLocale.localizationsDelegates, // делегат (подключение локали)
|
localizationsDelegates: AppLocale.localizationsDelegates,
|
||||||
supportedLocales: AppLocale.supportedLocales, // список доступных локалей (подключение локали)
|
supportedLocales: AppLocale.supportedLocales,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme:
|
colorScheme:
|
||||||
@ -40,7 +40,7 @@ class MyApp extends StatelessWidget {
|
|||||||
home: RepositoryProvider<MovieRepository>(
|
home: RepositoryProvider<MovieRepository>(
|
||||||
lazy: true,
|
lazy: true,
|
||||||
create: (_) => MovieRepository(),
|
create: (_) => MovieRepository(),
|
||||||
child: BlocProvider<LikeBloc>( // добавили BlocProvider
|
child: BlocProvider<LikeBloc>(
|
||||||
lazy: false,
|
lazy: false,
|
||||||
create: (context) => LikeBloc(),
|
create: (context) => LikeBloc(),
|
||||||
child: BlocProvider<HomeBloc>(
|
child: BlocProvider<HomeBloc>(
|
||||||
|
@ -11,10 +11,10 @@ class DetailsPage extends StatelessWidget {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("Детали"),
|
title: Text("Детали"),
|
||||||
backgroundColor: Colors.purpleAccent, // Фиолетовый цвет для AppBar
|
backgroundColor: Colors.purpleAccent,
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
color: Colors.purple[100], // Светло-сиреневый фон для всей страницы
|
color: Colors.purple[100],
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
@ -26,12 +26,12 @@ class DetailsPage extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
data.imageUrl ?? '',
|
data.imageUrl ?? '',
|
||||||
height: 600, // Задайте фиксированную высоту для изображения
|
height: 600,
|
||||||
width: 600, // Задайте фиксированную ширину для изображения
|
width: 600,
|
||||||
fit: BoxFit.cover, // Обеспечьте хороший аспект изображения
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 16), // Промежуток между изображением и текстом
|
SizedBox(width: 16),
|
||||||
|
|
||||||
// Текст справа
|
// Текст справа
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -43,35 +43,35 @@ class DetailsPage extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
data.text,
|
data.text,
|
||||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||||
color: Colors.purple, // Простой сиреневый цвет текста заголовка
|
color: Colors.purple,
|
||||||
fontWeight: FontWeight.bold, // Жирный шрифт
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 4.0),
|
padding: const EdgeInsets.only(bottom: 4.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Год: ${data.year}', // Отображение года
|
'Год: ${data.year}',
|
||||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
color: Colors.purple[700], // Темный сиреневый цвет текста года
|
color: Colors.purple[700],
|
||||||
fontStyle: FontStyle.italic, // Курсив для выделения года
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
data.descriptionText ?? '', // Обработаем случай, если описания нет
|
data.descriptionText,
|
||||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
color: Colors.purple[600], // Темный сиреневый цвет текста описания
|
color: Colors.purple[600],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Отображение жанров
|
// Отображение жанров
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Жанры: ${data.genres?.join(', ') ?? 'Нет жанров'}', // Проверка на null
|
'Жанры: ${data.genres?.join(', ') ?? 'Нет жанров'}',
|
||||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
color: Colors.purple[600], // Темный сиреневый цвет текста жанров
|
color: Colors.purple[600],
|
||||||
fontStyle: FontStyle.italic, // Курсив для выделения жанров
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -79,10 +79,10 @@ class DetailsPage extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Страны: ${data.countries?.join(', ') ?? 'Нет стран'}', // Проверка на null
|
'Страны: ${data.countries?.join(', ') ?? 'Нет стран'}',
|
||||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
color: Colors.purple[600], // Темный сиреневый цвет текста стран
|
color: Colors.purple[600],
|
||||||
fontStyle: FontStyle.italic, // Курсив для выделения стран
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,7 +2,7 @@ part of 'home_page.dart';
|
|||||||
|
|
||||||
typedef OnLikeCallback = void Function(String? id, String title, bool isLiked)?;
|
typedef OnLikeCallback = void Function(String? id, String title, bool isLiked)?;
|
||||||
|
|
||||||
class _Card extends StatelessWidget { // состояние карточки регулируется извне; виджеты с точкой убираем
|
class _Card extends StatelessWidget {
|
||||||
final String text;
|
final String text;
|
||||||
final String descriptionText;
|
final String descriptionText;
|
||||||
final String? imageUrl;
|
final String? imageUrl;
|
||||||
|
@ -55,7 +55,7 @@ class _BodyState extends State<Body> {
|
|||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.read<HomeBloc>().add(const HomeLoadDataEvent());
|
context.read<HomeBloc>().add(const HomeLoadDataEvent());
|
||||||
context.read<LikeBloc>().add(const LoadLikesEvent()); // событие на изменение лайка
|
context.read<LikeBloc>().add(const LoadLikesEvent());
|
||||||
});
|
});
|
||||||
scrollController.addListener(_onNextPageListener);
|
scrollController.addListener(_onNextPageListener);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ class _BodyState extends State<Body> {
|
|||||||
final MovieRepository repo = MovieRepository();
|
final MovieRepository repo = MovieRepository();
|
||||||
var data = MovieRepository().loadData();
|
var data = MovieRepository().loadData();
|
||||||
|
|
||||||
void _onLike(String? id, String title, bool isLiked) { // обработчик лайков
|
void _onLike(String? id, String title, bool isLiked) {
|
||||||
print("$id $title, $isLiked");
|
print("$id $title, $isLiked");
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
context.read<LikeBloc>().add(ChangeLikeEvent(id));
|
context.read<LikeBloc>().add(ChangeLikeEvent(id));
|
||||||
@ -95,7 +95,7 @@ class _BodyState extends State<Body> {
|
|||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
' ${isLiked ? context.locale.liked : context.locale.disliked} $title', //переписали константные строки под локаль
|
' ${isLiked ? context.locale.liked : context.locale.disliked} $title',
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.orangeAccent,
|
backgroundColor: Colors.orangeAccent,
|
||||||
@ -136,10 +136,10 @@ class _BodyState extends State<Body> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12), // Отступ между полем поиска и иконкой
|
const SizedBox(width: 12),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
context.read<LocaleBloc>().add(const ChangeLocaleEvent()), // смена иконки локализации
|
context.read<LocaleBloc>().add(const ChangeLocaleEvent()),
|
||||||
child: SizedBox.square(
|
child: SizedBox.square(
|
||||||
dimension: 50,
|
dimension: 50,
|
||||||
child: BlocBuilder<LocaleBloc, LocaleState>(
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
||||||
@ -154,7 +154,7 @@ class _BodyState extends State<Body> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocBuilder<HomeBloc, HomeState>( // обертка списка с карточками
|
BlocBuilder<HomeBloc, HomeState>(
|
||||||
builder: (context, state) => state.isLoading
|
builder: (context, state) => state.isLoading
|
||||||
? CircularProgressIndicator()
|
? CircularProgressIndicator()
|
||||||
: BlocBuilder<LikeBloc, LikeState>(
|
: BlocBuilder<LikeBloc, LikeState>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user