aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/FilesView.swift
blob: 0e1bb91106b81fde95e4a6722bdcfd2a9eb391dd (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
import SwiftUI

struct FilesView: View {
  @Environment(HotlineClient.self) private var hotline
  
  @State private var fetched = false
  
  var body: some View {
    ScrollView {
      VStack(spacing: 0) {
        List(hotline.userList) { u in
          HStack(alignment: .firstTextBaseline) {
            Text(u.name).bold().foregroundStyle(u.isAdmin ? Color.red : Color.black)
          }
        }
        .padding()
      }
    }
    .task {
      if !fetched {
        hotline.sendGetFileList() {
          fetched = true
        }
      }
    }
  }
}

#Preview {
  FilesView()
    .environment(HotlineClient())
}