diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-05 17:41:22 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-05 17:41:22 -0800 |
| commit | 06a2166415bca7e5fe32eac505859bdd690ab8e0 (patch) | |
| tree | d47d4ea30766a8e382deafa607a7abe66f47f9ab /Hotline/Views/FilesView.swift | |
| parent | b99219f16792be4a06a89f1f32a59f0bf97bba68 (diff) | |
Some styling work. Files showing. Message board tweaks.
Diffstat (limited to 'Hotline/Views/FilesView.swift')
| -rw-r--r-- | Hotline/Views/FilesView.swift | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Hotline/Views/FilesView.swift b/Hotline/Views/FilesView.swift index d910af2..7bacbce 100644 --- a/Hotline/Views/FilesView.swift +++ b/Hotline/Views/FilesView.swift @@ -5,10 +5,33 @@ struct FilesView: View { @State private var fetched = false + static let byteFormatter = ByteCountFormatter() + + private func formattedFileSize(_ fileSize: UInt32) -> String { +// let bcf = ByteCountFormatter() + FilesView.byteFormatter.allowedUnits = [.useAll] + FilesView.byteFormatter.countStyle = .file + return FilesView.byteFormatter.string(fromByteCount: Int64(fileSize)) + } + var body: some View { - List(hotline.fileList) { - FileListView(item: $0) + List(hotline.fileList, id: \.self, children: \.files) { tree in + HStack { + if tree.isFolder { + Image(systemName: "folder") + Text(tree.name).bold() + Spacer() + Text("\(tree.fileSize)").foregroundStyle(.gray) + } + else { + Image(systemName: "doc") + Text(tree.name).bold() + Spacer() + Text(formattedFileSize(tree.fileSize)).foregroundStyle(.gray) + } + } } + .listStyle(.plain) .task { if !fetched { hotline.sendGetFileList() { |