mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-05 07:07:04 +00:00
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:
@@ -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() }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user