blob: 90b08014b7e84dc715331db9da9b78aadd77d70b (
plain)
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
|
import SwiftUI
struct UserStatus: OptionSet {
let rawValue: UInt
static let idle = UserStatus(rawValue: 1 << 0)
static let admin = UserStatus(rawValue: 1 << 1)
}
struct User: Identifiable {
var id: UInt16
var name: String
var iconID: UInt
var status: UserStatus
var isAdmin: Bool { self.status.contains(.admin) }
var isIdle: Bool { self.status.contains(.idle) }
init(hotlineUser: HotlineUser) {
var status: UserStatus = UserStatus()
if hotlineUser.isIdle { status.update(with: .idle) }
if hotlineUser.isAdmin { status.update(with: .admin) }
self.id = hotlineUser.id
self.name = hotlineUser.name
self.iconID = UInt(hotlineUser.iconID)
self.status = status
}
init(id: UInt16, name: String, iconID: UInt, status: UserStatus) {
self.id = id
self.name = name
self.iconID = iconID
self.status = status
}
}
|