From 06a2166415bca7e5fe32eac505859bdd690ab8e0 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 5 Dec 2023 17:41:22 -0800 Subject: Some styling work. Files showing. Message board tweaks. --- Hotline/Views/FilesView.swift | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'Hotline/Views/FilesView.swift') 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() { -- cgit