aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/NewsView.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2023-12-06 13:52:20 -0800
committerDustin Mierau <dustin@mierau.me>2023-12-06 13:52:20 -0800
commitc0068f11c51bb587c16dfacb73629b3c6fb67fc8 (patch)
tree20753433f348b03bb590e0fe6a4cafbe56f4c859 /Hotline/Views/NewsView.swift
parent06a2166415bca7e5fe32eac505859bdd690ab8e0 (diff)
Further work on UI organization
Diffstat (limited to 'Hotline/Views/NewsView.swift')
-rw-r--r--Hotline/Views/NewsView.swift70
1 files changed, 70 insertions, 0 deletions
diff --git a/Hotline/Views/NewsView.swift b/Hotline/Views/NewsView.swift
new file mode 100644
index 0000000..5f2dbe9
--- /dev/null
+++ b/Hotline/Views/NewsView.swift
@@ -0,0 +1,70 @@
+import SwiftUI
+
+struct NewsView: View {
+ @Environment(HotlineState.self) private var appState
+ @Environment(HotlineClient.self) private var hotline
+
+ @State private var fetched = false
+
+ var body: some View {
+// @Bindable var config = appState
+ NavigationStack {
+ ScrollView {
+ LazyVStack(alignment: .leading) {
+// ForEach(hotline.messageBoardMessages, id: \.self) {
+// Text($0)
+// .lineLimit(100)
+// .padding()
+// .textSelection(.enabled)
+// Divider()
+// }
+ }
+ Spacer()
+ }
+ .task {
+ if !fetched {
+ hotline.sendGetNewsCategories() {
+ fetched = true
+ }
+ }
+ }
+ .refreshable {
+ hotline.sendGetNewsCategories()
+ }
+ .navigationBarTitleDisplayMode(.inline)
+ .toolbar {
+ ToolbarItem(placement: .principal) {
+ Text(hotline.server?.name ?? "")
+ .font(.headline)
+ }
+ ToolbarItem(placement: .navigationBarLeading) {
+ Button {
+ hotline.disconnect()
+ } label: {
+ Image(systemName: "xmark.circle.fill")
+ .symbolRenderingMode(.hierarchical)
+ .foregroundColor(.secondary)
+ }
+
+ }
+ ToolbarItem(placement: .navigationBarTrailing) {
+ Button {
+
+ } label: {
+ Image(systemName: "square.and.pencil")
+// .symbolRenderingMode(.hierarchical)
+// .foregroundColor(.secondary)
+ }
+
+ }
+ }
+ }
+
+ }
+}
+
+#Preview {
+ MessageBoardView()
+ .environment(HotlineState())
+ .environment(HotlineClient())
+}