diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-12 16:29:12 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-12 16:29:12 -0800 |
| commit | a428e3e28fb851cec65ff27f212c19bce08e5369 (patch) | |
| tree | d106ce73c1411dff56f401f3a9df62419c8d4f58 /Hotline/Models/User.swift | |
| parent | a4798840e1d58ddb19ed5d5e0e0a4f0add47c9fb (diff) | |
Break model objects out into their own files.
Diffstat (limited to 'Hotline/Models/User.swift')
| -rw-r--r-- | Hotline/Models/User.swift | 33 |
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 + } +} |