aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models/User.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/Models/User.swift')
-rw-r--r--Hotline/Models/User.swift33
1 files changed, 33 insertions, 0 deletions
diff --git a/Hotline/Models/User.swift b/Hotline/Models/User.swift
new file mode 100644
index 0000000..9011e56
--- /dev/null
+++ b/Hotline/Models/User.swift
@@ -0,0 +1,33 @@
+import SwiftUI
+
+struct UserStatus: OptionSet {
+ let rawValue: Int
+
+ static let idle = UserStatus(rawValue: 1 << 0)
+ static let admin = UserStatus(rawValue: 1 << 1)
+}
+
+struct User: Identifiable {
+ let id: UInt
+ var name: String
+ var iconID: UInt
+ var status: UserStatus
+
+ init(hotlineUser: HotlineUser) {
+ var status: UserStatus = UserStatus()
+ if hotlineUser.isIdle { status.update(with: .idle) }
+ if hotlineUser.isAdmin { status.update(with: .admin) }
+
+ self.id = UInt(hotlineUser.id)
+ self.name = hotlineUser.name
+ self.iconID = UInt(hotlineUser.iconID)
+ self.status = status
+ }
+
+ init(id: UInt, name: String, iconID: UInt, status: UserStatus) {
+ self.id = id
+ self.name = name
+ self.iconID = iconID
+ self.status = status
+ }
+}