-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_settings.dart
More file actions
49 lines (44 loc) · 1.6 KB
/
app_settings.dart
File metadata and controls
49 lines (44 loc) · 1.6 KB
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
enum NoticeRoutingMode { server, active, notice, private }
class AppSettings {
const AppSettings({
this.showRawEvents = true,
this.noticeRouting = NoticeRoutingMode.server,
this.showHeaderSearchButton = true,
this.showAttachmentPreviews = true,
});
final bool showRawEvents;
final NoticeRoutingMode noticeRouting;
final bool showHeaderSearchButton;
final bool showAttachmentPreviews;
AppSettings copyWith({
bool? showRawEvents,
NoticeRoutingMode? noticeRouting,
bool? showHeaderSearchButton,
bool? showAttachmentPreviews,
}) {
return AppSettings(
showRawEvents: showRawEvents ?? this.showRawEvents,
noticeRouting: noticeRouting ?? this.noticeRouting,
showHeaderSearchButton: showHeaderSearchButton ?? this.showHeaderSearchButton,
showAttachmentPreviews: showAttachmentPreviews ?? this.showAttachmentPreviews,
);
}
Map<String, Object?> toJson() {
return {
'showRawEvents': showRawEvents,
'noticeRouting': noticeRouting.name,
'showHeaderSearchButton': showHeaderSearchButton,
'showAttachmentPreviews': showAttachmentPreviews,
};
}
factory AppSettings.fromJson(Map<String, Object?> json) {
return AppSettings(
showRawEvents: (json['showRawEvents'] as bool?) ?? true,
noticeRouting: json['noticeRouting'] is String
? NoticeRoutingMode.values.byName(json['noticeRouting']! as String)
: NoticeRoutingMode.server,
showHeaderSearchButton: (json['showHeaderSearchButton'] as bool?) ?? true,
showAttachmentPreviews: (json['showAttachmentPreviews'] as bool?) ?? true,
);
}
}