We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c60909 commit 69093a2Copy full SHA for 69093a2
MacImageManager/MacImageManager/Models/FileItem.swift
@@ -18,4 +18,20 @@ struct FileItem: Identifiable, Hashable {
18
let isDirectory: Bool
19
let fileSize: Int
20
let modificationDate: Date
21
+
22
+ var formattedFileSize: String {
23
+ if fileSize < 1024 {
24
+ return "\(fileSize) B"
25
+ }
26
+ let kb = Double(fileSize) / 1024.0
27
+ if kb < 1024 {
28
+ return String(format: "%.1f KB", kb)
29
30
+ let mb = kb / 1024.0
31
+ if mb < 1024 {
32
+ return String(format: "%.1f MB", mb)
33
34
+ let gb = mb / 1024.0
35
+ return String(format: "%.2f GB", gb)
36
37
}
0 commit comments