add news detail page
This commit is contained in:
@@ -49,6 +49,18 @@ class NewsArticleModel {
|
||||
/// Author avatar URL (optional)
|
||||
final String? authorAvatar;
|
||||
|
||||
/// Tags/keywords for the article
|
||||
final List<String> tags;
|
||||
|
||||
/// Like count
|
||||
final int likeCount;
|
||||
|
||||
/// Comment count
|
||||
final int commentCount;
|
||||
|
||||
/// Share count
|
||||
final int shareCount;
|
||||
|
||||
/// Constructor
|
||||
const NewsArticleModel({
|
||||
required this.id,
|
||||
@@ -63,6 +75,10 @@ class NewsArticleModel {
|
||||
this.isFeatured = false,
|
||||
this.authorName,
|
||||
this.authorAvatar,
|
||||
this.tags = const [],
|
||||
this.likeCount = 0,
|
||||
this.commentCount = 0,
|
||||
this.shareCount = 0,
|
||||
});
|
||||
|
||||
/// Create model from JSON
|
||||
@@ -80,6 +96,12 @@ class NewsArticleModel {
|
||||
isFeatured: json['is_featured'] as bool? ?? false,
|
||||
authorName: json['author_name'] as String?,
|
||||
authorAvatar: json['author_avatar'] as String?,
|
||||
tags:
|
||||
(json['tags'] as List<dynamic>?)?.map((e) => e as String).toList() ??
|
||||
const [],
|
||||
likeCount: json['like_count'] as int? ?? 0,
|
||||
commentCount: json['comment_count'] as int? ?? 0,
|
||||
shareCount: json['share_count'] as int? ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,6 +120,10 @@ class NewsArticleModel {
|
||||
'is_featured': isFeatured,
|
||||
'author_name': authorName,
|
||||
'author_avatar': authorAvatar,
|
||||
'tags': tags,
|
||||
'like_count': likeCount,
|
||||
'comment_count': commentCount,
|
||||
'share_count': shareCount,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -116,6 +142,10 @@ class NewsArticleModel {
|
||||
isFeatured: isFeatured,
|
||||
authorName: authorName,
|
||||
authorAvatar: authorAvatar,
|
||||
tags: tags,
|
||||
likeCount: likeCount,
|
||||
commentCount: commentCount,
|
||||
shareCount: shareCount,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,6 +164,10 @@ class NewsArticleModel {
|
||||
isFeatured: entity.isFeatured,
|
||||
authorName: entity.authorName,
|
||||
authorAvatar: entity.authorAvatar,
|
||||
tags: entity.tags,
|
||||
likeCount: entity.likeCount,
|
||||
commentCount: entity.commentCount,
|
||||
shareCount: entity.shareCount,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user