add news detail page
This commit is contained in:
@@ -45,6 +45,18 @@ class NewsArticle {
|
||||
/// 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 NewsArticle({
|
||||
required this.id,
|
||||
@@ -59,6 +71,10 @@ class NewsArticle {
|
||||
this.isFeatured = false,
|
||||
this.authorName,
|
||||
this.authorAvatar,
|
||||
this.tags = const [],
|
||||
this.likeCount = 0,
|
||||
this.commentCount = 0,
|
||||
this.shareCount = 0,
|
||||
});
|
||||
|
||||
/// Get formatted publication date (dd/MM/yyyy)
|
||||
@@ -93,6 +109,10 @@ class NewsArticle {
|
||||
bool? isFeatured,
|
||||
String? authorName,
|
||||
String? authorAvatar,
|
||||
List<String>? tags,
|
||||
int? likeCount,
|
||||
int? commentCount,
|
||||
int? shareCount,
|
||||
}) {
|
||||
return NewsArticle(
|
||||
id: id ?? this.id,
|
||||
@@ -107,6 +127,10 @@ class NewsArticle {
|
||||
isFeatured: isFeatured ?? this.isFeatured,
|
||||
authorName: authorName ?? this.authorName,
|
||||
authorAvatar: authorAvatar ?? this.authorAvatar,
|
||||
tags: tags ?? this.tags,
|
||||
likeCount: likeCount ?? this.likeCount,
|
||||
commentCount: commentCount ?? this.commentCount,
|
||||
shareCount: shareCount ?? this.shareCount,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,38 +139,13 @@ class NewsArticle {
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is NewsArticle &&
|
||||
other.id == id &&
|
||||
other.title == title &&
|
||||
other.excerpt == excerpt &&
|
||||
other.content == content &&
|
||||
other.imageUrl == imageUrl &&
|
||||
other.category == category &&
|
||||
other.publishedDate == publishedDate &&
|
||||
other.viewCount == viewCount &&
|
||||
other.readingTimeMinutes == readingTimeMinutes &&
|
||||
other.isFeatured == isFeatured &&
|
||||
other.authorName == authorName &&
|
||||
other.authorAvatar == authorAvatar;
|
||||
return other is NewsArticle && other.id == id;
|
||||
}
|
||||
|
||||
/// Hash code
|
||||
@override
|
||||
int get hashCode {
|
||||
return Object.hash(
|
||||
id,
|
||||
title,
|
||||
excerpt,
|
||||
content,
|
||||
imageUrl,
|
||||
category,
|
||||
publishedDate,
|
||||
viewCount,
|
||||
readingTimeMinutes,
|
||||
isFeatured,
|
||||
authorName,
|
||||
authorAvatar,
|
||||
);
|
||||
return id.hashCode;
|
||||
}
|
||||
|
||||
/// String representation
|
||||
|
||||
Reference in New Issue
Block a user