aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/FilesView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/Views/FilesView.swift')
-rw-r--r--Hotline/Views/FilesView.swift27
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() {