~cytrogen/fluent-reader-mobile

ref: 35bca6d1825ff682e3b811a9f24e6865d96b0f08 fluent-reader-mobile/lib/models/item.dart -rw-r--r-- 1.3 KiB
35bca6d1 — Bruce Liu update localizations 5 years 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
class RSSItem {
  String id;
  String source;
  String title;
  String link;
  DateTime date;
  String content;
  String snippet;
  bool hasRead;
  bool starred;
  String creator; // Optional
  String thumb; // Optional

  RSSItem({
    this.id, this.source, this.title, this.link, this.date,
    this.content, this.snippet, this.hasRead, 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"];
  }
}