add news detail page

This commit is contained in:
Phuoc Nguyen
2025-11-03 13:37:33 +07:00
parent ea485d8c3a
commit 56c470baa1
9 changed files with 1614 additions and 94 deletions

View File

@@ -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