|
| 1 | +enum NoticeRoutingMode { server, active, notice, private } |
| 2 | + |
1 | 3 | class AppSettings { |
2 | 4 | const AppSettings({ |
3 | 5 | this.showRawEvents = true, |
| 6 | + this.noticeRouting = NoticeRoutingMode.server, |
| 7 | + this.showHeaderSearchButton = true, |
| 8 | + this.showAttachmentPreviews = true, |
4 | 9 | }); |
5 | 10 |
|
6 | 11 | final bool showRawEvents; |
| 12 | + final NoticeRoutingMode noticeRouting; |
| 13 | + final bool showHeaderSearchButton; |
| 14 | + final bool showAttachmentPreviews; |
7 | 15 |
|
8 | 16 | AppSettings copyWith({ |
9 | 17 | bool? showRawEvents, |
| 18 | + NoticeRoutingMode? noticeRouting, |
| 19 | + bool? showHeaderSearchButton, |
| 20 | + bool? showAttachmentPreviews, |
10 | 21 | }) { |
11 | 22 | return AppSettings( |
12 | 23 | showRawEvents: showRawEvents ?? this.showRawEvents, |
| 24 | + noticeRouting: noticeRouting ?? this.noticeRouting, |
| 25 | + showHeaderSearchButton: showHeaderSearchButton ?? this.showHeaderSearchButton, |
| 26 | + showAttachmentPreviews: showAttachmentPreviews ?? this.showAttachmentPreviews, |
13 | 27 | ); |
14 | 28 | } |
15 | 29 |
|
16 | 30 | Map<String, Object?> toJson() { |
17 | 31 | return { |
18 | 32 | 'showRawEvents': showRawEvents, |
| 33 | + 'noticeRouting': noticeRouting.name, |
| 34 | + 'showHeaderSearchButton': showHeaderSearchButton, |
| 35 | + 'showAttachmentPreviews': showAttachmentPreviews, |
19 | 36 | }; |
20 | 37 | } |
21 | 38 |
|
22 | 39 | factory AppSettings.fromJson(Map<String, Object?> json) { |
23 | 40 | return AppSettings( |
24 | 41 | showRawEvents: (json['showRawEvents'] as bool?) ?? true, |
| 42 | + noticeRouting: json['noticeRouting'] is String |
| 43 | + ? NoticeRoutingMode.values.byName(json['noticeRouting']! as String) |
| 44 | + : NoticeRoutingMode.server, |
| 45 | + showHeaderSearchButton: (json['showHeaderSearchButton'] as bool?) ?? true, |
| 46 | + showAttachmentPreviews: (json['showAttachmentPreviews'] as bool?) ?? true, |
25 | 47 | ); |
26 | 48 | } |
27 | 49 | } |
0 commit comments