import SwiftUI import UIKit private struct ShowImageButton: View { let index: Int let count: Int let description: String? let openImage: () -> Void var body: some View { Button(action: openImage) { Label(count == 1 ? "Show image" : "Show image \(index + 1) of \(count)", systemImage: "photo") .appFont(.subheadline, weight: .medium) .frame(maxWidth: .infinity, minHeight: 48) .modifier(MediaControlSurface()) } .buttonStyle(.plain) .accessibilityIdentifier("showImageButton-\(index + 1)") .accessibilityHint(description ?? "") } } private struct ImageGalleryGrid: View { @Environment(\.dynamicTypeSize) private var dynamicTypeSize let count: Int @ViewBuilder var content: (Int) -> Content private var rows: [Range] { guard count > 0 else { return [] } let squareSide = Int(Double(count).squareRoot()) let rowCount: Int if dynamicTypeSize.isAccessibilitySize { rowCount = count } else if count <= 2 { rowCount = 1 } else { rowCount = squareSide * squareSide == count ? squareSide : 2 } let imagesPerRow = count / rowCount let extraImages = count % rowCount return (0..