-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_tab.dart
More file actions
59 lines (54 loc) · 1.4 KB
/
chat_tab.dart
File metadata and controls
59 lines (54 loc) · 1.4 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
50
51
52
53
54
55
56
57
58
59
enum ChatTabType { server, channel, query, notice, dcc }
class ChatTab {
const ChatTab({
required this.id,
required this.name,
required this.type,
required this.networkId,
this.hasActivity = false,
this.isEncrypted = false,
});
final String id;
final String name;
final ChatTabType type;
final String networkId;
final bool hasActivity;
final bool isEncrypted;
ChatTab copyWith({
String? id,
String? name,
ChatTabType? type,
String? networkId,
bool? hasActivity,
bool? isEncrypted,
}) {
return ChatTab(
id: id ?? this.id,
name: name ?? this.name,
type: type ?? this.type,
networkId: networkId ?? this.networkId,
hasActivity: hasActivity ?? this.hasActivity,
isEncrypted: isEncrypted ?? this.isEncrypted,
);
}
Map<String, Object?> toJson() {
return {
'id': id,
'name': name,
'type': type.name,
'networkId': networkId,
'hasActivity': hasActivity,
'isEncrypted': isEncrypted,
};
}
factory ChatTab.fromJson(Map<String, Object?> json) {
return ChatTab(
id: json['id']! as String,
name: json['name']! as String,
type: ChatTabType.values.byName(json['type']! as String),
networkId: json['networkId']! as String,
hasActivity: (json['hasActivity'] as bool?) ?? false,
isEncrypted: (json['isEncrypted'] as bool?) ?? false,
);
}
}