diff options
| author | Dustin Mierau <dustin@mierau.me> | 2024-01-15 20:20:47 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2024-01-15 20:20:47 -0800 |
| commit | 7c9f6686044035c022a17551151cf1cbed0dc665 (patch) | |
| tree | d41403b6f64d3375fdea8cee48d9db91c3ce26e0 /Hotline/macOS/NewsView.swift | |
| parent | faae9cd1b47c6f22f3bcf4b1a24a4f7df41af9ed (diff) | |
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.
Diffstat (limited to 'Hotline/macOS/NewsView.swift')
| -rw-r--r-- | Hotline/macOS/NewsView.swift | 86 |
1 files changed, 61 insertions, 25 deletions
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 { |