7 lab final
This commit is contained in:
parent
c7ed4b4e5c
commit
b930d28d54
@ -3,6 +3,6 @@
|
||||
|
||||
"search": "Search",
|
||||
"liked": "liked!",
|
||||
"unliked": "unliked"
|
||||
"disliked": "unliked"
|
||||
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ class AppLocaleEn extends AppLocale {
|
||||
String get liked => 'liked!';
|
||||
|
||||
@override
|
||||
String get disliked => 'разонравился';
|
||||
String get disliked => 'unliked';
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ class MangaPaginationDto {
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class MangaDataDto {
|
||||
final String? id;
|
||||
@JsonKey(name: "mal_id")
|
||||
final int? id;
|
||||
final String? type;
|
||||
final String? title;
|
||||
final String? status;
|
||||
|
@ -31,7 +31,7 @@ MangaDataDto _$MangaDataDtoFromJson(Map<String, dynamic> json) => MangaDataDto(
|
||||
json['images'] == null
|
||||
? null
|
||||
: MangaDataImagesDto.fromJson(json['images'] as Map<String, dynamic>),
|
||||
id: json['id'] as String?,
|
||||
id: (json['mal_id'] as num?)?.toInt(),
|
||||
type: json['type'] as String?,
|
||||
);
|
||||
|
||||
|
@ -6,6 +6,7 @@ extension MangaDataDtoMapper on MangaDataDto {
|
||||
CardData toDomain() => CardData(
|
||||
title ?? 'UNKNOWN',
|
||||
imageUrl: images?.jpg?.image_url,
|
||||
id: id.toString(),
|
||||
descriptionText:
|
||||
'Статус: ${status}. Рейтинг: ${score}. Людей поставило оценку: ${scored_by}',
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app/components/extension/context_x.dart';
|
||||
import 'package:flutter_app/components/utils/debounce.dart';
|
||||
import 'package:flutter_app/data/repositories/manga_repository.dart';
|
||||
import 'package:flutter_app/presentation/details_page/details_page.dart';
|
||||
@ -63,7 +64,7 @@ class _BodyState extends State<Body> {
|
||||
}
|
||||
|
||||
void _onNextPageListener() {
|
||||
if (scrollController.offset > scrollController.position.maxScrollExtent) {
|
||||
if (scrollController.offset >= scrollController.position.maxScrollExtent) {
|
||||
final bloc = context.read<HomeBloc>();
|
||||
if (!bloc.state.isPaginationLoading) {
|
||||
bloc.add(HomeLoadDataEvent(
|
||||
@ -84,6 +85,7 @@ class _BodyState extends State<Body> {
|
||||
var data = MangaRepository().loadData();
|
||||
|
||||
void _onLike(String? id, String title, bool isLiked) {
|
||||
print("$id $title, $isLiked");
|
||||
if (id != null) {
|
||||
context.read<LikeBloc>().add(ChangeLikeEvent(id));
|
||||
_showSnackBar(context, title, !isLiked);
|
||||
@ -94,7 +96,7 @@ class _BodyState extends State<Body> {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
'Лайк на $title ${isLiked ? 'поставлен' : 'убран'}',
|
||||
' ${isLiked ? context.locale.liked : context.locale.disliked} $title',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
backgroundColor: Colors.orangeAccent,
|
||||
@ -163,6 +165,9 @@ class _BodyState extends State<Body> {
|
||||
return data != null
|
||||
? _Card.fromData(
|
||||
data,
|
||||
isLiked: likeState.likedIds
|
||||
?.contains(data.id) ==
|
||||
true,
|
||||
onLike: _onLike,
|
||||
onTap: () =>
|
||||
_navToDetails(context, data),
|
||||
|
@ -27,7 +27,8 @@ class _$LocaleStateCWProxyImpl implements _$LocaleStateCWProxy {
|
||||
final LocaleState _value;
|
||||
|
||||
@override
|
||||
LocaleState currentLocale(Locale currentLocale) => this(currentLocale: currentLocale);
|
||||
LocaleState currentLocale(Locale currentLocale) =>
|
||||
this(currentLocale: currentLocale);
|
||||
|
||||
@override
|
||||
|
||||
@ -41,7 +42,8 @@ class _$LocaleStateCWProxyImpl implements _$LocaleStateCWProxy {
|
||||
Object? currentLocale = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return LocaleState(
|
||||
currentLocale: currentLocale == const $CopyWithPlaceholder() || currentLocale == null
|
||||
currentLocale:
|
||||
currentLocale == const $CopyWithPlaceholder() || currentLocale == null
|
||||
? _value.currentLocale
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: currentLocale as Locale,
|
||||
|
@ -178,7 +178,7 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
copy_with_extension:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: copy_with_extension
|
||||
sha256: fbcf890b0c34aedf0894f91a11a579994b61b4e04080204656b582708b5b1125
|
||||
|
@ -20,6 +20,7 @@ dependencies:
|
||||
equatable: ^2.0.5
|
||||
flutter_bloc: ^8.1.5
|
||||
copy_with_extension_gen: ^5.0.4
|
||||
copy_with_extension: ^5.0.4
|
||||
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
Loading…
Reference in New Issue
Block a user