aboutsummaryrefslogtreecommitdiff
path: root/Hotline/iOS/MessageBoardView.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2023-12-19 20:38:13 -0800
committerDustin Mierau <dustin@mierau.me>2023-12-19 20:38:13 -0800
commit4fd69c02a3e7b581bb9229865336c315153f3b18 (patch)
treee6e11d872424196f2b4033077902126ad5556e40 /Hotline/iOS/MessageBoardView.swift
parent5e87b5927cd931d46fb5f72fb035480a95969a9f (diff)
Beginnings of a UI for macOS as well as some visual changes to iOS client. :)
Diffstat (limited to 'Hotline/iOS/MessageBoardView.swift')
-rw-r--r--Hotline/iOS/MessageBoardView.swift74
1 files changed, 74 insertions, 0 deletions
diff --git a/Hotline/iOS/MessageBoardView.swift b/Hotline/iOS/MessageBoardView.swift
new file mode 100644
index 0000000..0d3968f
--- /dev/null
+++ b/Hotline/iOS/MessageBoardView.swift
@@ -0,0 +1,74 @@
+import SwiftUI
+
+struct MessageBoardView: View {
+ @Environment(Hotline.self) private var model: Hotline
+
+ @State private var initialLoadComplete = false
+ @State private var fetched = false
+
+ var body: some View {
+ NavigationStack {
+ ScrollView {
+ LazyVStack(alignment: .leading) {
+ ForEach(model.messageBoard, id: \.self) {
+ Text($0)
+ .lineLimit(100)
+ .padding()
+ .textSelection(.enabled)
+ Divider()
+ }
+ }
+ Spacer()
+ }
+ .task {
+ if !initialLoadComplete {
+ let _ = await model.getMessageBoard()
+ initialLoadComplete = true
+ }
+ }
+ .overlay {
+ if !initialLoadComplete {
+ VStack {
+ ProgressView()
+ .controlSize(.large)
+ }
+ .frame(maxWidth: .infinity)
+ }
+ }
+ .refreshable {
+ let _ = await model.getMessageBoard()
+ initialLoadComplete = true
+ }
+ .navigationBarTitleDisplayMode(.inline)
+ .toolbar {
+ ToolbarItem(placement: .principal) {
+ Text(model.serverTitle)
+ .font(.headline)
+ }
+ ToolbarItem(placement: .navigationBarLeading) {
+ Button {
+ model.disconnect()
+ } label: {
+ Text(Image(systemName: "xmark.circle.fill"))
+ .symbolRenderingMode(.hierarchical)
+ .font(.title2)
+ .foregroundColor(.secondary)
+ }
+ }
+ ToolbarItem(placement: .navigationBarTrailing) {
+ Button {
+
+ } label: {
+ Image(systemName: "square.and.pencil")
+ }
+ }
+ }
+ }
+
+ }
+}
+
+#Preview {
+ MessageBoardView()
+ .environment(Hotline(trackerClient: HotlineTrackerClient(), client: HotlineClient()))
+}