Repository Public MIT
1{2 "accessibility" : [3 "Each cell is a button labelled \"Image n of m, description\" with the image trait.",4 "In the viewer the image carries the same label and supports the VoiceOver zoom action; the buttons are labelled \"Previous\", \"Next\" and \"Close\".",5 "Keyboard: left and right arrows navigate, Escape closes.",6 "Failure is a symbol plus text. The double-tap zoom animation becomes a short fade with Reduce Motion."7 ],8 "category" : "media",9 "changelog" : [10 {11 "changes" : [12 "Initial release."13 ],14 "date" : "2026-12-02",15 "version" : "1.0.0"16 }17 ],18 "dependencies" : [19 {20 "id" : "glass-foundation",21 "version" : "1.0.0"22 },23 {24 "id" : "glass-icon-button",25 "version" : "1.0.0"26 },27 {28 "id" : "glass-media-support",29 "version" : "1.0.0"30 }31 ],32 "description" : "Lazy image grid with a zoomable viewer, navigation and cancellable loading.",33 "examples" : [34 {35 "code" : "import SwiftUI\nimport CoreGraphics\nimport SPGlassKit\n\npublic struct GlassGalleryExample: GlassExample {\n public static let componentID = \"glass-gallery\"\n\n public init() {}\n\n public var body: some View {\n VStack(alignment: .leading, spacing: 8) {\n Text(\"Sample data · gradients generated in code, one slow image and one failing image.\")\n .font(.caption)\n .foregroundStyle(.secondary)\n .padding(.horizontal)\n GlassGallery(items: Self.items, cacheCapacity: 12)\n }\n }\n\n private struct SampleLoadingError: Error {}\n\n static let items: [GlassGalleryItem] = {\n let names = [\"Dawn\", \"Lagoon\", \"Orchard\", \"Ember\", \"Glacier\", \"Dusk\", \"Moss\", \"Coral\", \"Slate\", \"Saffron\", \"Iris\", \"Tundra\"]\n var items = names.enumerated().map { index, name in\n GlassGalleryItem(id: \"gradient-\\(index)\", description: \"\\(name) gradient\", loadCGImage: {\n // Stands in for decoding a file; the sleep makes cancellation observable while scrolling.\n try await Task.sleep(for: .milliseconds(index == 3 ? 1_500 : 120))\n return try gradient(hue: Double(index) / Double(names.count))\n })\n }\n items.insert(GlassGalleryItem(id: \"local-symbol\", description: \"Local symbol image\", image: Image(systemName: \"mountain.2.fill\")), at: 1)\n items.insert(GlassGalleryItem(id: \"broken\", description: \"An image that fails to load\", load: { throw SampleLoadingError() }), at: 5)\n return items\n }()\n\n /// Draws a diagonal two-colour gradient into a bitmap.\n nonisolated static func gradient(hue: Double, side: Int = 256) throws -> CGImage {\n let space = CGColorSpaceCreateDeviceRGB()\n guard let context = CGContext(data: nil, width: side, height: side, bitsPerComponent: 8, bytesPerRow: 0, space: space, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else {\n throw SampleLoadingError()\n }\n let colors = [rgb(hue: hue), rgb(hue: (hue + 0.18).truncatingRemainder(dividingBy: 1))] as CFArray\n guard let gradient = CGGradient(colorsSpace: space, colors: colors, locations: [0, 1]) else {\n throw SampleLoadingError()\n }\n context.drawLinearGradient(gradient, start: .zero, end: CGPoint(x: side, y: side), options: [])\n guard let image = context.makeImage() else { throw SampleLoadingError() }\n return image\n }\n\n /// A saturated colour for a hue in 0…1, without any platform colour type.\n nonisolated private static func rgb(hue: Double) -> CGColor {\n let sector = hue * 6\n let x = 1 - abs(sector.truncatingRemainder(dividingBy: 2) - 1)\n let (r, g, b): (Double, Double, Double) = switch Int(sector) % 6 {\n case 0: (1, x, 0)\n case 1: (x, 1, 0)\n case 2: (0, 1, x)\n case 3: (0, x, 1)\n case 4: (x, 0, 1)\n default: (1, 0, x)\n }\n return CGColor(red: 0.25 + 0.6 * r, green: 0.25 + 0.6 * g, blue: 0.25 + 0.6 * b, alpha: 1)\n }\n}\n\n#Preview(\"GlassGallery\") { GlassGalleryExample().glassTheme(.crystal) }\n",36 "title" : "GlassGallery example"37 }38 ],39 "files" : [40 {41 "bytes" : 9178,42 "path" : "Media/Media/GlassGallery+Viewer.swift",43 "sha256" : "737ca24a62cd279be92672f83b165b9625c2ee7e29e0b12df4f48c98a7c5501a"44 },45 {46 "bytes" : 9429,47 "path" : "Media/Media/GlassGallery.swift",48 "sha256" : "b8ecfb9a9b181d9a0cbf75da3d5986bc8d088fdf401a4d208be41afb1b0ca825"49 }50 ],51 "frameworks" : [5253 ],54 "id" : "glass-gallery",55 "kind" : "content-component",56 "license" : "MIT",57 "minimumOS" : {58 "iOS" : "26.0",59 "iPadOS" : "26.0",60 "macOS" : "26.0"61 },62 "name" : "GlassGallery",63 "platforms" : [64 "iOS",65 "iPadOS",66 "macOS"67 ],68 "schemaVersion" : 1,69 "sha256" : "7cba1b7cddb0024c1bb3df053357ff2add91d399b9dad8e83487d681e1730c09",70 "symbols" : [71 "GlassGalleryZoom",72 "GlassGalleryItem",73 "GlassGalleryLoading",74 "GlassGallery"75 ],76 "version" : "1.0.0"77}78