From c0068f11c51bb587c16dfacb73629b3c6fb67fc8 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Wed, 6 Dec 2023 13:52:20 -0800 Subject: Further work on UI organization --- Hotline/Views/NewsView.swift | 70 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Hotline/Views/NewsView.swift (limited to 'Hotline/Views/NewsView.swift') 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()) +} -- cgit