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/macOS/NewsView.swift | 86 +++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 25 deletions(-) (limited to 'Hotline/macOS/NewsView.swift') diff --git a/Hotline/macOS/NewsView.swift b/Hotline/macOS/NewsView.swift index bfc0cc0..875765e 100644 --- a/Hotline/macOS/NewsView.swift +++ b/Hotline/macOS/NewsView.swift @@ -14,21 +14,59 @@ struct NewsView: View { @State private var editorOpen: Bool = false var body: some View { - NavigationStack { - VSplit( - top: { - newsBrowser - }, - bottom: { - articleViewer + Group { + if model.serverVersion < 151 { + VStack { + Text("No News") + .bold() + .foregroundStyle(.secondary) + .font(.title3) + Text("This server has news turned off.") + .foregroundStyle(.tertiary) + .font(.system(size: 13)) + } + .padding() + } + else { + NavigationStack { + VSplit( + top: { + if !model.newsLoaded { + loadingIndicator + } + else if model.news.isEmpty { + VStack { + Text("No News") + .bold() + .foregroundStyle(.secondary) + .font(.title3) + Text("This server has no news available.") + .foregroundStyle(.tertiary) + .font(.system(size: 13)) + } + .padding() + } + else { + newsBrowser + } + }, + bottom: { + articleViewer + } + ) + .fraction(splitFraction) + .constraints(minPFraction: 0.1, minSFraction: 0.3) + .hide(splitHidden) + .styling(color: colorScheme == .dark ? .black : Splitter.defaultColor, inset: 0, visibleThickness: 0.5, invisibleThickness: 5, hideSplitter: true) + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(Color(nsColor: .textBackgroundColor)) } - ) - .fraction(splitFraction) - .constraints(minPFraction: 0.1, minSFraction: 0.3) - .hide(splitHidden) - .styling(color: colorScheme == .dark ? .black : Splitter.defaultColor, inset: 0, visibleThickness: 0.5, invisibleThickness: 5, hideSplitter: true) - .frame(maxWidth: .infinity, maxHeight: .infinity) - .background(Color(nsColor: .textBackgroundColor)) + .task { + if !model.newsLoaded { + let _ = await model.getNewsList() + } + } + } } // .sheet(isPresented: $editorOpen) { // print("Sheet dismissed!") @@ -73,11 +111,6 @@ struct NewsView: View { .environment(\.defaultMinListRowHeight, 34) .listStyle(.inset) .alternatingRowBackgrounds(.enabled) - .task { - if !model.newsLoaded { - let _ = await model.getNewsList() - } - } .contextMenu(forSelectionType: NewsInfo.self) { items in // ... } primaryAction: { items in @@ -130,15 +163,18 @@ struct NewsView: View { } return .ignored } - .overlay { - if !model.newsLoaded { - VStack { - ProgressView() - .controlSize(.regular) + } + + var loadingIndicator: some View { + VStack { + HStack { + ProgressView { + Text("Loading News") } - .frame(maxWidth: .infinity) + .controlSize(.regular) } } + .frame(maxWidth: .infinity) } var articleViewer: some View { -- cgit