Files
fcs/lib/vo/notification.dart
2020-05-29 07:45:27 +06:30

50 lines
1.1 KiB
Dart

import 'package:cloud_firestore/cloud_firestore.dart';
class Notification {
String id;
String itemID;
String itemNumber;
String itemType;
String desc;
DateTime time;
bool seen;
Notification(
{this.id,
this.itemID,
this.itemNumber,
this.itemType,
this.desc,
this.time,
this.seen});
String get getDesc =>
desc != null && desc.length > 30 ? desc.substring(0, 30) : desc;
bool fromToday() {
var now = DateTime.now();
return time.day == now.day &&
time.month == now.month &&
time.year == now.year;
}
factory Notification.fromMap(Map<String, dynamic> map, String id) {
var _time = (map['time'] as Timestamp);
return Notification(
id: id,
time: _time?.toDate(),
itemID: map['item_id'],
itemNumber: map['item_number'],
itemType: map['item_type'],
desc: map['desc'],
seen: map['seen'],
);
}
@override
String toString() {
return 'Notification{id:$id,itemID:$itemID,itemNumber:$itemNumber,itemType:$itemType,desc:$desc,seen:$seen}';
}
}