add likes

This commit is contained in:
mso7nueh
2024-08-19 17:41:09 +03:00
parent 026a11a6ca
commit 3761f25df4
12 changed files with 202 additions and 34 deletions

View File

@@ -16,12 +16,10 @@ class FeedBlogPostModel with _$FeedBlogPostModel {
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
required String title,
@JsonKey(name: "total_likes")
required int totalLikes,
@JsonKey(name: "total_views")
required int totalViews,
@JsonKey(name: "total_comments")
required int totalComments,
@JsonKey(name: "total_likes") required int totalLikes,
@JsonKey(name: "total_views") required int totalViews,
@JsonKey(name: "total_comments") required int totalComments,
@JsonKey(name: "was_liked_by_me") required bool wasLikedByMe,
}) = _FeedBlogPostModel;
factory FeedBlogPostModel.fromJson(Map<String, Object?> json) => _$FeedBlogPostModelFromJson(json);

View File

@@ -38,6 +38,8 @@ mixin _$FeedBlogPostModel {
int get totalViews => throw _privateConstructorUsedError;
@JsonKey(name: "total_comments")
int get totalComments => throw _privateConstructorUsedError;
@JsonKey(name: "was_liked_by_me")
bool get wasLikedByMe => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@@ -63,7 +65,8 @@ abstract class $FeedBlogPostModelCopyWith<$Res> {
String title,
@JsonKey(name: "total_likes") int totalLikes,
@JsonKey(name: "total_views") int totalViews,
@JsonKey(name: "total_comments") int totalComments});
@JsonKey(name: "total_comments") int totalComments,
@JsonKey(name: "was_liked_by_me") bool wasLikedByMe});
$AuthorCopyWith<$Res> get author;
}
@@ -93,6 +96,7 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel>
Object? totalLikes = null,
Object? totalViews = null,
Object? totalComments = null,
Object? wasLikedByMe = null,
}) {
return _then(_value.copyWith(
id: null == id
@@ -143,6 +147,10 @@ class _$FeedBlogPostModelCopyWithImpl<$Res, $Val extends FeedBlogPostModel>
? _value.totalComments
: totalComments // ignore: cast_nullable_to_non_nullable
as int,
wasLikedByMe: null == wasLikedByMe
? _value.wasLikedByMe
: wasLikedByMe // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
@@ -175,7 +183,8 @@ abstract class _$$FeedBlogPostModelImplCopyWith<$Res>
String title,
@JsonKey(name: "total_likes") int totalLikes,
@JsonKey(name: "total_views") int totalViews,
@JsonKey(name: "total_comments") int totalComments});
@JsonKey(name: "total_comments") int totalComments,
@JsonKey(name: "was_liked_by_me") bool wasLikedByMe});
@override
$AuthorCopyWith<$Res> get author;
@@ -204,6 +213,7 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res>
Object? totalLikes = null,
Object? totalViews = null,
Object? totalComments = null,
Object? wasLikedByMe = null,
}) {
return _then(_$FeedBlogPostModelImpl(
id: null == id
@@ -254,6 +264,10 @@ class __$$FeedBlogPostModelImplCopyWithImpl<$Res>
? _value.totalComments
: totalComments // ignore: cast_nullable_to_non_nullable
as int,
wasLikedByMe: null == wasLikedByMe
? _value.wasLikedByMe
: wasLikedByMe // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
@@ -273,7 +287,8 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
required this.title,
@JsonKey(name: "total_likes") required this.totalLikes,
@JsonKey(name: "total_views") required this.totalViews,
@JsonKey(name: "total_comments") required this.totalComments});
@JsonKey(name: "total_comments") required this.totalComments,
@JsonKey(name: "was_liked_by_me") required this.wasLikedByMe});
factory _$FeedBlogPostModelImpl.fromJson(Map<String, dynamic> json) =>
_$$FeedBlogPostModelImplFromJson(json);
@@ -308,10 +323,13 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
@override
@JsonKey(name: "total_comments")
final int totalComments;
@override
@JsonKey(name: "was_liked_by_me")
final bool wasLikedByMe;
@override
String toString() {
return 'FeedBlogPostModel(id: $id, state: $state, image: $image, description: $description, author: $author, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments)';
return 'FeedBlogPostModel(id: $id, state: $state, image: $image, description: $description, author: $author, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title, totalLikes: $totalLikes, totalViews: $totalViews, totalComments: $totalComments, wasLikedByMe: $wasLikedByMe)';
}
@override
@@ -337,7 +355,9 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
(identical(other.totalViews, totalViews) ||
other.totalViews == totalViews) &&
(identical(other.totalComments, totalComments) ||
other.totalComments == totalComments));
other.totalComments == totalComments) &&
(identical(other.wasLikedByMe, wasLikedByMe) ||
other.wasLikedByMe == wasLikedByMe));
}
@JsonKey(ignore: true)
@@ -355,7 +375,8 @@ class _$FeedBlogPostModelImpl implements _FeedBlogPostModel {
title,
totalLikes,
totalViews,
totalComments);
totalComments,
wasLikedByMe);
@JsonKey(ignore: true)
@override
@@ -385,7 +406,8 @@ abstract class _FeedBlogPostModel implements FeedBlogPostModel {
required final String title,
@JsonKey(name: "total_likes") required final int totalLikes,
@JsonKey(name: "total_views") required final int totalViews,
@JsonKey(name: "total_comments") required final int totalComments}) =
@JsonKey(name: "total_comments") required final int totalComments,
@JsonKey(name: "was_liked_by_me") required final bool wasLikedByMe}) =
_$FeedBlogPostModelImpl;
factory _FeedBlogPostModel.fromJson(Map<String, dynamic> json) =
@@ -422,6 +444,9 @@ abstract class _FeedBlogPostModel implements FeedBlogPostModel {
@JsonKey(name: "total_comments")
int get totalComments;
@override
@JsonKey(name: "was_liked_by_me")
bool get wasLikedByMe;
@override
@JsonKey(ignore: true)
_$$FeedBlogPostModelImplCopyWith<_$FeedBlogPostModelImpl> get copyWith =>
throw _privateConstructorUsedError;

View File

@@ -21,6 +21,7 @@ _$FeedBlogPostModelImpl _$$FeedBlogPostModelImplFromJson(
totalLikes: (json['total_likes'] as num).toInt(),
totalViews: (json['total_views'] as num).toInt(),
totalComments: (json['total_comments'] as num).toInt(),
wasLikedByMe: json['was_liked_by_me'] as bool,
);
Map<String, dynamic> _$$FeedBlogPostModelImplToJson(
@@ -38,4 +39,5 @@ Map<String, dynamic> _$$FeedBlogPostModelImplToJson(
'total_likes': instance.totalLikes,
'total_views': instance.totalViews,
'total_comments': instance.totalComments,
'was_liked_by_me': instance.wasLikedByMe,
};