aboutsummaryrefslogtreecommitdiff
path: root/Hotline
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-10-28 10:12:49 -0700
committerDustin Mierau <dustin@mierau.me>2025-10-28 10:12:49 -0700
commit8fdad8745921ea0bc43a9efd2beafc1a1ce3142b (patch)
treea5d03d185578774835da5b4e4264647206c0ad4e /Hotline
parentc5165d348c1efbcc553b3c31dbeaa23353914fb6 (diff)
Pop ServerState out into its own file.
Diffstat (limited to 'Hotline')
-rw-r--r--Hotline/State/ServerState.swift44
-rw-r--r--Hotline/macOS/ServerView.swift71
2 files changed, 46 insertions, 69 deletions
diff --git a/Hotline/State/ServerState.swift b/Hotline/State/ServerState.swift
new file mode 100644
index 0000000..e2fa40f
--- /dev/null
+++ b/Hotline/State/ServerState.swift
@@ -0,0 +1,44 @@
+import SwiftUI
+
+@Observable
+class ServerState: Equatable {
+ var id: UUID = UUID()
+ var selection: ServerNavigationType
+ var serverName: String? = nil
+ var serverBanner: NSImage? = nil
+ var bannerColors: ColorArt? = nil
+
+ init(selection: ServerNavigationType) {
+ self.selection = selection
+ }
+
+ static func == (lhs: ServerState, rhs: ServerState) -> Bool {
+ return lhs.id == rhs.id
+ }
+}
+
+enum ServerNavigationType: Identifiable, Hashable, Equatable {
+ var id: String {
+ switch self {
+ case .chat:
+ return "Chat"
+ case .news:
+ return "News"
+ case .board:
+ return "Board"
+ case .files:
+ return "Files"
+ case .accounts:
+ return "Accounts"
+ case .user(let userID):
+ return String(userID)
+ }
+ }
+
+ case chat
+ case news
+ case board
+ case files
+ case accounts
+ case user(userID: UInt16)
+}
diff --git a/Hotline/macOS/ServerView.swift b/Hotline/macOS/ServerView.swift
index 6d5743c..e18d630 100644
--- a/Hotline/macOS/ServerView.swift
+++ b/Hotline/macOS/ServerView.swift
@@ -2,32 +2,6 @@ import SwiftUI
import UniformTypeIdentifiers
import AppKit
-@Observable
-class ServerState: Equatable {
- var id: UUID = UUID()
- var selection: ServerNavigationType
- var serverName: String? = nil
- var serverBanner: NSImage? = nil
- var bannerColors: ColorArt? = nil
-
- init(selection: ServerNavigationType) {
- self.selection = selection
- }
-
- static func == (lhs: ServerState, rhs: ServerState) -> Bool {
- return lhs.id == rhs.id
- }
-}
-
-enum MenuItemType {
- case chat
- case news
- case messageBoard
- case files
- case tasks
- case user
-}
-
struct ServerMenuItem: Identifiable, Hashable {
let id: UUID
let type: ServerNavigationType
@@ -94,50 +68,9 @@ struct ListItemView: View {
}
}
-struct ActiveHotlineModelFocusedValueKey: FocusedValueKey {
- typealias Value = Hotline
-}
-
-struct ActiveServerStateFocusedValueKey: FocusedValueKey {
- typealias Value = ServerState
-}
-
extension FocusedValues {
- var activeHotlineModel: Hotline? {
- get { self[ActiveHotlineModelFocusedValueKey.self] }
- set { self[ActiveHotlineModelFocusedValueKey.self] = newValue }
- }
-
- var activeServerState: ServerState? {
- get { self[ActiveServerStateFocusedValueKey.self] }
- set { self[ActiveServerStateFocusedValueKey.self] = newValue }
- }
-}
-
-enum ServerNavigationType: Identifiable, Hashable, Equatable {
- var id: String {
- switch self {
- case .chat:
- return "Chat"
- case .news:
- return "News"
- case .board:
- return "Board"
- case .files:
- return "Files"
- case .accounts:
- return "Accounts"
- case .user(let userID):
- return String(userID)
- }
- }
-
- case chat
- case news
- case board
- case files
- case accounts
- case user(userID: UInt16)
+ @Entry var activeHotlineModel: Hotline?
+ @Entry var activeServerState: ServerState?
}
struct ServerView: View {