add noti
This commit is contained in:
@@ -100,6 +100,32 @@ class Notification {
|
||||
return timeSinceCreated.inDays > 7;
|
||||
}
|
||||
|
||||
/// Get formatted time ago text (Vietnamese)
|
||||
String get formattedTimeAgo {
|
||||
final duration = timeSinceCreated;
|
||||
|
||||
if (duration.inMinutes < 1) {
|
||||
return 'Vừa xong';
|
||||
} else if (duration.inMinutes < 60) {
|
||||
return '${duration.inMinutes} phút trước';
|
||||
} else if (duration.inHours < 24) {
|
||||
return '${duration.inHours} giờ trước';
|
||||
} else if (duration.inDays == 1) {
|
||||
return 'Hôm qua';
|
||||
} else if (duration.inDays < 7) {
|
||||
return '${duration.inDays} ngày trước';
|
||||
} else if (duration.inDays < 30) {
|
||||
final weeks = (duration.inDays / 7).floor();
|
||||
return '$weeks tuần trước';
|
||||
} else if (duration.inDays < 365) {
|
||||
final months = (duration.inDays / 30).floor();
|
||||
return '$months tháng trước';
|
||||
} else {
|
||||
final years = (duration.inDays / 365).floor();
|
||||
return '$years năm trước';
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy with method for immutability
|
||||
Notification copyWith({
|
||||
String? notificationId,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/// Notification Repository Interface
|
||||
///
|
||||
/// Defines operations for managing notifications.
|
||||
library;
|
||||
|
||||
import 'package:worker/features/notifications/domain/entities/notification.dart';
|
||||
|
||||
/// Notification Repository
|
||||
///
|
||||
/// Provides methods to:
|
||||
/// - Fetch notifications (all, by category, unread)
|
||||
/// - Mark notifications as read
|
||||
/// - Get notification counts
|
||||
abstract class NotificationRepository {
|
||||
/// Get all notifications
|
||||
Future<List<Notification>> getAllNotifications();
|
||||
|
||||
/// Get notifications by category (general or order)
|
||||
Future<List<Notification>> getNotificationsByCategory(String category);
|
||||
|
||||
/// Get unread notifications count
|
||||
Future<int> getUnreadCount();
|
||||
|
||||
/// Mark notification as read
|
||||
Future<void> markAsRead(String notificationId);
|
||||
|
||||
/// Mark all notifications as read
|
||||
Future<void> markAllAsRead();
|
||||
|
||||
/// Refresh notifications (fetch from server)
|
||||
Future<List<Notification>> refreshNotifications();
|
||||
}
|
||||
Reference in New Issue
Block a user