aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/MessageBoardView.swift
blob: e5f1521fdfbe47cd8a9505afc54c81909f0a0727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import SwiftUI

struct MessageBoardView: 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
    
    VStack(alignment: .leading) {
      ScrollView {
        VStack(alignment: .leading) {
          Text(hotline.messageBoard)
            .fontDesign(.monospaced)
            .padding()
            .dynamicTypeSize(.small)
            .textSelection(.enabled)
        }
      }
    }
    .presentationDetents([.fraction(0.6)])
    .presentationDragIndicator(.visible)
    .task {
      if !fetched {
        hotline.sendGetNews() {
          fetched = true
        }
      }
    }
    .refreshable {
      hotline.sendGetNews()
    }
  }
}

#Preview {
  MessageBoardView()
    .environment(HotlineState())
    .environment(HotlineClient())
}