From 45829daa856b376b1ab04d415917110b71b1dec5 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Wed, 5 Feb 2025 22:27:17 +0100 Subject: Apply formatting --- Hotline/iOS/FilesView.swift | 53 ++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) (limited to 'Hotline/iOS/FilesView.swift') diff --git a/Hotline/iOS/FilesView.swift b/Hotline/iOS/FilesView.swift index 017a469..70b07c2 100644 --- a/Hotline/iOS/FilesView.swift +++ b/Hotline/iOS/FilesView.swift @@ -3,11 +3,11 @@ import UniformTypeIdentifiers struct FileView: View { @Environment(Hotline.self) private var model: Hotline - + @State var expanded = false - + var file: FileInfo - + var body: some View { if file.isFolder { DisclosureGroup(isExpanded: $expanded) { @@ -17,7 +17,7 @@ struct FileView: View { } } label: { HStack { - HStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) { + HStack(alignment: /*@START_MENU_TOKEN@*/ .center /*@END_MENU_TOKEN@*/) { Image(systemName: "folder.fill") } .frame(minWidth: 25) @@ -30,20 +30,19 @@ struct FileView: View { if !expanded { return } - + // Some servers don't reply when asking for the contents of an empty folder. if file.isFolder && file.fileSize == 0 { return } - + Task { await model.getFileList(path: file.path) } } - } - else { + } else { HStack { - HStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/) { + HStack(alignment: /*@START_MENU_TOKEN@*/ .center /*@END_MENU_TOKEN@*/) { fileIcon(name: file.name) .renderingMode(.template) } @@ -54,53 +53,49 @@ struct FileView: View { } } } - + static let byteFormatter = ByteCountFormatter() - + private func formattedFileSize(_ fileSize: UInt) -> String { // let bcf = ByteCountFormatter() FileView.byteFormatter.allowedUnits = [.useAll] FileView.byteFormatter.countStyle = .file return FileView.byteFormatter.string(fromByteCount: Int64(fileSize)) } - + private func fileIcon(name: String) -> Image { // func utTypeForFilename(_ filename: String) -> UTType? { let fileExtension = (name as NSString).pathExtension if let fileType = UTType(filenameExtension: fileExtension) { print("\(name) \(fileExtension) = \(fileType)") - + if fileType.isSubtype(of: .movie) { return Image(systemName: "play.rectangle") -// return UIImage(systemName: "play.rectangle")! - } - else if fileType.isSubtype(of: .image) { + // return UIImage(systemName: "play.rectangle")! + } else if fileType.isSubtype(of: .image) { return Image(systemName: "photo") -// return UIImage(systemName: "photo")! - } - else if fileType.isSubtype(of: .archive) { + // return UIImage(systemName: "photo")! + } else if fileType.isSubtype(of: .archive) { return Image(systemName: "doc.zipper") -// return UIImage(systemName: "doc.zipper")! - } - else if fileType.isSubtype(of: .text) { + // return UIImage(systemName: "doc.zipper")! + } else if fileType.isSubtype(of: .text) { return Image(systemName: "doc.text") -// return UIImage(systemName: "doc.text")! - } - else { + // return UIImage(systemName: "doc.text")! + } else { return Image(systemName: "doc") -// return UIImage(systemName: "doc")! + // return UIImage(systemName: "doc")! } } - + return Image(systemName: "doc") } } struct FilesView: View { @Environment(Hotline.self) private var model: Hotline - + @State var initialLoadComplete = false - + var body: some View { NavigationStack { List(model.files) { file in -- cgit