forked from eatvio/eatvio_app
feat(feed): comments + redesign blogPost
This commit is contained in:
67
lib/features/feed/models/comment_model.dart
Normal file
67
lib/features/feed/models/comment_model.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'comment_model.freezed.dart';
|
||||
part 'comment_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class Comment with _$Comment {
|
||||
const factory Comment({
|
||||
@JsonKey(name: "data") required List<Datum> data,
|
||||
@JsonKey(name: "links") required Links links,
|
||||
@JsonKey(name: "meta") required Meta meta,
|
||||
}) = _Comment;
|
||||
|
||||
factory Comment.fromJson(Map<String, Object?> json) => _$CommentFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Datum with _$Datum {
|
||||
const factory Datum({
|
||||
@JsonKey(name: "id") required int id,
|
||||
@JsonKey(name: "author_name") required String authorName,
|
||||
@JsonKey(name: "author_profile_icon") required String authorProfileIcon,
|
||||
@JsonKey(name: "body") required String body,
|
||||
@JsonKey(name: "children_comments") required List<Datum> childrenComments,
|
||||
}) = _Datum;
|
||||
|
||||
factory Datum.fromJson(Map<String, Object?> json) => _$DatumFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Links with _$Links {
|
||||
const factory Links({
|
||||
@JsonKey(name: "first") required String first,
|
||||
@JsonKey(name: "last") required String last,
|
||||
@JsonKey(name: "prev") required dynamic prev,
|
||||
@JsonKey(name: "next") required dynamic next,
|
||||
}) = _Links;
|
||||
|
||||
factory Links.fromJson(Map<String, Object?> json) => _$LinksFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Meta with _$Meta {
|
||||
const factory Meta({
|
||||
@JsonKey(name: "current_page") required int currentPage,
|
||||
@JsonKey(name: "from") required int from,
|
||||
@JsonKey(name: "last_page") required int lastPage,
|
||||
@JsonKey(name: "links") required List<Link> links,
|
||||
@JsonKey(name: "path") required String path,
|
||||
@JsonKey(name: "per_page") required int perPage,
|
||||
@JsonKey(name: "to") required int to,
|
||||
@JsonKey(name: "total") required int total,
|
||||
}) = _Meta;
|
||||
|
||||
factory Meta.fromJson(Map<String, Object?> json) => _$MetaFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class Link with _$Link {
|
||||
const factory Link({
|
||||
@JsonKey(name: "url") required String? url,
|
||||
@JsonKey(name: "label") required String label,
|
||||
@JsonKey(name: "active") required bool active,
|
||||
}) = _Link;
|
||||
|
||||
factory Link.fromJson(Map<String, Object?> json) => _$LinkFromJson(json);
|
||||
}
|
||||
1188
lib/features/feed/models/comment_model.freezed.dart
Normal file
1188
lib/features/feed/models/comment_model.freezed.dart
Normal file
File diff suppressed because it is too large
Load Diff
95
lib/features/feed/models/comment_model.g.dart
Normal file
95
lib/features/feed/models/comment_model.g.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'comment_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CommentImpl _$$CommentImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CommentImpl(
|
||||
data: (json['data'] as List<dynamic>)
|
||||
.map((e) => Datum.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
links: Links.fromJson(json['links'] as Map<String, dynamic>),
|
||||
meta: Meta.fromJson(json['meta'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CommentImplToJson(_$CommentImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'data': instance.data,
|
||||
'links': instance.links,
|
||||
'meta': instance.meta,
|
||||
};
|
||||
|
||||
_$DatumImpl _$$DatumImplFromJson(Map<String, dynamic> json) => _$DatumImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
authorName: json['author_name'] as String,
|
||||
authorProfileIcon: json['author_profile_icon'] as String,
|
||||
body: json['body'] as String,
|
||||
childrenComments: (json['children_comments'] as List<dynamic>)
|
||||
.map((e) => Datum.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$DatumImplToJson(_$DatumImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'author_name': instance.authorName,
|
||||
'author_profile_icon': instance.authorProfileIcon,
|
||||
'body': instance.body,
|
||||
'children_comments': instance.childrenComments,
|
||||
};
|
||||
|
||||
_$LinksImpl _$$LinksImplFromJson(Map<String, dynamic> json) => _$LinksImpl(
|
||||
first: json['first'] as String,
|
||||
last: json['last'] as String,
|
||||
prev: json['prev'],
|
||||
next: json['next'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$LinksImplToJson(_$LinksImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'first': instance.first,
|
||||
'last': instance.last,
|
||||
'prev': instance.prev,
|
||||
'next': instance.next,
|
||||
};
|
||||
|
||||
_$MetaImpl _$$MetaImplFromJson(Map<String, dynamic> json) => _$MetaImpl(
|
||||
currentPage: (json['current_page'] as num).toInt(),
|
||||
from: (json['from'] as num).toInt(),
|
||||
lastPage: (json['last_page'] as num).toInt(),
|
||||
links: (json['links'] as List<dynamic>)
|
||||
.map((e) => Link.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
path: json['path'] as String,
|
||||
perPage: (json['per_page'] as num).toInt(),
|
||||
to: (json['to'] as num).toInt(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$MetaImplToJson(_$MetaImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'current_page': instance.currentPage,
|
||||
'from': instance.from,
|
||||
'last_page': instance.lastPage,
|
||||
'links': instance.links,
|
||||
'path': instance.path,
|
||||
'per_page': instance.perPage,
|
||||
'to': instance.to,
|
||||
'total': instance.total,
|
||||
};
|
||||
|
||||
_$LinkImpl _$$LinkImplFromJson(Map<String, dynamic> json) => _$LinkImpl(
|
||||
url: json['url'] as String?,
|
||||
label: json['label'] as String,
|
||||
active: json['active'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$LinkImplToJson(_$LinkImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'url': instance.url,
|
||||
'label': instance.label,
|
||||
'active': instance.active,
|
||||
};
|
||||
Reference in New Issue
Block a user