From a428e3e28fb851cec65ff27f212c19bce08e5369 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 12 Dec 2023 16:29:12 -0800 Subject: Break model objects out into their own files. --- Hotline/Models/User.swift | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Hotline/Models/User.swift (limited to 'Hotline/Models/User.swift') 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 + } +} -- cgit