feat(ios): zoom image attachments full screen

Tapping a user attachment or a generated image opens a pannable,
pinch-zoomable viewer. Zoom math (fit scale, clamping, double-tap
targets) is pure and unit tested so the gestures stay predictable.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
2026-12-05 12:09:07 +08:00
co-authored by HAPI
parent 4127106093
commit 0d8abb7e2c
4 changed files with 264 additions and 51 deletions
@@ -78,7 +78,9 @@ private struct GeneratedMediaCard: View {
if phase != .active { content.pause() }
}
.fullScreenCover(isPresented: $imageOpen) {
ImageViewer(image: content.image, title: content.block.fileName)
if let image = content.image {
ZoomableImageViewer(image: image, title: content.block.fileName)
}
}
.sheet(isPresented: $previewOpen) {
if let file = content.file {
@@ -190,31 +192,3 @@ private struct GeneratedMediaPreview: UIViewControllerRepresentable {
}
/// Minimal full-screen image viewer; keep the existing tap-to-dismiss behavior.
private struct ImageViewer: View {
let image: UIImage?
let title: String
@Environment(\.dismiss) private var dismiss
var body: some View {
ZStack(alignment: .topTrailing) {
Color.black.ignoresSafeArea()
if let image {
Image(uiImage: image)
.resizable()
.scaledToFit()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(8)
} else {
Text(verbatim: title).foregroundStyle(.white)
}
Button { dismiss() } label: {
Image(systemName: "xmark.circle.fill")
.font(.title2)
.foregroundStyle(.white.opacity(0.8))
.padding(16)
}
.accessibilityLabel("Close")
}
.onTapGesture { dismiss() }
}
}