Files
fcs/lib/vo/notification.dart

54 lines
1.1 KiB
Dart
Raw Normal View History

2020-05-29 07:45:27 +06:30
import 'package:cloud_firestore/cloud_firestore.dart';
class Notification {
String id;
String itemID;
String itemNumber;
String itemType;
String desc;
DateTime time;
bool seen;
2020-05-29 16:14:17 +06:30
String marketPlace;
String status;
2020-05-29 07:45:27 +06:30
Notification(
{this.id,
this.itemID,
this.itemNumber,
this.itemType,
this.desc,
this.time,
2020-05-29 16:14:17 +06:30
this.seen,
this.marketPlace,
this.status});
2020-05-29 07:45:27 +06:30
String get getDesc =>
desc != null && desc.length > 30 ? desc.substring(0, 30) : desc;
2020-05-29 16:14:17 +06:30
2020-05-29 07:45:27 +06:30
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}';
}
}