~cytrogen/fluent-reader-mobile

ref: b129c7643190a9f58005ede3edd41d7ed111281e fluent-reader-mobile/lib/models/source.dart -rw-r--r-- 1.3 KiB
b129c764 — Bruce Liu fix tab bar localization update 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
enum SourceOpenTarget {
    Local, FullContent, Webpage, External
}

class RSSSource {
  String id;
  String url;
  String iconUrl;
  String name;
  SourceOpenTarget openTarget;
  int unreadCount;
  DateTime latest;
  String lastTitle;

  RSSSource(this.id, this.url, this.name) {
    openTarget = SourceOpenTarget.Local;
    latest = DateTime.now();
    unreadCount = 0;
    lastTitle = "";
  }

  RSSSource._privateConstructor(
    this.id, this.url, this.iconUrl, this.name, this.openTarget,
    this.unreadCount, this.latest, this.lastTitle,
  );

  RSSSource clone() {
    return RSSSource._privateConstructor(
      this.id, this.url, this.iconUrl, this.name, this.openTarget,
      this.unreadCount, this.latest, this.lastTitle,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      "sid": id,
      "url": url,
      "iconUrl": iconUrl,
      "name": name,
      "openTarget": openTarget.index,
      "latest": latest.millisecondsSinceEpoch,
      "lastTitle": lastTitle,
    };
  }

  RSSSource.fromMap(Map<String, dynamic> map) {
    id = map["sid"];
    url = map["url"];
    iconUrl = map["iconUrl"];
    name = map["name"];
    openTarget = SourceOpenTarget.values[map["openTarget"]];
    latest = DateTime.fromMillisecondsSinceEpoch(map["latest"]);
    lastTitle = map["lastTitle"];
    unreadCount = 0;
  }
}