From 7c9f6686044035c022a17551151cf1cbed0dc665 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Mon, 15 Jan 2024 20:20:47 -0800 Subject: Add classic sound effects. Fix read user access bits. Better no content/no access views. Add Server menu. Add keep alive ping to server every 3 minutes. --- Hotline/Application.swift | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Hotline/Application.swift') diff --git a/Hotline/Application.swift b/Hotline/Application.swift index e7445dc..fdada40 100644 --- a/Hotline/Application.swift +++ b/Hotline/Application.swift @@ -13,6 +13,10 @@ struct Application: App { #endif @State private var preferences = Prefs() + @State private var soundEffects = SoundEffectPlayer() + + @FocusedValue(\.activeHotlineModel) private var activeHotline: Hotline? + @FocusedValue(\.activeServerState) private var activeServerState: ServerState? var body: some Scene { #if os(iOS) @@ -35,6 +39,7 @@ struct Application: App { ServerView(server: server) .frame(minWidth: 400, minHeight: 300) .environment(preferences) + .environment(soundEffects) } defaultValue: { Server(name: nil, description: nil, address: "") } @@ -47,6 +52,39 @@ struct Application: App { } .keyboardShortcut(.init("K"), modifiers: .command) } + CommandMenu("Server") { + Button("Disconnect") { + activeHotline?.disconnect() + } + .disabled(activeHotline?.status == .disconnected) + Divider() + Button("Broadcast Message...") { + // TODO: Implement broadcast message when user is allowed. + } + .disabled(true) + .keyboardShortcut(.init("B"), modifiers: .command) + Divider() + Button("Show Chat") { + activeServerState?.selection = .chat + } + .disabled(activeHotline?.status != .loggedIn) + .keyboardShortcut(.init("1"), modifiers: .command) + Button("Show News") { + activeServerState?.selection = .news + } + .disabled(activeHotline?.status != .loggedIn) + .keyboardShortcut(.init("2"), modifiers: .command) + Button("Show Message Board") { + activeServerState?.selection = .board + } + .disabled(activeHotline?.status != .loggedIn) + .keyboardShortcut(.init("3"), modifiers: .command) + Button("Show Files") { + activeServerState?.selection = .files + } + .disabled(activeHotline?.status != .loggedIn) + .keyboardShortcut(.init("4"), modifiers: .command) + } } // MARK: Settings Window -- cgit