aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Hotline.xcodeproj/project.pbxproj4
-rw-r--r--Hotline/State/ServerState.swift44
-rw-r--r--Hotline/macOS/ServerView.swift71
3 files changed, 50 insertions, 69 deletions
diff --git a/Hotline.xcodeproj/project.pbxproj b/Hotline.xcodeproj/project.pbxproj
index 5c0b943..03f170c 100644
--- a/Hotline.xcodeproj/project.pbxproj
+++ b/Hotline.xcodeproj/project.pbxproj
@@ -33,6 +33,7 @@
DA5268A32EB0741B00DCB941 /* FolderItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5268A22EB0741B00DCB941 /* FolderItemView.swift */; platformFilters = (macos, ); };
DA5268A52EB0743000DCB941 /* FileItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5268A42EB0743000DCB941 /* FileItemView.swift */; platformFilters = (macos, ); };
DA5268AB2EB11EA300DCB941 /* ColorArt.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5268AA2EB11EA300DCB941 /* ColorArt.swift */; };
+ DA5268AD2EB12FE200DCB941 /* ServerState.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5268AC2EB12FE200DCB941 /* ServerState.swift */; };
DA55AC732BE42AF000034857 /* AsyncLinkPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55AC722BE42AF000034857 /* AsyncLinkPreview.swift */; platformFilters = (macos, ); };
DA55AC752BE4888300034857 /* InstantMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55AC742BE4888300034857 /* InstantMessage.swift */; };
DA55AC772BE589F700034857 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55AC762BE589F700034857 /* AboutView.swift */; platformFilters = (macos, ); };
@@ -130,6 +131,7 @@
DA5268A22EB0741B00DCB941 /* FolderItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderItemView.swift; sourceTree = "<group>"; };
DA5268A42EB0743000DCB941 /* FileItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileItemView.swift; sourceTree = "<group>"; };
DA5268AA2EB11EA300DCB941 /* ColorArt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorArt.swift; sourceTree = "<group>"; };
+ DA5268AC2EB12FE200DCB941 /* ServerState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerState.swift; sourceTree = "<group>"; };
DA55AC722BE42AF000034857 /* AsyncLinkPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncLinkPreview.swift; sourceTree = "<group>"; };
DA55AC742BE4888300034857 /* InstantMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantMessage.swift; sourceTree = "<group>"; };
DA55AC762BE589F700034857 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
@@ -214,6 +216,7 @@
isa = PBXGroup;
children = (
DAC3D9822BC33FD000A727C9 /* AppState.swift */,
+ DA5268AC2EB12FE200DCB941 /* ServerState.swift */,
DA2863D92B37BF6E00A7D050 /* Preferences.swift */,
DACCE5E02EABE4B4008CDD92 /* AppUpdate.swift */,
);
@@ -600,6 +603,7 @@
DABFCC292B1530DC009F40D2 /* FoundationExtensions.swift in Sources */,
DA57536C2B36BA1D00FAC277 /* TextDocument.swift in Sources */,
DACCE5E12EABE4B4008CDD92 /* AppUpdate.swift in Sources */,
+ DA5268AD2EB12FE200DCB941 /* ServerState.swift in Sources */,
DA77253F2B21176D006C5ABB /* NewsView.swift in Sources */,
DAC6B2E22EAEE9FE004E2CBA /* NetSocketNew.swift in Sources */,
DA99218E2C51AA5D0058FA6C /* HotlineDataBuilder.swift in Sources */,
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 {