add structure

This commit is contained in:
2020-05-29 07:45:27 +06:30
parent 4c851d9971
commit bad27ba5c4
272 changed files with 36065 additions and 174 deletions

49
lib/vo/notification.dart Normal file
View File

@@ -0,0 +1,49 @@
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}';
}
}