Skip to content

Commit e1529aa

Browse files
committed
Improve formatting for image metadata
1 parent f0a6180 commit e1529aa

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Sources/PulseUI/Views/ImageViewer.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,24 @@ struct ImagePreviewViewModel {
6363
}
6464
}
6565

66-
var info: [(String, String?)] = [
67-
("Resolution", originalImageSize.map { "\(Int($0.width)) × \(Int($0.height)) px" }),
66+
let info: [(String, String?)] = [
67+
("Resolution", originalImageSize.map(formattedResolution)),
6868
("Size", ByteCountFormatter.string(fromByteCount: context.originalSize)),
6969
("Type", context.contentType?.rawValue),
70-
("Displayed", isShowingOriginal ? "original image" : "preview (original not saved)")
70+
("Source", isShowingOriginal ? "Original" : "Thumbnail (\(formattedResolution(with: image.size)))")
7171
]
72-
if !isShowingOriginal {
73-
info.append(("Preview Size (Decompressed)", ByteCountFormatter.string(fromByteCount: Int64(data.count))))
74-
}
7572

7673
self.image = image
7774
self.info = KeyValueSectionViewModel(title: "Image", color: .pink, items: info)
7875
}
7976
}
77+
78+
private extension CGSize {
79+
func scaled(by scale: CGFloat) -> CGSize {
80+
CGSize(width: width * scale, height: width * height)
81+
}
82+
}
83+
84+
private func formattedResolution(with pixelSize: CGSize) -> String {
85+
"\(Int(pixelSize.width)) × \(Int(pixelSize.height)) px"
86+
}

0 commit comments

Comments
 (0)