~cytrogen/fluent-reader-mobile

fluent-reader-mobile/lib/models/item.dart -rw-r--r-- 1.4 KiB
28b99e81 — Cytrogen feat: add subscription search/sort, rewrite README, upgrade infrastructure 9 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class RSSItem {
  String id;
  String source;
  String title;
  String link;
  DateTime date;
  String content;
  String snippet;
  bool hasRead;
  bool starred;
  String creator;
  String? thumb;

  RSSItem({
    required this.id, required this.source, required this.title,
    required this.link, required this.date,
    required this.content, required this.snippet,
    required this.hasRead, required this.starred,
    this.creator = "", this.thumb
  });

  RSSItem clone() {
    return RSSItem(
      id: id, source: source, title: title, link: link, date: date,
      content: content, snippet: snippet, hasRead: hasRead, starred: starred,
      creator: creator, thumb: thumb,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      "iid": id,
      "source": source,
      "title": title,
      "link": link,
      "date": date.millisecondsSinceEpoch,
      "content": content,
      "snippet": snippet,
      "hasRead": hasRead ? 1 : 0,
      "starred": starred ? 1 : 0,
      "creator": creator,
      "thumb": thumb,
    };
  }

  RSSItem.fromMap(Map<String, dynamic> map)
    : id = map["iid"],
      source = map["source"],
      title = map["title"],
      link = map["link"],
      date = DateTime.fromMillisecondsSinceEpoch(map["date"]),
      content = map["content"],
      snippet = map["snippet"],
      hasRead = map["hasRead"] != 0,
      starred = map["starred"] != 0,
      creator = map["creator"] ?? "",
      thumb = map["thumb"];
}