Files
oott/frontend/lib/model/notification.dart
T
rzuastiandClaude Sonnet 4.6 527e2bd6c8 Style notification list items by read/unread status
Unread notifications (isNew=true) now show a secondaryContainer background,
bold title, and primary-colored icon per Material 3 guidelines. State changes
via mark-as-read/unread update the item's styling immediately in the All filter
view using mapItems with a copyWith, ensuring PagingStateBase's deep equality
check detects the change and triggers a rebuild.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 11:00:46 -04:00

48 lines
1.1 KiB
Dart

import 'notification_type.dart';
class Notification {
int id;
String title;
String body;
bool isNew;
NotificationType notificationType;
DateTime createdOn;
Notification({
required this.id,
required this.title,
required this.body,
required this.notificationType,
required this.createdOn,
this.isNew = true,
});
Notification.fromJson(Map<String, dynamic> json)
: id = json['id'] as int,
createdOn = DateTime.parse(json['created_on'] as String),
notificationType = NotificationType.fromString(
json['notification_type'] as String,
),
title = json['title'] as String,
body = json['body'] as String,
isNew = json['is_new'] as bool;
Notification copyWith({bool? isNew}) => Notification(
id: id,
title: title,
body: body,
notificationType: notificationType,
createdOn: createdOn,
isNew: isNew ?? this.isNew,
);
Map<String, dynamic> toJson() => {
'id': id,
'created_on': createdOn.toUtc().toIso8601String(),
'notification_type': notificationType.toString,
'title': title,
'body': body,
'is_new': isNew,
};
}